diff options
Diffstat (limited to '')
| -rw-r--r-- | src/lib/libcrypto/rsa/rsa_prn.c (renamed from src/lib/libssl/src/fips/dsa/fips_dsa_lib.c) | 64 |
1 files changed, 31 insertions, 33 deletions
diff --git a/src/lib/libssl/src/fips/dsa/fips_dsa_lib.c b/src/lib/libcrypto/rsa/rsa_prn.c index 2545966d2a..224db0fae5 100644 --- a/src/lib/libssl/src/fips/dsa/fips_dsa_lib.c +++ b/src/lib/libcrypto/rsa/rsa_prn.c | |||
| @@ -1,9 +1,9 @@ | |||
| 1 | /* fips_dsa_lib.c */ | 1 | /* crypto/rsa/rsa_prn.c */ |
| 2 | /* Written by Dr Stephen N Henson (steve@openssl.org) for the OpenSSL | 2 | /* Written by Dr Stephen N Henson (steve@openssl.org) for the OpenSSL |
| 3 | * project 2007. | 3 | * project 2006. |
| 4 | */ | 4 | */ |
| 5 | /* ==================================================================== | 5 | /* ==================================================================== |
| 6 | * Copyright (c) 2007 The OpenSSL Project. All rights reserved. | 6 | * Copyright (c) 2006 The OpenSSL Project. All rights reserved. |
| 7 | * | 7 | * |
| 8 | * Redistribution and use in source and binary forms, with or without | 8 | * Redistribution and use in source and binary forms, with or without |
| 9 | * modification, are permitted provided that the following conditions | 9 | * modification, are permitted provided that the following conditions |
| @@ -56,40 +56,38 @@ | |||
| 56 | * | 56 | * |
| 57 | */ | 57 | */ |
| 58 | 58 | ||
| 59 | #include <string.h> | 59 | #include <stdio.h> |
| 60 | #include <openssl/dsa.h> | 60 | #include "cryptlib.h" |
| 61 | #include <openssl/bn.h> | 61 | #include <openssl/rsa.h> |
| 62 | #include <openssl/evp.h> | ||
| 62 | 63 | ||
| 63 | /* Minimal FIPS versions of FIPS_dsa_new() and FIPS_dsa_free: to | 64 | #ifndef OPENSSL_NO_FP_API |
| 64 | * reduce external dependencies. | 65 | int RSA_print_fp(FILE *fp, const RSA *x, int off) |
| 65 | */ | ||
| 66 | |||
| 67 | DSA *FIPS_dsa_new(void) | ||
| 68 | { | 66 | { |
| 69 | DSA *ret; | 67 | BIO *b; |
| 70 | ret = OPENSSL_malloc(sizeof(DSA)); | 68 | int ret; |
| 71 | if (!ret) | 69 | |
| 72 | return NULL; | 70 | if ((b=BIO_new(BIO_s_file())) == NULL) |
| 73 | memset(ret, 0, sizeof(DSA)); | 71 | { |
| 74 | ret->meth = DSA_OpenSSL(); | 72 | RSAerr(RSA_F_RSA_PRINT_FP,ERR_R_BUF_LIB); |
| 75 | if (ret->meth->init) | 73 | return(0); |
| 76 | ret->meth->init(ret); | 74 | } |
| 77 | return ret; | 75 | BIO_set_fp(b,fp,BIO_NOCLOSE); |
| 76 | ret=RSA_print(b,x,off); | ||
| 77 | BIO_free(b); | ||
| 78 | return(ret); | ||
| 78 | } | 79 | } |
| 80 | #endif | ||
| 79 | 81 | ||
| 80 | void FIPS_dsa_free(DSA *r) | 82 | int RSA_print(BIO *bp, const RSA *x, int off) |
| 81 | { | 83 | { |
| 82 | if (!r) | 84 | EVP_PKEY *pk; |
| 83 | return; | 85 | int ret; |
| 84 | if (r->meth->finish) | 86 | pk = EVP_PKEY_new(); |
| 85 | r->meth->finish(r); | 87 | if (!pk || !EVP_PKEY_set1_RSA(pk, (RSA *)x)) |
| 86 | if (r->p != NULL) BN_clear_free(r->p); | 88 | return 0; |
| 87 | if (r->q != NULL) BN_clear_free(r->q); | 89 | ret = EVP_PKEY_print_private(bp, pk, off, NULL); |
| 88 | if (r->g != NULL) BN_clear_free(r->g); | 90 | EVP_PKEY_free(pk); |
| 89 | if (r->pub_key != NULL) BN_clear_free(r->pub_key); | 91 | return ret; |
| 90 | if (r->priv_key != NULL) BN_clear_free(r->priv_key); | ||
| 91 | if (r->kinv != NULL) BN_clear_free(r->kinv); | ||
| 92 | if (r->r != NULL) BN_clear_free(r->r); | ||
| 93 | OPENSSL_free(r); | ||
| 94 | } | 92 | } |
| 95 | 93 | ||
