diff options
Diffstat (limited to 'src/lib/libcrypto/dsa/dsa_lib.c')
| -rw-r--r-- | src/lib/libcrypto/dsa/dsa_lib.c | 59 |
1 files changed, 49 insertions, 10 deletions
diff --git a/src/lib/libcrypto/dsa/dsa_lib.c b/src/lib/libcrypto/dsa/dsa_lib.c index b647257f9f..ce8e204f7e 100644 --- a/src/lib/libcrypto/dsa/dsa_lib.c +++ b/src/lib/libcrypto/dsa/dsa_lib.c | |||
| @@ -56,17 +56,17 @@ | |||
| 56 | * [including the GNU Public Licence.] | 56 | * [including the GNU Public Licence.] |
| 57 | */ | 57 | */ |
| 58 | 58 | ||
| 59 | /* Origional 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> | 61 | #include <stdio.h> |
| 62 | #include "cryptlib.h" | 62 | #include "cryptlib.h" |
| 63 | #include "bn.h" | 63 | #include <openssl/bn.h> |
| 64 | #include "dsa.h" | 64 | #include <openssl/dsa.h> |
| 65 | #include "asn1.h" | 65 | #include <openssl/asn1.h> |
| 66 | 66 | ||
| 67 | char *DSA_version="\0DSA part of SSLeay 0.9.0b 29-Jun-1998"; | 67 | const char *DSA_version="DSA" OPENSSL_VERSION_PTEXT; |
| 68 | 68 | ||
| 69 | DSA *DSA_new() | 69 | DSA *DSA_new(void) |
| 70 | { | 70 | { |
| 71 | DSA *ret; | 71 | DSA *ret; |
| 72 | 72 | ||
| @@ -82,19 +82,20 @@ DSA *DSA_new() | |||
| 82 | ret->p=NULL; | 82 | ret->p=NULL; |
| 83 | ret->q=NULL; | 83 | ret->q=NULL; |
| 84 | ret->g=NULL; | 84 | ret->g=NULL; |
| 85 | ret->flags=DSA_FLAG_CACHE_MONT_P; | ||
| 85 | 86 | ||
| 86 | ret->pub_key=NULL; | 87 | ret->pub_key=NULL; |
| 87 | ret->priv_key=NULL; | 88 | ret->priv_key=NULL; |
| 88 | 89 | ||
| 89 | ret->kinv=NULL; | 90 | ret->kinv=NULL; |
| 90 | ret->r=NULL; | 91 | ret->r=NULL; |
| 92 | ret->method_mont_p=NULL; | ||
| 91 | 93 | ||
| 92 | ret->references=1; | 94 | ret->references=1; |
| 93 | return(ret); | 95 | return(ret); |
| 94 | } | 96 | } |
| 95 | 97 | ||
| 96 | void DSA_free(r) | 98 | void DSA_free(DSA *r) |
| 97 | DSA *r; | ||
| 98 | { | 99 | { |
| 99 | int i; | 100 | int i; |
| 100 | 101 | ||
| @@ -120,11 +121,12 @@ DSA *r; | |||
| 120 | if (r->priv_key != NULL) BN_clear_free(r->priv_key); | 121 | if (r->priv_key != NULL) BN_clear_free(r->priv_key); |
| 121 | if (r->kinv != NULL) BN_clear_free(r->kinv); | 122 | if (r->kinv != NULL) BN_clear_free(r->kinv); |
| 122 | if (r->r != NULL) BN_clear_free(r->r); | 123 | if (r->r != NULL) BN_clear_free(r->r); |
| 124 | if (r->method_mont_p != NULL) | ||
| 125 | BN_MONT_CTX_free((BN_MONT_CTX *)r->method_mont_p); | ||
| 123 | Free(r); | 126 | Free(r); |
| 124 | } | 127 | } |
| 125 | 128 | ||
| 126 | int DSA_size(r) | 129 | int DSA_size(DSA *r) |
| 127 | DSA *r; | ||
| 128 | { | 130 | { |
| 129 | int ret,i; | 131 | int ret,i; |
| 130 | ASN1_INTEGER bs; | 132 | ASN1_INTEGER bs; |
| @@ -143,3 +145,40 @@ DSA *r; | |||
| 143 | return(ret); | 145 | return(ret); |
| 144 | } | 146 | } |
| 145 | 147 | ||
| 148 | #ifndef NO_DH | ||
| 149 | DH *DSA_dup_DH(DSA *r) | ||
| 150 | { | ||
| 151 | /* DSA has p, q, g, optional pub_key, optional priv_key. | ||
| 152 | * DH has p, optional length, g, optional pub_key, optional priv_key. | ||
| 153 | */ | ||
| 154 | |||
| 155 | DH *ret = NULL; | ||
| 156 | |||
| 157 | if (r == NULL) | ||
| 158 | goto err; | ||
| 159 | ret = DH_new(); | ||
| 160 | if (ret == NULL) | ||
| 161 | goto err; | ||
| 162 | if (r->p != NULL) | ||
| 163 | if ((ret->p = BN_dup(r->p)) == NULL) | ||
| 164 | goto err; | ||
| 165 | if (r->q != NULL) | ||
| 166 | ret->length = BN_num_bits(r->q); | ||
| 167 | if (r->g != NULL) | ||
| 168 | if ((ret->g = BN_dup(r->g)) == NULL) | ||
| 169 | goto err; | ||
| 170 | if (r->pub_key != NULL) | ||
| 171 | if ((ret->pub_key = BN_dup(r->pub_key)) == NULL) | ||
| 172 | goto err; | ||
| 173 | if (r->priv_key != NULL) | ||
| 174 | if ((ret->priv_key = BN_dup(r->priv_key)) == NULL) | ||
| 175 | goto err; | ||
| 176 | |||
| 177 | return ret; | ||
| 178 | |||
| 179 | err: | ||
| 180 | if (ret != NULL) | ||
| 181 | DH_free(ret); | ||
| 182 | return NULL; | ||
| 183 | } | ||
| 184 | #endif | ||
