Lines Matching defs:rl

21  * @rl: Pointer to TLS record layer data
30 int tlsv1_record_set_cipher_suite(struct tlsv1_record_layer *rl,
38 rl->cipher_suite = cipher_suite;
45 rl->hash_alg = CRYPTO_HASH_ALG_HMAC_MD5;
46 rl->hash_size = MD5_MAC_LEN;
48 rl->hash_alg = CRYPTO_HASH_ALG_HMAC_SHA1;
49 rl->hash_size = SHA1_MAC_LEN;
51 rl->hash_alg = CRYPTO_HASH_ALG_HMAC_SHA256;
52 rl->hash_size = SHA256_MAC_LEN;
59 rl->key_material_len = data->key_material;
60 rl->iv_size = data->block_size;
61 rl->cipher_alg = data->alg;
69 * @rl: Pointer to TLS record layer data
75 int tlsv1_record_change_write_cipher(struct tlsv1_record_layer *rl)
78 "0x%04x", rl->cipher_suite);
79 rl->write_cipher_suite = rl->cipher_suite;
80 os_memset(rl->write_seq_num, 0, TLS_SEQ_NUM_LEN);
82 if (rl->write_cbc) {
83 crypto_cipher_deinit(rl->write_cbc);
84 rl->write_cbc = NULL;
86 if (rl->cipher_alg != CRYPTO_CIPHER_NULL) {
87 rl->write_cbc = crypto_cipher_init(rl->cipher_alg,
88 rl->write_iv, rl->write_key,
89 rl->key_material_len);
90 if (rl->write_cbc == NULL) {
103 * @rl: Pointer to TLS record layer data
109 int tlsv1_record_change_read_cipher(struct tlsv1_record_layer *rl)
112 "0x%04x", rl->cipher_suite);
113 rl->read_cipher_suite = rl->cipher_suite;
114 os_memset(rl->read_seq_num, 0, TLS_SEQ_NUM_LEN);
116 if (rl->read_cbc) {
117 crypto_cipher_deinit(rl->read_cbc);
118 rl->read_cbc = NULL;
120 if (rl->cipher_alg != CRYPTO_CIPHER_NULL) {
121 rl->read_cbc = crypto_cipher_init(rl->cipher_alg,
122 rl->read_iv, rl->read_key,
123 rl->key_material_len);
124 if (rl->read_cbc == NULL) {
137 * @rl: Pointer to TLS record layer data
150 int tlsv1_record_send(struct tlsv1_record_layer *rl, u8 content_type, u8 *buf,
167 WPA_PUT_BE16(pos, rl->tls_version);
175 explicit_iv = rl->write_cipher_suite != TLS_NULL_WITH_NULL_NULL &&
176 rl->iv_size && rl->tls_version >= TLS_VERSION_1_1;
179 if (pos + rl->iv_size > buf + buf_size)
187 if (os_get_random(pos, rl->iv_size))
189 pos += rl->iv_size;
201 if (rl->write_cipher_suite != TLS_NULL_WITH_NULL_NULL) {
207 hmac = crypto_hash_init(rl->hash_alg, rl->write_mac_secret,
208 rl->hash_size);
214 crypto_hash_update(hmac, rl->write_seq_num, TLS_SEQ_NUM_LEN);
219 if (clen < rl->hash_size) {
234 if (rl->iv_size) {
237 pad = (len + 1) % rl->iv_size;
239 pad = rl->iv_size - pad;
249 if (crypto_cipher_encrypt(rl->write_cbc, cpayload,
255 inc_byte_array(rl->write_seq_num, TLS_SEQ_NUM_LEN);
265 * @rl: Pointer to TLS record layer data
278 int tlsv1_record_receive(struct tlsv1_record_layer *rl,
355 if (rl->read_cipher_suite != TLS_NULL_WITH_NULL_NULL) {
357 if (crypto_cipher_decrypt(rl->read_cbc, in_data,
366 if (rl->iv_size) {
378 if (rl->tls_version >= TLS_VERSION_1_1) {
380 if (plen < rl->iv_size) {
386 os_memmove(out_data, out_data + rl->iv_size,
387 plen - rl->iv_size);
388 plen -= rl->iv_size;
427 if (plen < rl->hash_size) {
434 plen -= rl->hash_size;
436 hmac = crypto_hash_init(rl->hash_alg, rl->read_mac_secret,
437 rl->hash_size);
445 crypto_hash_update(hmac, rl->read_seq_num, TLS_SEQ_NUM_LEN);
458 if (hlen != rl->hash_size ||
482 inc_byte_array(rl->read_seq_num, TLS_SEQ_NUM_LEN);