e_aes_cbc_hmac_sha1.c: address the CBC decrypt timing issues.
[openssl.git] / crypto / evp / m_sha.c
index fc7143e6da409b072b692d18d72f8c7f914ceeba..acccc8f92d8e13b9cd5d50f45780f64ccc145470 100644 (file)
  * [including the GNU Public Licence.]
  */
 
-#ifndef OPENSSL_NO_SHA
 #include <stdio.h>
 #include "cryptlib.h"
+
+#if !defined(OPENSSL_NO_SHA) && !defined(OPENSSL_NO_SHA0)
+
 #include <openssl/evp.h>
 #include <openssl/objects.h>
 #include <openssl/x509.h>
+#ifndef OPENSSL_NO_RSA
+#include <openssl/rsa.h>
+#endif
+
+static int init(EVP_MD_CTX *ctx)
+       { return SHA_Init(ctx->md_data); }
+
+static int update(EVP_MD_CTX *ctx,const void *data,size_t count)
+       { return SHA_Update(ctx->md_data,data,count); }
+
+static int final(EVP_MD_CTX *ctx,unsigned char *md)
+       { return SHA_Final(md,ctx->md_data); }
 
-static EVP_MD sha_md=
+static const EVP_MD sha_md=
        {
        NID_sha,
        NID_shaWithRSAEncryption,
        SHA_DIGEST_LENGTH,
-       SHA_Init,
-       SHA_Update,
-       SHA_Final,
+       0,
+       init,
+       update,
+       final,
+       NULL,
+       NULL,
        EVP_PKEY_RSA_method,
        SHA_CBLOCK,
        sizeof(EVP_MD *)+sizeof(SHA_CTX),
        };
 
-EVP_MD *EVP_sha(void)
+const EVP_MD *EVP_sha(void)
        {
        return(&sha_md);
        }