Lines Matching +full:inline +full:- +full:crypto +full:- +full:engine

2  * Copyright 2004-2023 The OpenSSL Project Authors. All Rights Reserved.
11 * This file uses the low level AES and engine functions (which are deprecated
12 * for non-internal use) in order to implement the padlock engine AES ciphers.
20 #include <openssl/crypto.h>
21 #include <openssl/engine.h>
39 static ENGINE *ENGINE_padlock(void);
47 /* On non-x86 CPUs it just returns. */ in engine_load_padlock_int()
49 ENGINE *toadd = ENGINE_padlock(); in engine_load_padlock_int()
56 * release our just-created reference. in engine_load_padlock_int()
72 /* Function for ENGINE detection and control */
74 static int padlock_init(ENGINE *e);
80 static int padlock_ciphers(ENGINE *e, const EVP_CIPHER **cipher,
83 /* Engine names */
88 static int padlock_use_ace = 0; /* Advanced Cryptography Engine */
91 /* ===== Engine "management" functions ===== */
93 /* Prepare the ENGINE structure for registration */
94 static int padlock_bind_helper(ENGINE *e) in padlock_bind_helper()
105 /* Generate a nice engine name with available features */ in padlock_bind_helper()
108 padlock_use_rng ? "RNG" : "no-RNG", in padlock_bind_helper()
109 padlock_use_ace ? "ACE" : "no-ACE"); in padlock_bind_helper()
126 static ENGINE *ENGINE_padlock(void) in ENGINE_padlock()
128 ENGINE *eng = ENGINE_new(); in ENGINE_padlock()
143 /* Check availability of the engine */
144 static int padlock_init(ENGINE *e) in padlock_init()
159 # include "../crypto/aes/aes_core.c"
163 * This stuff is needed if this ENGINE is being compiled into a
164 * self-contained shared-library.
167 static int padlock_bind_fn(ENGINE *e, const char *id) in padlock_bind_fn()
183 /* ===== Here comes the "real" engine ===== */
185 /* Some AES-related constants */
194 * BIG FAT WARNING: Inline assembler in PADLOCK_XCRYPT_ASM() depends on
308 ( (0x10 - ((size_t)(ptr) & 0x0F)) & 0x0F ) )
327 memcpy(cdata->iv, EVP_CIPHER_CTX_iv(ctx), AES_BLOCK_SIZE); in padlock_cbc_cipher()
329 memcpy(EVP_CIPHER_CTX_iv_noconst(ctx), cdata->iv, AES_BLOCK_SIZE); in padlock_cbc_cipher()
349 chunk++, nbytes--; in padlock_cfb_cipher()
354 ivp[chunk++] = c, nbytes--; in padlock_cfb_cipher()
363 memcpy(cdata->iv, EVP_CIPHER_CTX_iv(ctx), AES_BLOCK_SIZE); in padlock_cfb_cipher()
365 if ((chunk = nbytes & ~(AES_BLOCK_SIZE - 1))) { in padlock_cfb_cipher()
368 nbytes -= chunk; in padlock_cfb_cipher()
372 unsigned char *ivp = cdata->iv; in padlock_cfb_cipher()
377 if (cdata->cword.b.encdec) { in padlock_cfb_cipher()
378 cdata->cword.b.encdec = 0; in padlock_cfb_cipher()
381 cdata->cword.b.encdec = 1; in padlock_cfb_cipher()
386 *(ivp++) = c, nbytes--; in padlock_cfb_cipher()
394 ivp++, nbytes--; in padlock_cfb_cipher()
399 memcpy(EVP_CIPHER_CTX_iv_noconst(ctx), cdata->iv, AES_BLOCK_SIZE); in padlock_cfb_cipher()
412 * ctx->num is maintained in byte-oriented modes, such as CFB and OFB... in padlock_ofb_cipher()
422 chunk++, nbytes--; in padlock_ofb_cipher()
431 memcpy(cdata->iv, EVP_CIPHER_CTX_iv(ctx), AES_BLOCK_SIZE); in padlock_ofb_cipher()
433 if ((chunk = nbytes & ~(AES_BLOCK_SIZE - 1))) { in padlock_ofb_cipher()
436 nbytes -= chunk; in padlock_ofb_cipher()
440 unsigned char *ivp = cdata->iv; in padlock_ofb_cipher()
450 ivp++, nbytes--; in padlock_ofb_cipher()
454 memcpy(EVP_CIPHER_CTX_iv_noconst(ctx), cdata->iv, AES_BLOCK_SIZE); in padlock_ofb_cipher()
464 memcpy(ctx->iv, ivec, AES_BLOCK_SIZE); in padlock_ctr32_encrypt_glue()
497 * of preprocessor magic :-)
547 padlock_ciphers(ENGINE *e, const EVP_CIPHER **cipher, const int **nids, in padlock_ciphers()
632 cdata->cword.b.encdec = 0; in padlock_aes_init_key()
634 cdata->cword.b.encdec = (EVP_CIPHER_CTX_is_encrypting(ctx) == 0); in padlock_aes_init_key()
635 cdata->cword.b.rounds = 10 + (key_len - 128) / 32; in padlock_aes_init_key()
636 cdata->cword.b.ksize = (key_len - 128) / 64; in padlock_aes_init_key()
643 memcpy(cdata->ks.rd_key, key, AES_KEY_SIZE_128); in padlock_aes_init_key()
644 cdata->cword.b.keygen = 0; in padlock_aes_init_key()
659 AES_set_decrypt_key(key, key_len, &cdata->ks); in padlock_aes_init_key()
661 AES_set_encrypt_key(key, key_len, &cdata->ks); in padlock_aes_init_key()
663 * OpenSSL C functions use byte-swapped extended key. in padlock_aes_init_key()
665 padlock_key_bswap(&cdata->ks); in padlock_aes_init_key()
666 cdata->cword.b.keygen = 1; in padlock_aes_init_key()
703 /* this ---vv--- covers DC bias, Raw Bits and String Filter */ in padlock_rand_bytes()
711 count -= 8; in padlock_rand_bytes()
717 /* this ---vv--- covers DC bias, Raw Bits and String Filter */ in padlock_rand_bytes()
725 count--; in padlock_rand_bytes()
754 int bind_engine(ENGINE *e, const char *id, const dynamic_fns *fns);
756 int bind_engine(ENGINE *e, const char *id, const dynamic_fns *fns) in bind_engine()