Initialize cipher context in KRB5
authorDr. Stephen Henson <steve@openssl.org>
Thu, 14 Mar 2002 18:16:49 +0000 (18:16 +0000)
committerDr. Stephen Henson <steve@openssl.org>
Thu, 14 Mar 2002 18:16:49 +0000 (18:16 +0000)
("D. Russell" <russelld@aol.net>)

Allow HMAC functions to use an alternative ENGINE.

apps/speed.c
crypto/evp/p5_crpt2.c
crypto/hmac/hmac.c
crypto/hmac/hmac.h
crypto/pkcs12/p12_mutl.c
ssl/s3_clnt.c
ssl/s3_srvr.c
ssl/t1_enc.c

index e817a0df152fe25e44c07aee241c353ee3acd3a4..95979e509f37658a17cfd3adbad3732aa3d8df39 100644 (file)
@@ -1138,7 +1138,7 @@ int MAIN(int argc, char **argv)
 
                HMAC_CTX_init(&hctx);
                HMAC_Init_ex(&hctx,(unsigned char *)"This is a key...",
-                       16,EVP_md5());
+                       16,EVP_md5(), NULL);
 
                for (j=0; j<SIZE_NUM; j++)
                        {
@@ -1146,9 +1146,9 @@ int MAIN(int argc, char **argv)
                        Time_F(START);
                        for (count=0,run=1; COND(c[D_HMAC][j]); count++)
                                {
-                               HMAC_Init_ex(&hctx,NULL,0,NULL);
-                                HMAC_Update(&hctx,buf,lengths[j]);
-                                HMAC_Final(&hctx,&(hmac[0]),NULL);
+                               HMAC_Init_ex(&hctx,NULL,0,NULL,NULL);
+                               HMAC_Update(&hctx,buf,lengths[j]);
+                               HMAC_Final(&hctx,&(hmac[0]),NULL);
                                }
                        d=Time_F(STOP);
                        print_result(D_HMAC,j,count,d);
index 14cad73cde1bd863cf23df88aeeb4e21e3a1b07e..7881860b53eee7690d4c1ccab331eb053682bc1d 100644 (file)
@@ -100,7 +100,7 @@ int PKCS5_PBKDF2_HMAC_SHA1(const char *pass, int passlen,
                itmp[1] = (unsigned char)((i >> 16) & 0xff);
                itmp[2] = (unsigned char)((i >> 8) & 0xff);
                itmp[3] = (unsigned char)(i & 0xff);
-               HMAC_Init_ex(&hctx, pass, passlen, EVP_sha1());
+               HMAC_Init_ex(&hctx, pass, passlen, EVP_sha1(), NULL);
                HMAC_Update(&hctx, salt, saltlen);
                HMAC_Update(&hctx, itmp, 4);
                HMAC_Final(&hctx, digtmp, NULL);
index 3fff7b1af35c1558b59afbe0db274618311b056e..da363b795070cab0a56b5c84cf919bea6e9507de 100644 (file)
@@ -61,7 +61,7 @@
 #include <openssl/hmac.h>
 
 void HMAC_Init_ex(HMAC_CTX *ctx, const void *key, int len,
-                 const EVP_MD *md)
+                 const EVP_MD *md, ENGINE *impl)
        {
        int i,j,reset=0;
        unsigned char pad[HMAC_MAX_MD_CBLOCK];
@@ -80,7 +80,7 @@ void HMAC_Init_ex(HMAC_CTX *ctx, const void *key, int len,
                j=EVP_MD_block_size(md);
                if (j < len)
                        {
-                       EVP_DigestInit_ex(&ctx->md_ctx,md, NULL);
+                       EVP_DigestInit_ex(&ctx->md_ctx,md, impl);
                        EVP_DigestUpdate(&ctx->md_ctx,key,len);
                        EVP_DigestFinal_ex(&(ctx->md_ctx),ctx->key,
                                &ctx->key_length);
@@ -99,12 +99,12 @@ void HMAC_Init_ex(HMAC_CTX *ctx, const void *key, int len,
                {
                for (i=0; i<HMAC_MAX_MD_CBLOCK; i++)
                        pad[i]=0x36^ctx->key[i];
-               EVP_DigestInit_ex(&ctx->i_ctx,md, NULL);
+               EVP_DigestInit_ex(&ctx->i_ctx,md, impl);
                EVP_DigestUpdate(&ctx->i_ctx,pad,EVP_MD_block_size(md));
 
                for (i=0; i<HMAC_MAX_MD_CBLOCK; i++)
                        pad[i]=0x5c^ctx->key[i];
-               EVP_DigestInit_ex(&ctx->o_ctx,md, NULL);
+               EVP_DigestInit_ex(&ctx->o_ctx,md, impl);
                EVP_DigestUpdate(&ctx->o_ctx,pad,EVP_MD_block_size(md));
                }
        EVP_MD_CTX_copy_ex(&ctx->md_ctx,&ctx->i_ctx);
@@ -115,7 +115,7 @@ void HMAC_Init(HMAC_CTX *ctx, const void *key, int len,
        {
        if(key && md)
            HMAC_CTX_init(ctx);
-       HMAC_Init_ex(ctx,key,len,md);
+       HMAC_Init_ex(ctx,key,len,md, NULL);
        }
 
 void HMAC_Update(HMAC_CTX *ctx, const unsigned char *data, int len)
index 58ac3d09936dd41f7efebb180457fb1f47e7f44b..0364a1fcbd93485c0808b7ef0d0cf530c35f804d 100644 (file)
@@ -91,7 +91,7 @@ void HMAC_CTX_cleanup(HMAC_CTX *ctx);
 void HMAC_Init(HMAC_CTX *ctx, const void *key, int len,
               const EVP_MD *md); /* deprecated */
 void HMAC_Init_ex(HMAC_CTX *ctx, const void *key, int len,
-                 const EVP_MD *md);
+                 const EVP_MD *md, ENGINE *impl);
 void HMAC_Update(HMAC_CTX *ctx, const unsigned char *data, int len);
 void HMAC_Final(HMAC_CTX *ctx, unsigned char *md, unsigned int *len);
 unsigned char *HMAC(const EVP_MD *evp_md, const void *key, int key_len,
index b6a10de70c85fcd7816572523b32d8bcda7f2120..0fb67f74b8b261c8f9a059c09f295d37ca23246b 100644 (file)
@@ -87,11 +87,11 @@ int PKCS12_gen_mac (PKCS12 *p12, const char *pass, int passlen,
                return 0;
        }
        HMAC_CTX_init(&hmac);
-       HMAC_Init_ex (&hmac, key, PKCS12_MAC_KEY_LENGTH, md_type);
-       HMAC_Update (&hmac, p12->authsafes->d.data->data,
+       HMAC_Init_ex(&hmac, key, PKCS12_MAC_KEY_LENGTH, md_type, NULL);
+       HMAC_Update(&hmac, p12->authsafes->d.data->data,
                                         p12->authsafes->d.data->length);
-       HMAC_Final (&hmac, mac, maclen);
-       HMAC_CTX_cleanup (&hmac);
+       HMAC_Final(&hmac, mac, maclen);
+       HMAC_CTX_cleanup(&hmac);
        return 1;
 }
 
index 62571ef5d1bcb7709b49e121c2d0cc516c67759e..e5853ede95b4f3f00a94d03a4811297276dbfde5 100644 (file)
@@ -1494,6 +1494,8 @@ static int ssl3_send_client_key_exchange(SSL *s)
                                                + EVP_MAX_IV_LENGTH];
                        int             padl, outl = sizeof(epms);
 
+                       EVP_CIPHER_CTX_init(&ciph_ctx);
+
 #ifdef KSSL_DEBUG
                         printf("ssl3_send_client_key_exchange(%lx & %lx)\n",
                                 l, SSL_kKRB5);
index 61ed0ad10e052dc9cd641223fd75c86a1efc2298..d6247a64ea1ba1f53d408922f282a3fd9ae6e965 100644 (file)
@@ -1557,6 +1557,8 @@ static int ssl3_get_client_key_exchange(SSL *s)
                krb5_timestamp          authtime = 0;
                krb5_ticket_times       ttimes;
 
+               EVP_CIPHER_CTX_init(&ciph_ctx);
+
                 if (!kssl_ctx)  kssl_ctx = kssl_ctx_new();
 
                n2s(p,i);
index 054853335485f56138ee61c09e926acdde7d037c..8b7844ceee18f1eaebbc2f77d4096ecb1f203b3e 100644 (file)
@@ -78,16 +78,16 @@ static void tls1_P_hash(const EVP_MD *md, const unsigned char *sec,
 
        HMAC_CTX_init(&ctx);
        HMAC_CTX_init(&ctx_tmp);
-       HMAC_Init_ex(&ctx,sec,sec_len,md);
-       HMAC_Init_ex(&ctx_tmp,sec,sec_len,md);
+       HMAC_Init_ex(&ctx,sec,sec_len,md, NULL);
+       HMAC_Init_ex(&ctx_tmp,sec,sec_len,md, NULL);
        HMAC_Update(&ctx,seed,seed_len);
        HMAC_Final(&ctx,A1,&A1_len);
 
        n=0;
        for (;;)
                {
-               HMAC_Init_ex(&ctx,NULL,0,NULL); /* re-init */
-               HMAC_Init_ex(&ctx_tmp,NULL,0,NULL); /* re-init */
+               HMAC_Init_ex(&ctx,NULL,0,NULL,NULL); /* re-init */
+               HMAC_Init_ex(&ctx_tmp,NULL,0,NULL,NULL); /* re-init */
                HMAC_Update(&ctx,A1,A1_len);
                HMAC_Update(&ctx_tmp,A1,A1_len);
                HMAC_Update(&ctx,seed,seed_len);
@@ -652,7 +652,7 @@ int tls1_mac(SSL *ssl, unsigned char *md, int send)
 
        /* I should fix this up TLS TLS TLS TLS TLS XXXXXXXX */
        HMAC_CTX_init(&hmac);
-       HMAC_Init_ex(&hmac,mac_sec,EVP_MD_size(hash),hash);
+       HMAC_Init_ex(&hmac,mac_sec,EVP_MD_size(hash),hash,NULL);
        HMAC_Update(&hmac,seq,8);
        HMAC_Update(&hmac,buf,5);
        HMAC_Update(&hmac,rec->input,rec->length);