OLD | NEW |
1 /* dh_asn1.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 2000. | 3 * project 2000. |
4 */ | 4 */ |
5 /* ==================================================================== | 5 /* ==================================================================== |
6 * Copyright (c) 2000 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 |
10 * are met: | 10 * are met: |
11 * | 11 * |
12 * 1. Redistributions of source code must retain the above copyright | 12 * 1. Redistributions of source code must retain the above copyright |
13 * notice, this list of conditions and the following disclaimer. | 13 * notice, this list of conditions and the following disclaimer. |
14 * | 14 * |
15 * 2. Redistributions in binary form must reproduce the above copyright | 15 * 2. Redistributions in binary form must reproduce the above copyright |
16 * notice, this list of conditions and the following disclaimer in | 16 * notice, this list of conditions and the following disclaimer in |
(...skipping 40 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
57 */ | 57 */ |
58 | 58 |
59 #include <stdio.h> | 59 #include <stdio.h> |
60 #include "cryptlib.h" | 60 #include "cryptlib.h" |
61 #include <openssl/bn.h> | 61 #include <openssl/bn.h> |
62 #include <openssl/dh.h> | 62 #include <openssl/dh.h> |
63 #include <openssl/objects.h> | 63 #include <openssl/objects.h> |
64 #include <openssl/asn1t.h> | 64 #include <openssl/asn1t.h> |
65 | 65 |
66 /* Override the default free and new methods */ | 66 /* Override the default free and new methods */ |
67 static int dh_cb(int operation, ASN1_VALUE **pval, const ASN1_ITEM *it) | 67 static int dh_cb(int operation, ASN1_VALUE **pval, const ASN1_ITEM *it, |
| 68 » » » » » » void *exarg) |
68 { | 69 { |
69 if(operation == ASN1_OP_NEW_PRE) { | 70 if(operation == ASN1_OP_NEW_PRE) { |
70 *pval = (ASN1_VALUE *)DH_new(); | 71 *pval = (ASN1_VALUE *)DH_new(); |
71 if(*pval) return 2; | 72 if(*pval) return 2; |
72 return 0; | 73 return 0; |
73 } else if(operation == ASN1_OP_FREE_PRE) { | 74 } else if(operation == ASN1_OP_FREE_PRE) { |
74 DH_free((DH *)*pval); | 75 DH_free((DH *)*pval); |
75 *pval = NULL; | 76 *pval = NULL; |
76 return 2; | 77 return 2; |
77 } | 78 } |
78 return 1; | 79 return 1; |
79 } | 80 } |
80 | 81 |
81 ASN1_SEQUENCE_cb(DHparams, dh_cb) = { | 82 ASN1_SEQUENCE_cb(DHparams, dh_cb) = { |
82 ASN1_SIMPLE(DH, p, BIGNUM), | 83 ASN1_SIMPLE(DH, p, BIGNUM), |
83 ASN1_SIMPLE(DH, g, BIGNUM), | 84 ASN1_SIMPLE(DH, g, BIGNUM), |
84 ASN1_OPT(DH, length, ZLONG), | 85 ASN1_OPT(DH, length, ZLONG), |
85 } ASN1_SEQUENCE_END_cb(DH, DHparams) | 86 } ASN1_SEQUENCE_END_cb(DH, DHparams) |
86 | 87 |
87 IMPLEMENT_ASN1_ENCODE_FUNCTIONS_const_fname(DH, DHparams, DHparams) | 88 IMPLEMENT_ASN1_ENCODE_FUNCTIONS_const_fname(DH, DHparams, DHparams) |
| 89 |
| 90 DH *DHparams_dup(DH *dh) |
| 91 { |
| 92 return ASN1_item_dup(ASN1_ITEM_rptr(DHparams), dh); |
| 93 } |
OLD | NEW |