diff options
Diffstat (limited to '')
| -rw-r--r-- | src/lib/libcrypto/dh/dh_asn1.c (renamed from src/lib/libssl/src/fips/dh/fips_dh_lib.c) | 64 |
1 files changed, 31 insertions, 33 deletions
diff --git a/src/lib/libssl/src/fips/dh/fips_dh_lib.c b/src/lib/libcrypto/dh/dh_asn1.c index 4a822cf192..0b4357d605 100644 --- a/src/lib/libssl/src/fips/dh/fips_dh_lib.c +++ b/src/lib/libcrypto/dh/dh_asn1.c | |||
| @@ -1,9 +1,9 @@ | |||
| 1 | /* fips_dh_lib.c */ | 1 | /* dh_asn1.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 2000. |
| 4 | */ | 4 | */ |
| 5 | /* ==================================================================== | 5 | /* ==================================================================== |
| 6 | * Copyright (c) 2007 The OpenSSL Project. All rights reserved. | 6 | * Copyright (c) 2000-2005 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 "cryptlib.h" | ||
| 60 | #include <openssl/bn.h> | 61 | #include <openssl/bn.h> |
| 61 | #include <openssl/dh.h> | 62 | #include <openssl/dh.h> |
| 63 | #include <openssl/objects.h> | ||
| 64 | #include <openssl/asn1t.h> | ||
| 62 | 65 | ||
| 63 | /* Minimal FIPS versions of FIPS_dh_new() and FIPS_dh_free(): to | 66 | /* Override the default free and new methods */ |
| 64 | * reduce external dependencies. | 67 | static int dh_cb(int operation, ASN1_VALUE **pval, const ASN1_ITEM *it, |
| 65 | */ | 68 | void *exarg) |
| 66 | 69 | { | |
| 67 | DH *FIPS_dh_new(void) | 70 | if(operation == ASN1_OP_NEW_PRE) { |
| 68 | { | 71 | *pval = (ASN1_VALUE *)DH_new(); |
| 69 | DH *ret; | 72 | if(*pval) return 2; |
| 70 | ret = OPENSSL_malloc(sizeof(DH)); | 73 | return 0; |
| 71 | if (!ret) | 74 | } else if(operation == ASN1_OP_FREE_PRE) { |
| 72 | return NULL; | 75 | DH_free((DH *)*pval); |
| 73 | memset(ret, 0, sizeof(DH)); | 76 | *pval = NULL; |
| 74 | ret->meth = DH_OpenSSL(); | 77 | return 2; |
| 75 | if (ret->meth->init) | ||
| 76 | ret->meth->init(ret); | ||
| 77 | return ret; | ||
| 78 | } | 78 | } |
| 79 | return 1; | ||
| 80 | } | ||
| 81 | |||
| 82 | ASN1_SEQUENCE_cb(DHparams, dh_cb) = { | ||
| 83 | ASN1_SIMPLE(DH, p, BIGNUM), | ||
| 84 | ASN1_SIMPLE(DH, g, BIGNUM), | ||
| 85 | ASN1_OPT(DH, length, ZLONG), | ||
| 86 | } ASN1_SEQUENCE_END_cb(DH, DHparams) | ||
| 87 | |||
| 88 | IMPLEMENT_ASN1_ENCODE_FUNCTIONS_const_fname(DH, DHparams, DHparams) | ||
| 79 | 89 | ||
| 80 | void FIPS_dh_free(DH *r) | 90 | DH *DHparams_dup(DH *dh) |
| 81 | { | 91 | { |
| 82 | if (!r) | 92 | return ASN1_item_dup(ASN1_ITEM_rptr(DHparams), dh); |
| 83 | return; | ||
| 84 | if (r->meth->finish) | ||
| 85 | r->meth->finish(r); | ||
| 86 | if (r->p != NULL) BN_clear_free(r->p); | ||
| 87 | if (r->g != NULL) BN_clear_free(r->g); | ||
| 88 | if (r->q != NULL) BN_clear_free(r->q); | ||
| 89 | if (r->j != NULL) BN_clear_free(r->j); | ||
| 90 | if (r->seed) OPENSSL_free(r->seed); | ||
| 91 | if (r->counter != NULL) BN_clear_free(r->counter); | ||
| 92 | if (r->pub_key != NULL) BN_clear_free(r->pub_key); | ||
| 93 | if (r->priv_key != NULL) BN_clear_free(r->priv_key); | ||
| 94 | OPENSSL_free(r); | ||
| 95 | } | 93 | } |
