| OLD | NEW | 
|    1 /* crypto/evp/m_sha1.c */ |    1 /* crypto/evp/m_sha1.c */ | 
|    2 /* Copyright (C) 1995-1998 Eric Young (eay@cryptsoft.com) |    2 /* Copyright (C) 1995-1998 Eric Young (eay@cryptsoft.com) | 
|    3  * All rights reserved. |    3  * All rights reserved. | 
|    4  * |    4  * | 
|    5  * This package is an SSL implementation written |    5  * This package is an SSL implementation written | 
|    6  * by Eric Young (eay@cryptsoft.com). |    6  * by Eric Young (eay@cryptsoft.com). | 
|    7  * The implementation was written so as to conform with Netscapes SSL. |    7  * The implementation was written so as to conform with Netscapes SSL. | 
|    8  *  |    8  *  | 
|    9  * This library is free for commercial and non-commercial use as long as |    9  * This library is free for commercial and non-commercial use as long as | 
|   10  * the following conditions are aheared to.  The following conditions |   10  * the following conditions are aheared to.  The following conditions | 
| (...skipping 50 matching lines...) Expand 10 before | Expand all | Expand 10 after  Loading... | 
|   61  |   61  | 
|   62 #ifndef OPENSSL_NO_SHA |   62 #ifndef OPENSSL_NO_SHA | 
|   63  |   63  | 
|   64 #include <openssl/evp.h> |   64 #include <openssl/evp.h> | 
|   65 #include <openssl/objects.h> |   65 #include <openssl/objects.h> | 
|   66 #include <openssl/x509.h> |   66 #include <openssl/x509.h> | 
|   67 #ifndef OPENSSL_NO_RSA |   67 #ifndef OPENSSL_NO_RSA | 
|   68 #include <openssl/rsa.h> |   68 #include <openssl/rsa.h> | 
|   69 #endif |   69 #endif | 
|   70  |   70  | 
|   71 #ifndef OPENSSL_FIPS |  | 
|   72  |  | 
|   73 static int init(EVP_MD_CTX *ctx) |   71 static int init(EVP_MD_CTX *ctx) | 
|   74         { return SHA1_Init(ctx->md_data); } |   72         { return SHA1_Init(ctx->md_data); } | 
|   75  |   73  | 
|   76 static int update(EVP_MD_CTX *ctx,const void *data,size_t count) |   74 static int update(EVP_MD_CTX *ctx,const void *data,size_t count) | 
|   77         { return SHA1_Update(ctx->md_data,data,count); } |   75         { return SHA1_Update(ctx->md_data,data,count); } | 
|   78  |   76  | 
|   79 static int final(EVP_MD_CTX *ctx,unsigned char *md) |   77 static int final(EVP_MD_CTX *ctx,unsigned char *md) | 
|   80         { return SHA1_Final(md,ctx->md_data); } |   78         { return SHA1_Final(md,ctx->md_data); } | 
|   81  |   79  | 
|   82 static const EVP_MD sha1_md= |   80 static const EVP_MD sha1_md= | 
|   83         { |   81         { | 
|   84         NID_sha1, |   82         NID_sha1, | 
|   85         NID_sha1WithRSAEncryption, |   83         NID_sha1WithRSAEncryption, | 
|   86         SHA_DIGEST_LENGTH, |   84         SHA_DIGEST_LENGTH, | 
|   87 »       0, |   85 »       EVP_MD_FLAG_PKEY_METHOD_SIGNATURE|EVP_MD_FLAG_DIGALGID_ABSENT, | 
|   88         init, |   86         init, | 
|   89         update, |   87         update, | 
|   90         final, |   88         final, | 
|   91         NULL, |   89         NULL, | 
|   92         NULL, |   90         NULL, | 
|   93         EVP_PKEY_RSA_method, |   91         EVP_PKEY_RSA_method, | 
|   94         SHA_CBLOCK, |   92         SHA_CBLOCK, | 
|   95         sizeof(EVP_MD *)+sizeof(SHA_CTX), |   93         sizeof(EVP_MD *)+sizeof(SHA_CTX), | 
|   96         }; |   94         }; | 
|   97  |   95  | 
|   98 const EVP_MD *EVP_sha1(void) |   96 const EVP_MD *EVP_sha1(void) | 
|   99         { |   97         { | 
|  100         return(&sha1_md); |   98         return(&sha1_md); | 
|  101         } |   99         } | 
 |  100 #endif | 
|  102  |  101  | 
|  103 #ifndef OPENSSL_NO_SHA256 |  102 #ifndef OPENSSL_NO_SHA256 | 
|  104 static int init224(EVP_MD_CTX *ctx) |  103 static int init224(EVP_MD_CTX *ctx) | 
|  105         { return SHA224_Init(ctx->md_data); } |  104         { return SHA224_Init(ctx->md_data); } | 
|  106 static int init256(EVP_MD_CTX *ctx) |  105 static int init256(EVP_MD_CTX *ctx) | 
|  107         { return SHA256_Init(ctx->md_data); } |  106         { return SHA256_Init(ctx->md_data); } | 
|  108 /* |  107 /* | 
|  109  * Even though there're separate SHA224_[Update|Final], we call |  108  * Even though there're separate SHA224_[Update|Final], we call | 
|  110  * SHA256 functions even in SHA224 context. This is what happens |  109  * SHA256 functions even in SHA224 context. This is what happens | 
|  111  * there anyway, so we can spare few CPU cycles:-) |  110  * there anyway, so we can spare few CPU cycles:-) | 
|  112  */ |  111  */ | 
|  113 static int update256(EVP_MD_CTX *ctx,const void *data,size_t count) |  112 static int update256(EVP_MD_CTX *ctx,const void *data,size_t count) | 
|  114         { return SHA256_Update(ctx->md_data,data,count); } |  113         { return SHA256_Update(ctx->md_data,data,count); } | 
|  115 static int final256(EVP_MD_CTX *ctx,unsigned char *md) |  114 static int final256(EVP_MD_CTX *ctx,unsigned char *md) | 
|  116         { return SHA256_Final(md,ctx->md_data); } |  115         { return SHA256_Final(md,ctx->md_data); } | 
|  117  |  116  | 
|  118 static const EVP_MD sha224_md= |  117 static const EVP_MD sha224_md= | 
|  119         { |  118         { | 
|  120         NID_sha224, |  119         NID_sha224, | 
|  121         NID_sha224WithRSAEncryption, |  120         NID_sha224WithRSAEncryption, | 
|  122         SHA224_DIGEST_LENGTH, |  121         SHA224_DIGEST_LENGTH, | 
|  123 »       0, |  122 »       EVP_MD_FLAG_PKEY_METHOD_SIGNATURE|EVP_MD_FLAG_DIGALGID_ABSENT, | 
|  124         init224, |  123         init224, | 
|  125         update256, |  124         update256, | 
|  126         final256, |  125         final256, | 
|  127         NULL, |  126         NULL, | 
|  128         NULL, |  127         NULL, | 
|  129         EVP_PKEY_RSA_method, |  128         EVP_PKEY_RSA_method, | 
|  130         SHA256_CBLOCK, |  129         SHA256_CBLOCK, | 
|  131         sizeof(EVP_MD *)+sizeof(SHA256_CTX), |  130         sizeof(EVP_MD *)+sizeof(SHA256_CTX), | 
|  132         }; |  131         }; | 
|  133  |  132  | 
|  134 const EVP_MD *EVP_sha224(void) |  133 const EVP_MD *EVP_sha224(void) | 
|  135         { return(&sha224_md); } |  134         { return(&sha224_md); } | 
|  136  |  135  | 
|  137 static const EVP_MD sha256_md= |  136 static const EVP_MD sha256_md= | 
|  138         { |  137         { | 
|  139         NID_sha256, |  138         NID_sha256, | 
|  140         NID_sha256WithRSAEncryption, |  139         NID_sha256WithRSAEncryption, | 
|  141         SHA256_DIGEST_LENGTH, |  140         SHA256_DIGEST_LENGTH, | 
|  142 »       0, |  141 »       EVP_MD_FLAG_PKEY_METHOD_SIGNATURE|EVP_MD_FLAG_DIGALGID_ABSENT, | 
|  143         init256, |  142         init256, | 
|  144         update256, |  143         update256, | 
|  145         final256, |  144         final256, | 
|  146         NULL, |  145         NULL, | 
|  147         NULL, |  146         NULL, | 
|  148         EVP_PKEY_RSA_method, |  147         EVP_PKEY_RSA_method, | 
|  149         SHA256_CBLOCK, |  148         SHA256_CBLOCK, | 
|  150         sizeof(EVP_MD *)+sizeof(SHA256_CTX), |  149         sizeof(EVP_MD *)+sizeof(SHA256_CTX), | 
|  151         }; |  150         }; | 
|  152  |  151  | 
| (...skipping 10 matching lines...) Expand all  Loading... | 
|  163 static int update512(EVP_MD_CTX *ctx,const void *data,size_t count) |  162 static int update512(EVP_MD_CTX *ctx,const void *data,size_t count) | 
|  164         { return SHA512_Update(ctx->md_data,data,count); } |  163         { return SHA512_Update(ctx->md_data,data,count); } | 
|  165 static int final512(EVP_MD_CTX *ctx,unsigned char *md) |  164 static int final512(EVP_MD_CTX *ctx,unsigned char *md) | 
|  166         { return SHA512_Final(md,ctx->md_data); } |  165         { return SHA512_Final(md,ctx->md_data); } | 
|  167  |  166  | 
|  168 static const EVP_MD sha384_md= |  167 static const EVP_MD sha384_md= | 
|  169         { |  168         { | 
|  170         NID_sha384, |  169         NID_sha384, | 
|  171         NID_sha384WithRSAEncryption, |  170         NID_sha384WithRSAEncryption, | 
|  172         SHA384_DIGEST_LENGTH, |  171         SHA384_DIGEST_LENGTH, | 
|  173 »       0, |  172 »       EVP_MD_FLAG_PKEY_METHOD_SIGNATURE|EVP_MD_FLAG_DIGALGID_ABSENT, | 
|  174         init384, |  173         init384, | 
|  175         update512, |  174         update512, | 
|  176         final512, |  175         final512, | 
|  177         NULL, |  176         NULL, | 
|  178         NULL, |  177         NULL, | 
|  179         EVP_PKEY_RSA_method, |  178         EVP_PKEY_RSA_method, | 
|  180         SHA512_CBLOCK, |  179         SHA512_CBLOCK, | 
|  181         sizeof(EVP_MD *)+sizeof(SHA512_CTX), |  180         sizeof(EVP_MD *)+sizeof(SHA512_CTX), | 
|  182         }; |  181         }; | 
|  183  |  182  | 
|  184 const EVP_MD *EVP_sha384(void) |  183 const EVP_MD *EVP_sha384(void) | 
|  185         { return(&sha384_md); } |  184         { return(&sha384_md); } | 
|  186  |  185  | 
|  187 static const EVP_MD sha512_md= |  186 static const EVP_MD sha512_md= | 
|  188         { |  187         { | 
|  189         NID_sha512, |  188         NID_sha512, | 
|  190         NID_sha512WithRSAEncryption, |  189         NID_sha512WithRSAEncryption, | 
|  191         SHA512_DIGEST_LENGTH, |  190         SHA512_DIGEST_LENGTH, | 
|  192 »       0, |  191 »       EVP_MD_FLAG_PKEY_METHOD_SIGNATURE|EVP_MD_FLAG_DIGALGID_ABSENT, | 
|  193         init512, |  192         init512, | 
|  194         update512, |  193         update512, | 
|  195         final512, |  194         final512, | 
|  196         NULL, |  195         NULL, | 
|  197         NULL, |  196         NULL, | 
|  198         EVP_PKEY_RSA_method, |  197         EVP_PKEY_RSA_method, | 
|  199         SHA512_CBLOCK, |  198         SHA512_CBLOCK, | 
|  200         sizeof(EVP_MD *)+sizeof(SHA512_CTX), |  199         sizeof(EVP_MD *)+sizeof(SHA512_CTX), | 
|  201         }; |  200         }; | 
|  202  |  201  | 
|  203 const EVP_MD *EVP_sha512(void) |  202 const EVP_MD *EVP_sha512(void) | 
|  204         { return(&sha512_md); } |  203         { return(&sha512_md); } | 
|  205 #endif  /* ifndef OPENSSL_NO_SHA512 */ |  204 #endif  /* ifndef OPENSSL_NO_SHA512 */ | 
|  206  |  | 
|  207 #endif |  | 
|  208  |  | 
|  209 #endif |  | 
| OLD | NEW |