summaryrefslogtreecommitdiff
path: root/src/lib/libcrypto/dsa/dsa_prn.c
diff options
context:
space:
mode:
Diffstat (limited to '')
-rw-r--r--src/lib/libcrypto/dsa/dsa_prn.c (renamed from src/lib/libssl/src/fips/rsa/fips_rsa_lib.c)92
1 files changed, 56 insertions, 36 deletions
diff --git a/src/lib/libssl/src/fips/rsa/fips_rsa_lib.c b/src/lib/libcrypto/dsa/dsa_prn.c
index a37ad3e540..6f29f5e240 100644
--- a/src/lib/libssl/src/fips/rsa/fips_rsa_lib.c
+++ b/src/lib/libcrypto/dsa/dsa_prn.c
@@ -1,9 +1,9 @@
1/* fips_rsa_sign.c */ 1/* crypto/dsa/dsa_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,46 +56,66 @@
56 * 56 *
57 */ 57 */
58 58
59#include <string.h> 59#include <stdio.h>
60#include "cryptlib.h"
60#include <openssl/evp.h> 61#include <openssl/evp.h>
61#include <openssl/rsa.h> 62#include <openssl/dsa.h>
62#include <openssl/bn.h>
63#include <openssl/err.h>
64 63
65/* Minimal FIPS versions of FIPS_rsa_new() and FIPS_rsa_free: to 64#ifndef OPENSSL_NO_FP_API
66 * reduce external dependencies. 65int DSA_print_fp(FILE *fp, const DSA *x, int off)
67 */ 66 {
67 BIO *b;
68 int ret;
68 69
69RSA *FIPS_rsa_new(void) 70 if ((b=BIO_new(BIO_s_file())) == NULL)
71 {
72 DSAerr(DSA_F_DSA_PRINT_FP,ERR_R_BUF_LIB);
73 return(0);
74 }
75 BIO_set_fp(b,fp,BIO_NOCLOSE);
76 ret=DSA_print(b,x,off);
77 BIO_free(b);
78 return(ret);
79 }
80
81int DSAparams_print_fp(FILE *fp, const DSA *x)
70 { 82 {
71 RSA *ret; 83 BIO *b;
72 ret = OPENSSL_malloc(sizeof(RSA)); 84 int ret;
73 if (!ret) 85
74 return NULL; 86 if ((b=BIO_new(BIO_s_file())) == NULL)
75 memset(ret, 0, sizeof(RSA)); 87 {
76 ret->meth = RSA_PKCS1_SSLeay(); 88 DSAerr(DSA_F_DSAPARAMS_PRINT_FP,ERR_R_BUF_LIB);
77 if (ret->meth->init) 89 return(0);
78 ret->meth->init(ret); 90 }
91 BIO_set_fp(b,fp,BIO_NOCLOSE);
92 ret=DSAparams_print(b, x);
93 BIO_free(b);
94 return(ret);
95 }
96#endif
97
98int DSA_print(BIO *bp, const DSA *x, int off)
99 {
100 EVP_PKEY *pk;
101 int ret;
102 pk = EVP_PKEY_new();
103 if (!pk || !EVP_PKEY_set1_DSA(pk, (DSA *)x))
104 return 0;
105 ret = EVP_PKEY_print_private(bp, pk, off, NULL);
106 EVP_PKEY_free(pk);
79 return ret; 107 return ret;
80 } 108 }
81 109
82void FIPS_rsa_free(RSA *r) 110int DSAparams_print(BIO *bp, const DSA *x)
83 { 111 {
84 if (!r) 112 EVP_PKEY *pk;
85 return; 113 int ret;
86 if (r->meth->finish) 114 pk = EVP_PKEY_new();
87 r->meth->finish(r); 115 if (!pk || !EVP_PKEY_set1_DSA(pk, (DSA *)x))
88 if (r->n != NULL) BN_clear_free(r->n); 116 return 0;
89 if (r->e != NULL) BN_clear_free(r->e); 117 ret = EVP_PKEY_print_params(bp, pk, 4, NULL);
90 if (r->d != NULL) BN_clear_free(r->d); 118 EVP_PKEY_free(pk);
91 if (r->p != NULL) BN_clear_free(r->p); 119 return ret;
92 if (r->q != NULL) BN_clear_free(r->q);
93 if (r->dmp1 != NULL) BN_clear_free(r->dmp1);
94 if (r->dmq1 != NULL) BN_clear_free(r->dmq1);
95 if (r->iqmp != NULL) BN_clear_free(r->iqmp);
96 if (r->blinding != NULL) BN_BLINDING_free(r->blinding);
97 if (r->mt_blinding != NULL) BN_BLINDING_free(r->mt_blinding);
98 if (r->bignum_data != NULL) OPENSSL_free_locked(r->bignum_data);
99 OPENSSL_free(r);
100 } 120 }
101 121