diff options
Diffstat (limited to 'crypto/openssl/providers/implementations/ciphers/cipher_tdes_wrap.c')
| -rw-r--r-- | crypto/openssl/providers/implementations/ciphers/cipher_tdes_wrap.c | 92 |
1 files changed, 45 insertions, 47 deletions
diff --git a/crypto/openssl/providers/implementations/ciphers/cipher_tdes_wrap.c b/crypto/openssl/providers/implementations/ciphers/cipher_tdes_wrap.c index b48c02ae2581..8fc053d04594 100644 --- a/crypto/openssl/providers/implementations/ciphers/cipher_tdes_wrap.c +++ b/crypto/openssl/providers/implementations/ciphers/cipher_tdes_wrap.c @@ -32,7 +32,7 @@ static const unsigned char wrap_iv[8] = { }; static int des_ede3_unwrap(PROV_CIPHER_CTX *ctx, unsigned char *out, - const unsigned char *in, size_t inl) + const unsigned char *in, size_t inl) { unsigned char icv[8], iv[TDES_IVLEN], sha1tmp[SHA_DIGEST_LENGTH]; int rv = -1; @@ -65,7 +65,7 @@ static int des_ede3_unwrap(PROV_CIPHER_CTX *ctx, unsigned char *out, ctx->hw->cipher(ctx, out, out, inl - 16); ctx->hw->cipher(ctx, icv, icv, 8); if (ossl_sha1(out, inl - 16, sha1tmp) /* Work out hash of first portion */ - && CRYPTO_memcmp(sha1tmp, icv, 8) == 0) + && CRYPTO_memcmp(sha1tmp, icv, 8) == 0) rv = inl - 16; OPENSSL_cleanse(icv, 8); OPENSSL_cleanse(sha1tmp, SHA_DIGEST_LENGTH); @@ -78,7 +78,7 @@ static int des_ede3_unwrap(PROV_CIPHER_CTX *ctx, unsigned char *out, } static int des_ede3_wrap(PROV_CIPHER_CTX *ctx, unsigned char *out, - const unsigned char *in, size_t inl) + const unsigned char *in, size_t inl) { unsigned char sha1tmp[SHA_DIGEST_LENGTH]; size_t ivlen = TDES_IVLEN; @@ -108,7 +108,7 @@ static int des_ede3_wrap(PROV_CIPHER_CTX *ctx, unsigned char *out, } static int tdes_wrap_cipher_internal(PROV_CIPHER_CTX *ctx, unsigned char *out, - const unsigned char *in, size_t inl) + const unsigned char *in, size_t inl) { /* * Sanity check input length: we typically only wrap keys so EVP_MAXCHUNK @@ -124,8 +124,8 @@ static int tdes_wrap_cipher_internal(PROV_CIPHER_CTX *ctx, unsigned char *out, } static int tdes_wrap_cipher(void *vctx, - unsigned char *out, size_t *outl, size_t outsize, - const unsigned char *in, size_t inl) + unsigned char *out, size_t *outl, size_t outsize, + const unsigned char *in, size_t inl) { PROV_CIPHER_CTX *ctx = (PROV_CIPHER_CTX *)vctx; int ret; @@ -148,8 +148,8 @@ static int tdes_wrap_cipher(void *vctx, } static int tdes_wrap_update(void *vctx, unsigned char *out, size_t *outl, - size_t outsize, const unsigned char *in, - size_t inl) + size_t outsize, const unsigned char *in, + size_t inl) { *outl = 0; if (inl == 0) @@ -166,44 +166,42 @@ static int tdes_wrap_update(void *vctx, unsigned char *out, size_t *outl, return 1; } - -# define IMPLEMENT_WRAP_CIPHER(flags, kbits, blkbits, ivbits) \ -static OSSL_FUNC_cipher_newctx_fn tdes_wrap_newctx; \ -static void *tdes_wrap_newctx(void *provctx) \ -{ \ - return ossl_tdes_newctx(provctx, EVP_CIPH_WRAP_MODE, kbits, blkbits, \ - ivbits, flags, \ - ossl_prov_cipher_hw_tdes_wrap_cbc()); \ -} \ -static OSSL_FUNC_cipher_get_params_fn tdes_wrap_get_params; \ -static int tdes_wrap_get_params(OSSL_PARAM params[]) \ -{ \ - return ossl_cipher_generic_get_params(params, EVP_CIPH_WRAP_MODE, flags, \ - kbits, blkbits, ivbits); \ -} \ -const OSSL_DISPATCH ossl_tdes_wrap_cbc_functions[] = \ -{ \ - { OSSL_FUNC_CIPHER_ENCRYPT_INIT, (void (*)(void)) ossl_tdes_einit }, \ - { OSSL_FUNC_CIPHER_DECRYPT_INIT, (void (*)(void)) ossl_tdes_dinit }, \ - { OSSL_FUNC_CIPHER_CIPHER, (void (*)(void))tdes_wrap_cipher }, \ - { OSSL_FUNC_CIPHER_NEWCTX, (void (*)(void))tdes_wrap_newctx }, \ - { OSSL_FUNC_CIPHER_FREECTX, (void (*)(void))ossl_tdes_freectx }, \ - { OSSL_FUNC_CIPHER_UPDATE, (void (*)(void))tdes_wrap_update }, \ - { OSSL_FUNC_CIPHER_FINAL, \ - (void (*)(void))ossl_cipher_generic_stream_final }, \ - { OSSL_FUNC_CIPHER_GET_PARAMS, (void (*)(void))tdes_wrap_get_params }, \ - { OSSL_FUNC_CIPHER_GETTABLE_PARAMS, \ - (void (*)(void))ossl_cipher_generic_gettable_params }, \ - { OSSL_FUNC_CIPHER_GET_CTX_PARAMS, \ - (void (*)(void))ossl_tdes_get_ctx_params }, \ - { OSSL_FUNC_CIPHER_GETTABLE_CTX_PARAMS, \ - (void (*)(void))ossl_tdes_gettable_ctx_params }, \ - { OSSL_FUNC_CIPHER_SET_CTX_PARAMS, \ - (void (*)(void))ossl_cipher_generic_set_ctx_params }, \ - { OSSL_FUNC_CIPHER_SETTABLE_CTX_PARAMS, \ - (void (*)(void))ossl_cipher_generic_settable_ctx_params }, \ - OSSL_DISPATCH_END \ -} +#define IMPLEMENT_WRAP_CIPHER(flags, kbits, blkbits, ivbits) \ + static OSSL_FUNC_cipher_newctx_fn tdes_wrap_newctx; \ + static void *tdes_wrap_newctx(void *provctx) \ + { \ + return ossl_tdes_newctx(provctx, EVP_CIPH_WRAP_MODE, kbits, blkbits, \ + ivbits, flags, \ + ossl_prov_cipher_hw_tdes_wrap_cbc()); \ + } \ + static OSSL_FUNC_cipher_get_params_fn tdes_wrap_get_params; \ + static int tdes_wrap_get_params(OSSL_PARAM params[]) \ + { \ + return ossl_cipher_generic_get_params(params, EVP_CIPH_WRAP_MODE, flags, \ + kbits, blkbits, ivbits); \ + } \ + const OSSL_DISPATCH ossl_tdes_wrap_cbc_functions[] = { \ + { OSSL_FUNC_CIPHER_ENCRYPT_INIT, (void (*)(void))ossl_tdes_einit }, \ + { OSSL_FUNC_CIPHER_DECRYPT_INIT, (void (*)(void))ossl_tdes_dinit }, \ + { OSSL_FUNC_CIPHER_CIPHER, (void (*)(void))tdes_wrap_cipher }, \ + { OSSL_FUNC_CIPHER_NEWCTX, (void (*)(void))tdes_wrap_newctx }, \ + { OSSL_FUNC_CIPHER_FREECTX, (void (*)(void))ossl_tdes_freectx }, \ + { OSSL_FUNC_CIPHER_UPDATE, (void (*)(void))tdes_wrap_update }, \ + { OSSL_FUNC_CIPHER_FINAL, \ + (void (*)(void))ossl_cipher_generic_stream_final }, \ + { OSSL_FUNC_CIPHER_GET_PARAMS, (void (*)(void))tdes_wrap_get_params }, \ + { OSSL_FUNC_CIPHER_GETTABLE_PARAMS, \ + (void (*)(void))ossl_cipher_generic_gettable_params }, \ + { OSSL_FUNC_CIPHER_GET_CTX_PARAMS, \ + (void (*)(void))ossl_tdes_get_ctx_params }, \ + { OSSL_FUNC_CIPHER_GETTABLE_CTX_PARAMS, \ + (void (*)(void))ossl_tdes_gettable_ctx_params }, \ + { OSSL_FUNC_CIPHER_SET_CTX_PARAMS, \ + (void (*)(void))ossl_cipher_generic_set_ctx_params }, \ + { OSSL_FUNC_CIPHER_SETTABLE_CTX_PARAMS, \ + (void (*)(void))ossl_cipher_generic_settable_ctx_params }, \ + OSSL_DISPATCH_END \ + } /* ossl_tdes_wrap_cbc_functions */ -IMPLEMENT_WRAP_CIPHER(TDES_WRAP_FLAGS, 64*3, 64, 0); +IMPLEMENT_WRAP_CIPHER(TDES_WRAP_FLAGS, 64 * 3, 64, 0); |
