Lines Matching refs:cctx
330 EVP_AES_CCM_CTX *cctx = EVP_C_DATA(EVP_AES_CCM_CTX,ctx); in aesni_ccm_init_key() local
342 aesni_set_encrypt_key(key, keylen, &cctx->ks.ks); in aesni_ccm_init_key()
343 CRYPTO_ccm128_init(&cctx->ccm, cctx->M, cctx->L, in aesni_ccm_init_key()
344 &cctx->ks, (block128_f) aesni_encrypt); in aesni_ccm_init_key()
345 cctx->str = enc ? (ccm128_f) aesni_ccm64_encrypt_blocks : in aesni_ccm_init_key()
347 cctx->key_set = 1; in aesni_ccm_init_key()
350 memcpy(ctx->iv, iv, 15 - cctx->L); in aesni_ccm_init_key()
351 cctx->iv_set = 1; in aesni_ccm_init_key()
713 EVP_AES_CCM_CTX *cctx = EVP_C_DATA(EVP_AES_CCM_CTX,ctx); in aes_t4_ccm_init_key() local
725 aes_t4_set_encrypt_key(key, bits, &cctx->ks.ks); in aes_t4_ccm_init_key()
726 CRYPTO_ccm128_init(&cctx->ccm, cctx->M, cctx->L, in aes_t4_ccm_init_key()
727 &cctx->ks, (block128_f) aes_t4_encrypt); in aes_t4_ccm_init_key()
728 cctx->str = NULL; in aes_t4_ccm_init_key()
729 cctx->key_set = 1; in aes_t4_ccm_init_key()
732 memcpy(ctx->iv, iv, 15 - cctx->L); in aes_t4_ccm_init_key()
733 cctx->iv_set = 1; in aes_t4_ccm_init_key()
1023 S390X_AES_ECB_CTX *cctx = EVP_C_DATA(S390X_AES_ECB_CTX, ctx); in s390x_aes_ecb_init_key() local
1030 cctx->fc = S390X_AES_FC(keylen); in s390x_aes_ecb_init_key()
1032 cctx->fc |= S390X_DECRYPT; in s390x_aes_ecb_init_key()
1034 memcpy(cctx->km.param.k, key, keylen); in s390x_aes_ecb_init_key()
1041 S390X_AES_ECB_CTX *cctx = EVP_C_DATA(S390X_AES_ECB_CTX, ctx); in s390x_aes_ecb_cipher() local
1043 s390x_km(in, len, out, cctx->fc, &cctx->km.param); in s390x_aes_ecb_cipher()
1051 S390X_AES_OFB_CTX *cctx = EVP_C_DATA(S390X_AES_OFB_CTX, ctx); in s390x_aes_ofb_init_key() local
1064 memcpy(cctx->kmo.param.cv, iv, ivlen); in s390x_aes_ofb_init_key()
1065 memcpy(cctx->kmo.param.k, key, keylen); in s390x_aes_ofb_init_key()
1066 cctx->fc = S390X_AES_FC(keylen); in s390x_aes_ofb_init_key()
1073 S390X_AES_OFB_CTX *cctx = EVP_C_DATA(S390X_AES_OFB_CTX, ctx); in s390x_aes_ofb_cipher() local
1079 memcpy(cctx->kmo.param.cv, iv, ivlen); in s390x_aes_ofb_cipher()
1081 *out = *in ^ cctx->kmo.param.cv[n]; in s390x_aes_ofb_cipher()
1092 s390x_kmo(in, len, out, cctx->fc, &cctx->kmo.param); in s390x_aes_ofb_cipher()
1099 s390x_km(cctx->kmo.param.cv, 16, cctx->kmo.param.cv, cctx->fc, in s390x_aes_ofb_cipher()
1100 cctx->kmo.param.k); in s390x_aes_ofb_cipher()
1103 out[n] = in[n] ^ cctx->kmo.param.cv[n]; in s390x_aes_ofb_cipher()
1108 memcpy(iv, cctx->kmo.param.cv, ivlen); in s390x_aes_ofb_cipher()
1117 S390X_AES_CFB_CTX *cctx = EVP_C_DATA(S390X_AES_CFB_CTX, ctx); in s390x_aes_cfb_init_key() local
1130 cctx->fc = S390X_AES_FC(keylen); in s390x_aes_cfb_init_key()
1131 cctx->fc |= 16 << 24; /* 16 bytes cipher feedback */ in s390x_aes_cfb_init_key()
1133 cctx->fc |= S390X_DECRYPT; in s390x_aes_cfb_init_key()
1135 memcpy(cctx->kmf.param.cv, iv, ivlen); in s390x_aes_cfb_init_key()
1136 memcpy(cctx->kmf.param.k, key, keylen); in s390x_aes_cfb_init_key()
1143 S390X_AES_CFB_CTX *cctx = EVP_C_DATA(S390X_AES_CFB_CTX, ctx); in s390x_aes_cfb_cipher() local
1160 memcpy(cctx->kmf.param.cv, iv, ivlen); in s390x_aes_cfb_cipher()
1163 *out = cctx->kmf.param.cv[n] ^ tmp; in s390x_aes_cfb_cipher()
1164 cctx->kmf.param.cv[n] = enc ? *out : tmp; in s390x_aes_cfb_cipher()
1175 s390x_kmf(in, len, out, cctx->fc, &cctx->kmf.param); in s390x_aes_cfb_cipher()
1182 s390x_km(cctx->kmf.param.cv, 16, cctx->kmf.param.cv, in s390x_aes_cfb_cipher()
1183 S390X_AES_FC(keylen), cctx->kmf.param.k); in s390x_aes_cfb_cipher()
1187 out[n] = cctx->kmf.param.cv[n] ^ tmp; in s390x_aes_cfb_cipher()
1188 cctx->kmf.param.cv[n] = enc ? out[n] : tmp; in s390x_aes_cfb_cipher()
1193 memcpy(iv, cctx->kmf.param.cv, ivlen); in s390x_aes_cfb_cipher()
1202 S390X_AES_CFB_CTX *cctx = EVP_C_DATA(S390X_AES_CFB_CTX, ctx); in s390x_aes_cfb8_init_key() local
1215 cctx->fc = S390X_AES_FC(keylen); in s390x_aes_cfb8_init_key()
1216 cctx->fc |= 1 << 24; /* 1 byte cipher feedback */ in s390x_aes_cfb8_init_key()
1218 cctx->fc |= S390X_DECRYPT; in s390x_aes_cfb8_init_key()
1220 memcpy(cctx->kmf.param.cv, iv, ivlen); in s390x_aes_cfb8_init_key()
1221 memcpy(cctx->kmf.param.k, key, keylen); in s390x_aes_cfb8_init_key()
1228 S390X_AES_CFB_CTX *cctx = EVP_C_DATA(S390X_AES_CFB_CTX, ctx); in s390x_aes_cfb8_cipher() local
1232 memcpy(cctx->kmf.param.cv, iv, ivlen); in s390x_aes_cfb8_cipher()
1233 s390x_kmf(in, len, out, cctx->fc, &cctx->kmf.param); in s390x_aes_cfb8_cipher()
1234 memcpy(iv, cctx->kmf.param.cv, ivlen); in s390x_aes_cfb8_cipher()
1965 S390X_AES_CCM_CTX *cctx = EVP_C_DATA(S390X_AES_CCM_CTX, ctx); in s390x_aes_ccm_tls_cipher() local
1971 || len < (EVP_CCM_TLS_EXPLICIT_IV_LEN + (size_t)cctx->aes.ccm.m)) in s390x_aes_ccm_tls_cipher()
1979 len -= EVP_CCM_TLS_EXPLICIT_IV_LEN + cctx->aes.ccm.m; in s390x_aes_ccm_tls_cipher()
1985 s390x_aes_ccm_setiv(cctx, ivec, len); in s390x_aes_ccm_tls_cipher()
1988 s390x_aes_ccm_aad(cctx, buf, cctx->aes.ccm.tls_aad_len); in s390x_aes_ccm_tls_cipher()
1994 if (s390x_aes_ccm(cctx, in, out, len, enc)) in s390x_aes_ccm_tls_cipher()
1997 memcpy(out + len, cctx->aes.ccm.kmac_param.icv.b, cctx->aes.ccm.m); in s390x_aes_ccm_tls_cipher()
1998 return len + EVP_CCM_TLS_EXPLICIT_IV_LEN + cctx->aes.ccm.m; in s390x_aes_ccm_tls_cipher()
2000 if (!s390x_aes_ccm(cctx, in, out, len, enc)) { in s390x_aes_ccm_tls_cipher()
2001 if (!CRYPTO_memcmp(cctx->aes.ccm.kmac_param.icv.b, in + len, in s390x_aes_ccm_tls_cipher()
2002 cctx->aes.ccm.m)) in s390x_aes_ccm_tls_cipher()
2019 S390X_AES_CCM_CTX *cctx = EVP_C_DATA(S390X_AES_CCM_CTX, ctx); in s390x_aes_ccm_init_key() local
2032 cctx->aes.ccm.fc = S390X_AES_FC(keylen); in s390x_aes_ccm_init_key()
2033 memcpy(cctx->aes.ccm.kmac_param.k, key, keylen); in s390x_aes_ccm_init_key()
2036 cctx->aes.ccm.nonce.b[0] = ((cctx->aes.ccm.l - 1) & 0x7) in s390x_aes_ccm_init_key()
2037 | (((cctx->aes.ccm.m - 2) >> 1) & 0x7) << 3; in s390x_aes_ccm_init_key()
2038 memset(cctx->aes.ccm.nonce.b + 1, 0, in s390x_aes_ccm_init_key()
2039 sizeof(cctx->aes.ccm.nonce.b)); in s390x_aes_ccm_init_key()
2040 cctx->aes.ccm.blocks = 0; in s390x_aes_ccm_init_key()
2042 cctx->aes.ccm.key_set = 1; in s390x_aes_ccm_init_key()
2046 memcpy(ctx->iv, iv, 15 - cctx->aes.ccm.l); in s390x_aes_ccm_init_key()
2048 cctx->aes.ccm.iv_set = 1; in s390x_aes_ccm_init_key()
2063 S390X_AES_CCM_CTX *cctx = EVP_C_DATA(S390X_AES_CCM_CTX, ctx); in s390x_aes_ccm_cipher() local
2068 if (!cctx->aes.ccm.key_set) in s390x_aes_ccm_cipher()
2071 if (cctx->aes.ccm.tls_aad_len >= 0) in s390x_aes_ccm_cipher()
2082 if (!cctx->aes.ccm.iv_set) in s390x_aes_ccm_cipher()
2088 s390x_aes_ccm_setiv(cctx, ctx->iv, len); in s390x_aes_ccm_cipher()
2090 cctx->aes.ccm.len_set = 1; in s390x_aes_ccm_cipher()
2095 if (!cctx->aes.ccm.len_set && len) in s390x_aes_ccm_cipher()
2098 s390x_aes_ccm_aad(cctx, in, len); in s390x_aes_ccm_cipher()
2103 if (!enc && !cctx->aes.ccm.tag_set) in s390x_aes_ccm_cipher()
2108 if (!cctx->aes.ccm.len_set) { in s390x_aes_ccm_cipher()
2113 s390x_aes_ccm_setiv(cctx, ctx->iv, len); in s390x_aes_ccm_cipher()
2115 cctx->aes.ccm.len_set = 1; in s390x_aes_ccm_cipher()
2119 if (s390x_aes_ccm(cctx, in, out, len, enc)) in s390x_aes_ccm_cipher()
2122 cctx->aes.ccm.tag_set = 1; in s390x_aes_ccm_cipher()
2127 if (!s390x_aes_ccm(cctx, in, out, len, enc)) { in s390x_aes_ccm_cipher()
2129 if (!CRYPTO_memcmp(cctx->aes.ccm.kmac_param.icv.b, buf, in s390x_aes_ccm_cipher()
2130 cctx->aes.ccm.m)) in s390x_aes_ccm_cipher()
2137 cctx->aes.ccm.iv_set = 0; in s390x_aes_ccm_cipher()
2138 cctx->aes.ccm.tag_set = 0; in s390x_aes_ccm_cipher()
2139 cctx->aes.ccm.len_set = 0; in s390x_aes_ccm_cipher()
2151 S390X_AES_CCM_CTX *cctx = EVP_C_DATA(S390X_AES_CCM_CTX, c); in s390x_aes_ccm_ctrl() local
2157 cctx->aes.ccm.key_set = 0; in s390x_aes_ccm_ctrl()
2158 cctx->aes.ccm.iv_set = 0; in s390x_aes_ccm_ctrl()
2159 cctx->aes.ccm.l = 8; in s390x_aes_ccm_ctrl()
2160 cctx->aes.ccm.m = 12; in s390x_aes_ccm_ctrl()
2161 cctx->aes.ccm.tag_set = 0; in s390x_aes_ccm_ctrl()
2162 cctx->aes.ccm.len_set = 0; in s390x_aes_ccm_ctrl()
2163 cctx->aes.ccm.tls_aad_len = -1; in s390x_aes_ccm_ctrl()
2167 *(int *)ptr = 15 - cctx->aes.ccm.l; in s390x_aes_ccm_ctrl()
2177 cctx->aes.ccm.tls_aad_len = arg; in s390x_aes_ccm_ctrl()
2188 if (len < cctx->aes.ccm.m) in s390x_aes_ccm_ctrl()
2192 len -= cctx->aes.ccm.m; in s390x_aes_ccm_ctrl()
2199 return cctx->aes.ccm.m; in s390x_aes_ccm_ctrl()
2217 cctx->aes.ccm.l = arg; in s390x_aes_ccm_ctrl()
2229 cctx->aes.ccm.tag_set = 1; in s390x_aes_ccm_ctrl()
2234 cctx->aes.ccm.m = arg; in s390x_aes_ccm_ctrl()
2239 if (!enc || !cctx->aes.ccm.tag_set) in s390x_aes_ccm_ctrl()
2242 if (arg < cctx->aes.ccm.m) in s390x_aes_ccm_ctrl()
2245 memcpy(ptr, cctx->aes.ccm.kmac_param.icv.b, cctx->aes.ccm.m); in s390x_aes_ccm_ctrl()
2246 cctx->aes.ccm.tag_set = 0; in s390x_aes_ccm_ctrl()
2247 cctx->aes.ccm.iv_set = 0; in s390x_aes_ccm_ctrl()
2248 cctx->aes.ccm.len_set = 0; in s390x_aes_ccm_ctrl()
3379 EVP_AES_CCM_CTX *cctx = EVP_C_DATA(EVP_AES_CCM_CTX,c); in aes_ccm_ctrl() local
3382 cctx->key_set = 0; in aes_ccm_ctrl()
3383 cctx->iv_set = 0; in aes_ccm_ctrl()
3384 cctx->L = 8; in aes_ccm_ctrl()
3385 cctx->M = 12; in aes_ccm_ctrl()
3386 cctx->tag_set = 0; in aes_ccm_ctrl()
3387 cctx->len_set = 0; in aes_ccm_ctrl()
3388 cctx->tls_aad_len = -1; in aes_ccm_ctrl()
3392 *(int *)ptr = 15 - cctx->L; in aes_ccm_ctrl()
3400 cctx->tls_aad_len = arg; in aes_ccm_ctrl()
3411 if (len < cctx->M) in aes_ccm_ctrl()
3413 len -= cctx->M; in aes_ccm_ctrl()
3419 return cctx->M; in aes_ccm_ctrl()
3435 cctx->L = arg; in aes_ccm_ctrl()
3444 cctx->tag_set = 1; in aes_ccm_ctrl()
3447 cctx->M = arg; in aes_ccm_ctrl()
3451 if (!EVP_CIPHER_CTX_is_encrypting(c) || !cctx->tag_set) in aes_ccm_ctrl()
3453 if (!CRYPTO_ccm128_tag(&cctx->ccm, ptr, (size_t)arg)) in aes_ccm_ctrl()
3455 cctx->tag_set = 0; in aes_ccm_ctrl()
3456 cctx->iv_set = 0; in aes_ccm_ctrl()
3457 cctx->len_set = 0; in aes_ccm_ctrl()
3464 if (cctx->ccm.key) { in aes_ccm_ctrl()
3465 if (cctx->ccm.key != &cctx->ks) in aes_ccm_ctrl()
3481 EVP_AES_CCM_CTX *cctx = EVP_C_DATA(EVP_AES_CCM_CTX,ctx); in aes_ccm_init_key() local
3496 HWAES_set_encrypt_key(key, keylen, &cctx->ks.ks); in aes_ccm_init_key()
3498 CRYPTO_ccm128_init(&cctx->ccm, cctx->M, cctx->L, in aes_ccm_init_key()
3499 &cctx->ks, (block128_f) HWAES_encrypt); in aes_ccm_init_key()
3500 cctx->str = NULL; in aes_ccm_init_key()
3501 cctx->key_set = 1; in aes_ccm_init_key()
3507 vpaes_set_encrypt_key(key, keylen, &cctx->ks.ks); in aes_ccm_init_key()
3508 CRYPTO_ccm128_init(&cctx->ccm, cctx->M, cctx->L, in aes_ccm_init_key()
3509 &cctx->ks, (block128_f) vpaes_encrypt); in aes_ccm_init_key()
3510 cctx->str = NULL; in aes_ccm_init_key()
3511 cctx->key_set = 1; in aes_ccm_init_key()
3515 AES_set_encrypt_key(key, keylen, &cctx->ks.ks); in aes_ccm_init_key()
3516 CRYPTO_ccm128_init(&cctx->ccm, cctx->M, cctx->L, in aes_ccm_init_key()
3517 &cctx->ks, (block128_f) AES_encrypt); in aes_ccm_init_key()
3518 cctx->str = NULL; in aes_ccm_init_key()
3519 cctx->key_set = 1; in aes_ccm_init_key()
3523 memcpy(ctx->iv, iv, 15 - cctx->L); in aes_ccm_init_key()
3524 cctx->iv_set = 1; in aes_ccm_init_key()
3532 EVP_AES_CCM_CTX *cctx = EVP_C_DATA(EVP_AES_CCM_CTX,ctx); in aes_ccm_tls_cipher() local
3533 CCM128_CONTEXT *ccm = &cctx->ccm; in aes_ccm_tls_cipher()
3535 if (out != in || len < (EVP_CCM_TLS_EXPLICIT_IV_LEN + (size_t)cctx->M)) in aes_ccm_tls_cipher()
3545 len -= EVP_CCM_TLS_EXPLICIT_IV_LEN + cctx->M; in aes_ccm_tls_cipher()
3546 if (CRYPTO_ccm128_setiv(ccm, ctx->iv, 15 - cctx->L, in aes_ccm_tls_cipher()
3551 cctx->tls_aad_len); in aes_ccm_tls_cipher()
3556 if (cctx->str ? CRYPTO_ccm128_encrypt_ccm64(ccm, in, out, len, in aes_ccm_tls_cipher()
3557 cctx->str) : in aes_ccm_tls_cipher()
3560 if (!CRYPTO_ccm128_tag(ccm, out + len, cctx->M)) in aes_ccm_tls_cipher()
3562 return len + EVP_CCM_TLS_EXPLICIT_IV_LEN + cctx->M; in aes_ccm_tls_cipher()
3564 if (cctx->str ? !CRYPTO_ccm128_decrypt_ccm64(ccm, in, out, len, in aes_ccm_tls_cipher()
3565 cctx->str) : in aes_ccm_tls_cipher()
3568 if (CRYPTO_ccm128_tag(ccm, tag, cctx->M)) { in aes_ccm_tls_cipher()
3569 if (!CRYPTO_memcmp(tag, in + len, cctx->M)) in aes_ccm_tls_cipher()
3581 EVP_AES_CCM_CTX *cctx = EVP_C_DATA(EVP_AES_CCM_CTX,ctx); in aes_ccm_cipher() local
3582 CCM128_CONTEXT *ccm = &cctx->ccm; in aes_ccm_cipher()
3584 if (!cctx->key_set) in aes_ccm_cipher()
3587 if (cctx->tls_aad_len >= 0) in aes_ccm_cipher()
3594 if (!cctx->iv_set) in aes_ccm_cipher()
3600 15 - cctx->L, len)) in aes_ccm_cipher()
3602 cctx->len_set = 1; in aes_ccm_cipher()
3606 if (!cctx->len_set && len) in aes_ccm_cipher()
3613 if (!EVP_CIPHER_CTX_is_encrypting(ctx) && !cctx->tag_set) in aes_ccm_cipher()
3617 if (!cctx->len_set) { in aes_ccm_cipher()
3618 if (CRYPTO_ccm128_setiv(ccm, ctx->iv, 15 - cctx->L, len)) in aes_ccm_cipher()
3620 cctx->len_set = 1; in aes_ccm_cipher()
3623 if (cctx->str ? CRYPTO_ccm128_encrypt_ccm64(ccm, in, out, len, in aes_ccm_cipher()
3624 cctx->str) : in aes_ccm_cipher()
3627 cctx->tag_set = 1; in aes_ccm_cipher()
3631 if (cctx->str ? !CRYPTO_ccm128_decrypt_ccm64(ccm, in, out, len, in aes_ccm_cipher()
3632 cctx->str) : in aes_ccm_cipher()
3635 if (CRYPTO_ccm128_tag(ccm, tag, cctx->M)) { in aes_ccm_cipher()
3637 cctx->M)) in aes_ccm_cipher()
3643 cctx->iv_set = 0; in aes_ccm_cipher()
3644 cctx->tag_set = 0; in aes_ccm_cipher()
3645 cctx->len_set = 0; in aes_ccm_cipher()