Lines Matching refs:cipher

77  *	blkcipher	Run all block cipher tests
99 * <block cipher>+<hmac>
129 int cipher;
143 { .name = "aes-cbc", .cipher = CRYPTO_AES_CBC, .type = T_BLKCIPHER,
145 { .name = "aes-cbc192", .cipher = CRYPTO_AES_CBC, .type = T_BLKCIPHER,
147 { .name = "aes-cbc256", .cipher = CRYPTO_AES_CBC, .type = T_BLKCIPHER,
149 { .name = "aes-ctr", .cipher = CRYPTO_AES_ICM, .type = T_BLKCIPHER,
151 { .name = "aes-ctr192", .cipher = CRYPTO_AES_ICM, .type = T_BLKCIPHER,
153 { .name = "aes-ctr256", .cipher = CRYPTO_AES_ICM, .type = T_BLKCIPHER,
155 { .name = "aes-xts", .cipher = CRYPTO_AES_XTS, .type = T_BLKCIPHER,
157 { .name = "aes-xts256", .cipher = CRYPTO_AES_XTS, .type = T_BLKCIPHER,
159 { .name = "aes-gcm", .cipher = CRYPTO_AES_NIST_GCM_16,
162 { .name = "aes-gcm192", .cipher = CRYPTO_AES_NIST_GCM_16,
165 { .name = "aes-gcm256", .cipher = CRYPTO_AES_NIST_GCM_16,
194 build_authenc(struct alg *cipher, struct alg *hmac)
199 assert(cipher->type == T_BLKCIPHER);
202 asprintf(&name, "%s+%s", cipher->name, hmac->name);
204 authenc.cipher = cipher->cipher;
207 authenc.evp_cipher = cipher->evp_cipher;
215 struct alg *cipher, *hmac;
222 cipher = find_alg(cipher_name);
224 if (cipher == NULL)
225 errx(1, "Invalid cipher %s", cipher_name);
229 return (build_authenc(cipher, hmac));
317 switch (alg->cipher) {
440 openssl_cipher(struct alg *alg, const EVP_CIPHER *cipher, const char *key,
450 if (EVP_CipherInit_ex(ctx, cipher, NULL, (const u_char *)key,
457 errx(1, "OpenSSL %s (%zu) cipher update failed: %s", alg->name,
461 errx(1, "OpenSSL %s (%zu) cipher final failed: %s", alg->name,
465 errx(1, "OpenSSL %s (%zu) cipher size mismatch: %d", alg->name,
484 sop.cipher = alg->cipher;
487 warn("cryptodev %s block cipher not supported for device %s",
502 warn("cryptodev %s (%zu) block cipher failed for device %s",
519 const EVP_CIPHER *cipher;
525 cipher = alg->evp_cipher();
526 if (size % EVP_CIPHER_block_size(cipher) != 0) {
530 alg->name, size, EVP_CIPHER_block_size(cipher));
534 key_len = EVP_CIPHER_key_length(cipher);
535 iv_len = EVP_CIPHER_iv_length(cipher);
543 /* OpenSSL cipher. */
544 openssl_cipher(alg, cipher, key, iv, cleartext, ciphertext, size, 1);
546 errx(1, "OpenSSL %s (%zu): cipher text unchanged", alg->name,
548 openssl_cipher(alg, cipher, key, iv, ciphertext, buffer, size, 0);
550 printf("OpenSSL %s (%zu): cipher mismatch:", alg->name, size);
609 sop.cipher = alg->cipher;
675 const EVP_CIPHER *cipher;
683 cipher = alg->evp_cipher();
684 if (size % EVP_CIPHER_block_size(cipher) != 0) {
688 alg->name, size, EVP_CIPHER_block_size(cipher));
697 cipher_key_len = EVP_CIPHER_key_length(cipher);
698 iv_len = EVP_CIPHER_iv_length(cipher);
711 openssl_cipher(alg, cipher, cipher_key, iv, cleartext + aad_len,
715 errx(1, "OpenSSL %s (%zu): cipher text unchanged", alg->name,
793 openssl_gcm_encrypt(struct alg *alg, const EVP_CIPHER *cipher, const char *key,
804 if (EVP_EncryptInit_ex(ctx, cipher, NULL, (const u_char *)key,
849 sop.cipher = alg->cipher;
889 openssl_gcm_decrypt(struct alg *alg, const EVP_CIPHER *cipher, const char *key,
901 if (EVP_DecryptInit_ex(ctx, cipher, NULL, (const u_char *)key,
935 const EVP_CIPHER *cipher;
942 cipher = alg->evp_cipher();
943 if (size % EVP_CIPHER_block_size(cipher) != 0) {
947 alg->name, size, EVP_CIPHER_block_size(cipher));
954 key_len = EVP_CIPHER_key_length(cipher);
955 iv_len = EVP_CIPHER_iv_length(cipher);
968 openssl_gcm_encrypt(alg, cipher, key, iv, aad, aad_len, cleartext,
1070 struct alg *authenc, *cipher, *hmac;
1074 cipher = &algs[i];
1075 if (cipher->type != T_BLKCIPHER)
1081 authenc = build_authenc(cipher, hmac);