| OLD | NEW |
| 1 /* crypto/dsa/dsa_sign.c */ | 1 /* crypto/dsa/dsa_sign.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 40 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 51 * SUCH DAMAGE. | 51 * SUCH DAMAGE. |
| 52 * | 52 * |
| 53 * The licence and distribution terms for any publically available version or | 53 * The licence and distribution terms for any publically available version or |
| 54 * derivative of this code cannot be changed. i.e. this code cannot simply be | 54 * derivative of this code cannot be changed. i.e. this code cannot simply be |
| 55 * copied and put under another distribution licence | 55 * copied and put under another distribution licence |
| 56 * [including the GNU Public Licence.] | 56 * [including the GNU Public Licence.] |
| 57 */ | 57 */ |
| 58 | 58 |
| 59 /* Original version from Steven Schoch <schoch@sheba.arc.nasa.gov> */ | 59 /* Original version from Steven Schoch <schoch@sheba.arc.nasa.gov> */ |
| 60 | 60 |
| 61 #include <stdio.h> | |
| 62 #include "cryptlib.h" | 61 #include "cryptlib.h" |
| 63 #include <openssl/bn.h> | |
| 64 #include <openssl/dsa.h> | 62 #include <openssl/dsa.h> |
| 65 #include <openssl/rand.h> | 63 #include <openssl/rand.h> |
| 66 #include <openssl/asn1.h> | |
| 67 #ifdef OPENSSL_FIPS | |
| 68 #include <openssl/fips.h> | |
| 69 #endif | |
| 70 | |
| 71 | 64 |
| 72 DSA_SIG * DSA_do_sign(const unsigned char *dgst, int dlen, DSA *dsa) | 65 DSA_SIG * DSA_do_sign(const unsigned char *dgst, int dlen, DSA *dsa) |
| 73 { | 66 { |
| 74 #ifdef OPENSSL_FIPS | 67 » return dsa->meth->dsa_do_sign(dgst, dlen, dsa); |
| 75 » if(FIPS_mode() && !(dsa->flags & DSA_FLAG_NON_FIPS_ALLOW)) | 68 » } |
| 69 |
| 70 int DSA_sign(int type, const unsigned char *dgst, int dlen, unsigned char *sig, |
| 71 » unsigned int *siglen, DSA *dsa) |
| 72 » { |
| 73 » DSA_SIG *s; |
| 74 » RAND_seed(dgst, dlen); |
| 75 » s=DSA_do_sign(dgst,dlen,dsa); |
| 76 » if (s == NULL) |
| 76 { | 77 { |
| 77 » » DSAerr(DSA_F_DSA_DO_SIGN, DSA_R_OPERATION_NOT_ALLOWED_IN_FIPS_MO
DE); | 78 » » *siglen=0; |
| 78 » » return NULL; | 79 » » return(0); |
| 79 } | 80 } |
| 80 #endif | 81 » *siglen=i2d_DSA_SIG(s,&sig); |
| 81 » return dsa->meth->dsa_do_sign(dgst, dlen, dsa); | 82 » DSA_SIG_free(s); |
| 83 » return(1); |
| 82 } | 84 } |
| 83 | 85 |
| 84 int DSA_sign_setup(DSA *dsa, BN_CTX *ctx_in, BIGNUM **kinvp, BIGNUM **rp) | 86 int DSA_sign_setup(DSA *dsa, BN_CTX *ctx_in, BIGNUM **kinvp, BIGNUM **rp) |
| 85 { | 87 { |
| 86 #ifdef OPENSSL_FIPS | |
| 87 if(FIPS_mode() && !(dsa->flags & DSA_FLAG_NON_FIPS_ALLOW)) | |
| 88 { | |
| 89 DSAerr(DSA_F_DSA_SIGN_SETUP, DSA_R_OPERATION_NOT_ALLOWED_IN_FIPS
_MODE); | |
| 90 return 0; | |
| 91 } | |
| 92 #endif | |
| 93 return dsa->meth->dsa_sign_setup(dsa, ctx_in, kinvp, rp); | 88 return dsa->meth->dsa_sign_setup(dsa, ctx_in, kinvp, rp); |
| 94 } | 89 } |
| 95 | 90 |
| OLD | NEW |