Lines Matching refs:cctx
317 EVP_AES_CCM_CTX *cctx = EVP_C_DATA(EVP_AES_CCM_CTX,ctx); in aesni_ccm_init_key() local
322 &cctx->ks.ks); in aesni_ccm_init_key()
323 CRYPTO_ccm128_init(&cctx->ccm, cctx->M, cctx->L, in aesni_ccm_init_key()
324 &cctx->ks, (block128_f) aesni_encrypt); in aesni_ccm_init_key()
325 cctx->str = enc ? (ccm128_f) aesni_ccm64_encrypt_blocks : in aesni_ccm_init_key()
327 cctx->key_set = 1; in aesni_ccm_init_key()
330 memcpy(ctx->iv, iv, 15 - cctx->L); in aesni_ccm_init_key()
331 cctx->iv_set = 1; in aesni_ccm_init_key()
672 EVP_AES_CCM_CTX *cctx = EVP_C_DATA(EVP_AES_CCM_CTX,ctx); in aes_t4_ccm_init_key() local
677 aes_t4_set_encrypt_key(key, bits, &cctx->ks.ks); in aes_t4_ccm_init_key()
678 CRYPTO_ccm128_init(&cctx->ccm, cctx->M, cctx->L, in aes_t4_ccm_init_key()
679 &cctx->ks, (block128_f) aes_t4_encrypt); in aes_t4_ccm_init_key()
680 cctx->str = NULL; in aes_t4_ccm_init_key()
681 cctx->key_set = 1; in aes_t4_ccm_init_key()
684 memcpy(ctx->iv, iv, 15 - cctx->L); in aes_t4_ccm_init_key()
685 cctx->iv_set = 1; in aes_t4_ccm_init_key()
973 S390X_AES_ECB_CTX *cctx = EVP_C_DATA(S390X_AES_ECB_CTX, ctx); in s390x_aes_ecb_init_key() local
976 cctx->fc = S390X_AES_FC(keylen); in s390x_aes_ecb_init_key()
978 cctx->fc |= S390X_DECRYPT; in s390x_aes_ecb_init_key()
980 memcpy(cctx->km.param.k, key, keylen); in s390x_aes_ecb_init_key()
987 S390X_AES_ECB_CTX *cctx = EVP_C_DATA(S390X_AES_ECB_CTX, ctx); in s390x_aes_ecb_cipher() local
989 s390x_km(in, len, out, cctx->fc, &cctx->km.param); in s390x_aes_ecb_cipher()
997 S390X_AES_OFB_CTX *cctx = EVP_C_DATA(S390X_AES_OFB_CTX, ctx); in s390x_aes_ofb_init_key() local
1002 memcpy(cctx->kmo.param.cv, iv, ivlen); in s390x_aes_ofb_init_key()
1003 memcpy(cctx->kmo.param.k, key, keylen); in s390x_aes_ofb_init_key()
1004 cctx->fc = S390X_AES_FC(keylen); in s390x_aes_ofb_init_key()
1005 cctx->res = 0; in s390x_aes_ofb_init_key()
1012 S390X_AES_OFB_CTX *cctx = EVP_C_DATA(S390X_AES_OFB_CTX, ctx); in s390x_aes_ofb_cipher() local
1015 int n = cctx->res; in s390x_aes_ofb_cipher()
1018 memcpy(cctx->kmo.param.cv, iv, ivlen); in s390x_aes_ofb_cipher()
1020 *out = *in ^ cctx->kmo.param.cv[n]; in s390x_aes_ofb_cipher()
1031 s390x_kmo(in, len, out, cctx->fc, &cctx->kmo.param); in s390x_aes_ofb_cipher()
1038 s390x_km(cctx->kmo.param.cv, 16, cctx->kmo.param.cv, cctx->fc, in s390x_aes_ofb_cipher()
1039 cctx->kmo.param.k); in s390x_aes_ofb_cipher()
1042 out[n] = in[n] ^ cctx->kmo.param.cv[n]; in s390x_aes_ofb_cipher()
1047 memcpy(iv, cctx->kmo.param.cv, ivlen); in s390x_aes_ofb_cipher()
1048 cctx->res = n; in s390x_aes_ofb_cipher()
1056 S390X_AES_CFB_CTX *cctx = EVP_C_DATA(S390X_AES_CFB_CTX, ctx); in s390x_aes_cfb_init_key() local
1061 cctx->fc = S390X_AES_FC(keylen); in s390x_aes_cfb_init_key()
1062 cctx->fc |= 16 << 24; /* 16 bytes cipher feedback */ in s390x_aes_cfb_init_key()
1064 cctx->fc |= S390X_DECRYPT; in s390x_aes_cfb_init_key()
1066 cctx->res = 0; in s390x_aes_cfb_init_key()
1067 memcpy(cctx->kmf.param.cv, iv, ivlen); in s390x_aes_cfb_init_key()
1068 memcpy(cctx->kmf.param.k, key, keylen); in s390x_aes_cfb_init_key()
1075 S390X_AES_CFB_CTX *cctx = EVP_C_DATA(S390X_AES_CFB_CTX, ctx); in s390x_aes_cfb_cipher() local
1080 int n = cctx->res; in s390x_aes_cfb_cipher()
1084 memcpy(cctx->kmf.param.cv, iv, ivlen); in s390x_aes_cfb_cipher()
1087 *out = cctx->kmf.param.cv[n] ^ tmp; in s390x_aes_cfb_cipher()
1088 cctx->kmf.param.cv[n] = enc ? *out : tmp; in s390x_aes_cfb_cipher()
1099 s390x_kmf(in, len, out, cctx->fc, &cctx->kmf.param); in s390x_aes_cfb_cipher()
1106 s390x_km(cctx->kmf.param.cv, 16, cctx->kmf.param.cv, in s390x_aes_cfb_cipher()
1107 S390X_AES_FC(keylen), cctx->kmf.param.k); in s390x_aes_cfb_cipher()
1111 out[n] = cctx->kmf.param.cv[n] ^ tmp; in s390x_aes_cfb_cipher()
1112 cctx->kmf.param.cv[n] = enc ? out[n] : tmp; in s390x_aes_cfb_cipher()
1117 memcpy(iv, cctx->kmf.param.cv, ivlen); in s390x_aes_cfb_cipher()
1118 cctx->res = n; in s390x_aes_cfb_cipher()
1126 S390X_AES_CFB_CTX *cctx = EVP_C_DATA(S390X_AES_CFB_CTX, ctx); in s390x_aes_cfb8_init_key() local
1131 cctx->fc = S390X_AES_FC(keylen); in s390x_aes_cfb8_init_key()
1132 cctx->fc |= 1 << 24; /* 1 byte cipher feedback */ in s390x_aes_cfb8_init_key()
1134 cctx->fc |= S390X_DECRYPT; in s390x_aes_cfb8_init_key()
1136 memcpy(cctx->kmf.param.cv, iv, ivlen); in s390x_aes_cfb8_init_key()
1137 memcpy(cctx->kmf.param.k, key, keylen); in s390x_aes_cfb8_init_key()
1144 S390X_AES_CFB_CTX *cctx = EVP_C_DATA(S390X_AES_CFB_CTX, ctx); in s390x_aes_cfb8_cipher() local
1148 memcpy(cctx->kmf.param.cv, iv, ivlen); in s390x_aes_cfb8_cipher()
1149 s390x_kmf(in, len, out, cctx->fc, &cctx->kmf.param); in s390x_aes_cfb8_cipher()
1150 memcpy(iv, cctx->kmf.param.cv, ivlen); in s390x_aes_cfb8_cipher()
1880 S390X_AES_CCM_CTX *cctx = EVP_C_DATA(S390X_AES_CCM_CTX, ctx); in s390x_aes_ccm_tls_cipher() local
1886 || len < (EVP_CCM_TLS_EXPLICIT_IV_LEN + (size_t)cctx->aes.ccm.m)) in s390x_aes_ccm_tls_cipher()
1894 len -= EVP_CCM_TLS_EXPLICIT_IV_LEN + cctx->aes.ccm.m; in s390x_aes_ccm_tls_cipher()
1900 s390x_aes_ccm_setiv(cctx, ivec, len); in s390x_aes_ccm_tls_cipher()
1903 s390x_aes_ccm_aad(cctx, buf, cctx->aes.ccm.tls_aad_len); in s390x_aes_ccm_tls_cipher()
1909 if (s390x_aes_ccm(cctx, in, out, len, enc)) in s390x_aes_ccm_tls_cipher()
1912 memcpy(out + len, cctx->aes.ccm.kmac_param.icv.b, cctx->aes.ccm.m); in s390x_aes_ccm_tls_cipher()
1913 return len + EVP_CCM_TLS_EXPLICIT_IV_LEN + cctx->aes.ccm.m; in s390x_aes_ccm_tls_cipher()
1915 if (!s390x_aes_ccm(cctx, in, out, len, enc)) { in s390x_aes_ccm_tls_cipher()
1916 if (!CRYPTO_memcmp(cctx->aes.ccm.kmac_param.icv.b, in + len, in s390x_aes_ccm_tls_cipher()
1917 cctx->aes.ccm.m)) in s390x_aes_ccm_tls_cipher()
1934 S390X_AES_CCM_CTX *cctx = EVP_C_DATA(S390X_AES_CCM_CTX, ctx); in s390x_aes_ccm_init_key() local
1942 cctx->aes.ccm.fc = S390X_AES_FC(keylen); in s390x_aes_ccm_init_key()
1943 memcpy(cctx->aes.ccm.kmac_param.k, key, keylen); in s390x_aes_ccm_init_key()
1946 cctx->aes.ccm.nonce.b[0] = ((cctx->aes.ccm.l - 1) & 0x7) in s390x_aes_ccm_init_key()
1947 | (((cctx->aes.ccm.m - 2) >> 1) & 0x7) << 3; in s390x_aes_ccm_init_key()
1948 memset(cctx->aes.ccm.nonce.b + 1, 0, in s390x_aes_ccm_init_key()
1949 sizeof(cctx->aes.ccm.nonce.b)); in s390x_aes_ccm_init_key()
1950 cctx->aes.ccm.blocks = 0; in s390x_aes_ccm_init_key()
1952 cctx->aes.ccm.key_set = 1; in s390x_aes_ccm_init_key()
1956 memcpy(ctx->iv, iv, 15 - cctx->aes.ccm.l); in s390x_aes_ccm_init_key()
1958 cctx->aes.ccm.iv_set = 1; in s390x_aes_ccm_init_key()
1973 S390X_AES_CCM_CTX *cctx = EVP_C_DATA(S390X_AES_CCM_CTX, ctx); in s390x_aes_ccm_cipher() local
1978 if (!cctx->aes.ccm.key_set) in s390x_aes_ccm_cipher()
1981 if (cctx->aes.ccm.tls_aad_len >= 0) in s390x_aes_ccm_cipher()
1992 if (!cctx->aes.ccm.iv_set) in s390x_aes_ccm_cipher()
1998 s390x_aes_ccm_setiv(cctx, ctx->iv, len); in s390x_aes_ccm_cipher()
2000 cctx->aes.ccm.len_set = 1; in s390x_aes_ccm_cipher()
2005 if (!cctx->aes.ccm.len_set && len) in s390x_aes_ccm_cipher()
2008 s390x_aes_ccm_aad(cctx, in, len); in s390x_aes_ccm_cipher()
2013 if (!enc && !cctx->aes.ccm.tag_set) in s390x_aes_ccm_cipher()
2018 if (!cctx->aes.ccm.len_set) { in s390x_aes_ccm_cipher()
2023 s390x_aes_ccm_setiv(cctx, ctx->iv, len); in s390x_aes_ccm_cipher()
2025 cctx->aes.ccm.len_set = 1; in s390x_aes_ccm_cipher()
2029 if (s390x_aes_ccm(cctx, in, out, len, enc)) in s390x_aes_ccm_cipher()
2032 cctx->aes.ccm.tag_set = 1; in s390x_aes_ccm_cipher()
2037 if (!s390x_aes_ccm(cctx, in, out, len, enc)) { in s390x_aes_ccm_cipher()
2039 if (!CRYPTO_memcmp(cctx->aes.ccm.kmac_param.icv.b, buf, in s390x_aes_ccm_cipher()
2040 cctx->aes.ccm.m)) in s390x_aes_ccm_cipher()
2047 cctx->aes.ccm.iv_set = 0; in s390x_aes_ccm_cipher()
2048 cctx->aes.ccm.tag_set = 0; in s390x_aes_ccm_cipher()
2049 cctx->aes.ccm.len_set = 0; in s390x_aes_ccm_cipher()
2061 S390X_AES_CCM_CTX *cctx = EVP_C_DATA(S390X_AES_CCM_CTX, c); in s390x_aes_ccm_ctrl() local
2067 cctx->aes.ccm.key_set = 0; in s390x_aes_ccm_ctrl()
2068 cctx->aes.ccm.iv_set = 0; in s390x_aes_ccm_ctrl()
2069 cctx->aes.ccm.l = 8; in s390x_aes_ccm_ctrl()
2070 cctx->aes.ccm.m = 12; in s390x_aes_ccm_ctrl()
2071 cctx->aes.ccm.tag_set = 0; in s390x_aes_ccm_ctrl()
2072 cctx->aes.ccm.len_set = 0; in s390x_aes_ccm_ctrl()
2073 cctx->aes.ccm.tls_aad_len = -1; in s390x_aes_ccm_ctrl()
2077 *(int *)ptr = 15 - cctx->aes.ccm.l; in s390x_aes_ccm_ctrl()
2087 cctx->aes.ccm.tls_aad_len = arg; in s390x_aes_ccm_ctrl()
2098 if (len < cctx->aes.ccm.m) in s390x_aes_ccm_ctrl()
2102 len -= cctx->aes.ccm.m; in s390x_aes_ccm_ctrl()
2109 return cctx->aes.ccm.m; in s390x_aes_ccm_ctrl()
2127 cctx->aes.ccm.l = arg; in s390x_aes_ccm_ctrl()
2139 cctx->aes.ccm.tag_set = 1; in s390x_aes_ccm_ctrl()
2144 cctx->aes.ccm.m = arg; in s390x_aes_ccm_ctrl()
2149 if (!enc || !cctx->aes.ccm.tag_set) in s390x_aes_ccm_ctrl()
2152 if(arg < cctx->aes.ccm.m) in s390x_aes_ccm_ctrl()
2155 memcpy(ptr, cctx->aes.ccm.kmac_param.icv.b, cctx->aes.ccm.m); in s390x_aes_ccm_ctrl()
2156 cctx->aes.ccm.tag_set = 0; in s390x_aes_ccm_ctrl()
2157 cctx->aes.ccm.iv_set = 0; in s390x_aes_ccm_ctrl()
2158 cctx->aes.ccm.len_set = 0; in s390x_aes_ccm_ctrl()
3282 EVP_AES_CCM_CTX *cctx = EVP_C_DATA(EVP_AES_CCM_CTX,c); in aes_ccm_ctrl() local
3285 cctx->key_set = 0; in aes_ccm_ctrl()
3286 cctx->iv_set = 0; in aes_ccm_ctrl()
3287 cctx->L = 8; in aes_ccm_ctrl()
3288 cctx->M = 12; in aes_ccm_ctrl()
3289 cctx->tag_set = 0; in aes_ccm_ctrl()
3290 cctx->len_set = 0; in aes_ccm_ctrl()
3291 cctx->tls_aad_len = -1; in aes_ccm_ctrl()
3295 *(int *)ptr = 15 - cctx->L; in aes_ccm_ctrl()
3303 cctx->tls_aad_len = arg; in aes_ccm_ctrl()
3314 if (len < cctx->M) in aes_ccm_ctrl()
3316 len -= cctx->M; in aes_ccm_ctrl()
3322 return cctx->M; in aes_ccm_ctrl()
3338 cctx->L = arg; in aes_ccm_ctrl()
3347 cctx->tag_set = 1; in aes_ccm_ctrl()
3350 cctx->M = arg; in aes_ccm_ctrl()
3354 if (!EVP_CIPHER_CTX_is_encrypting(c) || !cctx->tag_set) in aes_ccm_ctrl()
3356 if (!CRYPTO_ccm128_tag(&cctx->ccm, ptr, (size_t)arg)) in aes_ccm_ctrl()
3358 cctx->tag_set = 0; in aes_ccm_ctrl()
3359 cctx->iv_set = 0; in aes_ccm_ctrl()
3360 cctx->len_set = 0; in aes_ccm_ctrl()
3367 if (cctx->ccm.key) { in aes_ccm_ctrl()
3368 if (cctx->ccm.key != &cctx->ks) in aes_ccm_ctrl()
3384 EVP_AES_CCM_CTX *cctx = EVP_C_DATA(EVP_AES_CCM_CTX,ctx); in aes_ccm_init_key() local
3393 &cctx->ks.ks); in aes_ccm_init_key()
3395 CRYPTO_ccm128_init(&cctx->ccm, cctx->M, cctx->L, in aes_ccm_init_key()
3396 &cctx->ks, (block128_f) HWAES_encrypt); in aes_ccm_init_key()
3397 cctx->str = NULL; in aes_ccm_init_key()
3398 cctx->key_set = 1; in aes_ccm_init_key()
3406 &cctx->ks.ks); in aes_ccm_init_key()
3407 CRYPTO_ccm128_init(&cctx->ccm, cctx->M, cctx->L, in aes_ccm_init_key()
3408 &cctx->ks, (block128_f) vpaes_encrypt); in aes_ccm_init_key()
3409 cctx->str = NULL; in aes_ccm_init_key()
3410 cctx->key_set = 1; in aes_ccm_init_key()
3415 &cctx->ks.ks); in aes_ccm_init_key()
3416 CRYPTO_ccm128_init(&cctx->ccm, cctx->M, cctx->L, in aes_ccm_init_key()
3417 &cctx->ks, (block128_f) AES_encrypt); in aes_ccm_init_key()
3418 cctx->str = NULL; in aes_ccm_init_key()
3419 cctx->key_set = 1; in aes_ccm_init_key()
3422 memcpy(ctx->iv, iv, 15 - cctx->L); in aes_ccm_init_key()
3423 cctx->iv_set = 1; in aes_ccm_init_key()
3431 EVP_AES_CCM_CTX *cctx = EVP_C_DATA(EVP_AES_CCM_CTX,ctx); in aes_ccm_tls_cipher() local
3432 CCM128_CONTEXT *ccm = &cctx->ccm; in aes_ccm_tls_cipher()
3434 if (out != in || len < (EVP_CCM_TLS_EXPLICIT_IV_LEN + (size_t)cctx->M)) in aes_ccm_tls_cipher()
3444 len -= EVP_CCM_TLS_EXPLICIT_IV_LEN + cctx->M; in aes_ccm_tls_cipher()
3445 if (CRYPTO_ccm128_setiv(ccm, ctx->iv, 15 - cctx->L, in aes_ccm_tls_cipher()
3450 cctx->tls_aad_len); in aes_ccm_tls_cipher()
3455 if (cctx->str ? CRYPTO_ccm128_encrypt_ccm64(ccm, in, out, len, in aes_ccm_tls_cipher()
3456 cctx->str) : in aes_ccm_tls_cipher()
3459 if (!CRYPTO_ccm128_tag(ccm, out + len, cctx->M)) in aes_ccm_tls_cipher()
3461 return len + EVP_CCM_TLS_EXPLICIT_IV_LEN + cctx->M; in aes_ccm_tls_cipher()
3463 if (cctx->str ? !CRYPTO_ccm128_decrypt_ccm64(ccm, in, out, len, in aes_ccm_tls_cipher()
3464 cctx->str) : in aes_ccm_tls_cipher()
3467 if (CRYPTO_ccm128_tag(ccm, tag, cctx->M)) { in aes_ccm_tls_cipher()
3468 if (!CRYPTO_memcmp(tag, in + len, cctx->M)) in aes_ccm_tls_cipher()
3480 EVP_AES_CCM_CTX *cctx = EVP_C_DATA(EVP_AES_CCM_CTX,ctx); in aes_ccm_cipher() local
3481 CCM128_CONTEXT *ccm = &cctx->ccm; in aes_ccm_cipher()
3483 if (!cctx->key_set) in aes_ccm_cipher()
3486 if (cctx->tls_aad_len >= 0) in aes_ccm_cipher()
3493 if (!cctx->iv_set) in aes_ccm_cipher()
3499 15 - cctx->L, len)) in aes_ccm_cipher()
3501 cctx->len_set = 1; in aes_ccm_cipher()
3505 if (!cctx->len_set && len) in aes_ccm_cipher()
3512 if (!EVP_CIPHER_CTX_is_encrypting(ctx) && !cctx->tag_set) in aes_ccm_cipher()
3516 if (!cctx->len_set) { in aes_ccm_cipher()
3517 if (CRYPTO_ccm128_setiv(ccm, ctx->iv, 15 - cctx->L, len)) in aes_ccm_cipher()
3519 cctx->len_set = 1; in aes_ccm_cipher()
3522 if (cctx->str ? CRYPTO_ccm128_encrypt_ccm64(ccm, in, out, len, in aes_ccm_cipher()
3523 cctx->str) : in aes_ccm_cipher()
3526 cctx->tag_set = 1; in aes_ccm_cipher()
3530 if (cctx->str ? !CRYPTO_ccm128_decrypt_ccm64(ccm, in, out, len, in aes_ccm_cipher()
3531 cctx->str) : in aes_ccm_cipher()
3534 if (CRYPTO_ccm128_tag(ccm, tag, cctx->M)) { in aes_ccm_cipher()
3536 cctx->M)) in aes_ccm_cipher()
3542 cctx->iv_set = 0; in aes_ccm_cipher()
3543 cctx->tag_set = 0; in aes_ccm_cipher()
3544 cctx->len_set = 0; in aes_ccm_cipher()