| OLD | NEW |
| 1 /* rsa_asn1.c */ | 1 /* rsa_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 38 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 55 * Hudson (tjh@cryptsoft.com). | 55 * Hudson (tjh@cryptsoft.com). |
| 56 * | 56 * |
| 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/rsa.h> | 62 #include <openssl/rsa.h> |
| 63 #include <openssl/asn1t.h> | 63 #include <openssl/asn1t.h> |
| 64 | 64 |
| 65 static ASN1_METHOD method={ | |
| 66 (I2D_OF(void)) i2d_RSAPrivateKey, | |
| 67 (D2I_OF(void)) d2i_RSAPrivateKey, | |
| 68 (void *(*)(void)) RSA_new, | |
| 69 (void (*)(void *)) RSA_free}; | |
| 70 | |
| 71 ASN1_METHOD *RSAPrivateKey_asn1_meth(void) | |
| 72 { | |
| 73 return(&method); | |
| 74 } | |
| 75 | |
| 76 /* Override the default free and new methods */ | 65 /* Override the default free and new methods */ |
| 77 static int rsa_cb(int operation, ASN1_VALUE **pval, const ASN1_ITEM *it) | 66 static int rsa_cb(int operation, ASN1_VALUE **pval, const ASN1_ITEM *it, |
| 67 » » » » » » » » void *exarg) |
| 78 { | 68 { |
| 79 if(operation == ASN1_OP_NEW_PRE) { | 69 if(operation == ASN1_OP_NEW_PRE) { |
| 80 *pval = (ASN1_VALUE *)RSA_new(); | 70 *pval = (ASN1_VALUE *)RSA_new(); |
| 81 if(*pval) return 2; | 71 if(*pval) return 2; |
| 82 return 0; | 72 return 0; |
| 83 } else if(operation == ASN1_OP_FREE_PRE) { | 73 } else if(operation == ASN1_OP_FREE_PRE) { |
| 84 RSA_free((RSA *)*pval); | 74 RSA_free((RSA *)*pval); |
| 85 *pval = NULL; | 75 *pval = NULL; |
| 86 return 2; | 76 return 2; |
| 87 } | 77 } |
| (...skipping 24 matching lines...) Expand all Loading... |
| 112 | 102 |
| 113 RSA *RSAPublicKey_dup(RSA *rsa) | 103 RSA *RSAPublicKey_dup(RSA *rsa) |
| 114 { | 104 { |
| 115 return ASN1_item_dup(ASN1_ITEM_rptr(RSAPublicKey), rsa); | 105 return ASN1_item_dup(ASN1_ITEM_rptr(RSAPublicKey), rsa); |
| 116 } | 106 } |
| 117 | 107 |
| 118 RSA *RSAPrivateKey_dup(RSA *rsa) | 108 RSA *RSAPrivateKey_dup(RSA *rsa) |
| 119 { | 109 { |
| 120 return ASN1_item_dup(ASN1_ITEM_rptr(RSAPrivateKey), rsa); | 110 return ASN1_item_dup(ASN1_ITEM_rptr(RSAPrivateKey), rsa); |
| 121 } | 111 } |
| OLD | NEW |