OLD | NEW |
1 /* t_spki.c */ | 1 /* t_spki.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 1999. | 3 * project 1999. |
4 */ | 4 */ |
5 /* ==================================================================== | 5 /* ==================================================================== |
6 * Copyright (c) 1999 The OpenSSL Project. All rights reserved. | 6 * Copyright (c) 1999 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: |
(...skipping 64 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
75 EVP_PKEY *pkey; | 75 EVP_PKEY *pkey; |
76 ASN1_IA5STRING *chal; | 76 ASN1_IA5STRING *chal; |
77 int i, n; | 77 int i, n; |
78 char *s; | 78 char *s; |
79 BIO_printf(out, "Netscape SPKI:\n"); | 79 BIO_printf(out, "Netscape SPKI:\n"); |
80 i=OBJ_obj2nid(spki->spkac->pubkey->algor->algorithm); | 80 i=OBJ_obj2nid(spki->spkac->pubkey->algor->algorithm); |
81 BIO_printf(out," Public Key Algorithm: %s\n", | 81 BIO_printf(out," Public Key Algorithm: %s\n", |
82 (i == NID_undef)?"UNKNOWN":OBJ_nid2ln(i)); | 82 (i == NID_undef)?"UNKNOWN":OBJ_nid2ln(i)); |
83 pkey = X509_PUBKEY_get(spki->spkac->pubkey); | 83 pkey = X509_PUBKEY_get(spki->spkac->pubkey); |
84 if(!pkey) BIO_printf(out, " Unable to load public key\n"); | 84 if(!pkey) BIO_printf(out, " Unable to load public key\n"); |
85 » else { | 85 » else |
86 #ifndef OPENSSL_NO_RSA | |
87 » » if (pkey->type == EVP_PKEY_RSA) | |
88 » » » { | |
89 » » » BIO_printf(out," RSA Public Key: (%d bit)\n", | |
90 » » » » BN_num_bits(pkey->pkey.rsa->n)); | |
91 » » » RSA_print(out,pkey->pkey.rsa,2); | |
92 » » » } | |
93 » » else | |
94 #endif | |
95 #ifndef OPENSSL_NO_DSA | |
96 » » if (pkey->type == EVP_PKEY_DSA) | |
97 { | 86 { |
98 » » BIO_printf(out," DSA Public Key:\n"); | 87 » » EVP_PKEY_print_public(out, pkey, 4, NULL); |
99 » » DSA_print(out,pkey->pkey.dsa,2); | 88 » » EVP_PKEY_free(pkey); |
100 } | 89 } |
101 else | |
102 #endif | |
103 #ifndef OPENSSL_NO_EC | |
104 if (pkey->type == EVP_PKEY_EC) | |
105 { | |
106 BIO_printf(out, " EC Public Key:\n"); | |
107 EC_KEY_print(out, pkey->pkey.ec,2); | |
108 } | |
109 else | |
110 #endif | |
111 | |
112 BIO_printf(out," Unknown Public Key:\n"); | |
113 EVP_PKEY_free(pkey); | |
114 } | |
115 chal = spki->spkac->challenge; | 90 chal = spki->spkac->challenge; |
116 if(chal->length) | 91 if(chal->length) |
117 BIO_printf(out, " Challenge String: %s\n", chal->data); | 92 BIO_printf(out, " Challenge String: %s\n", chal->data); |
118 i=OBJ_obj2nid(spki->sig_algor->algorithm); | 93 i=OBJ_obj2nid(spki->sig_algor->algorithm); |
119 BIO_printf(out," Signature Algorithm: %s", | 94 BIO_printf(out," Signature Algorithm: %s", |
120 (i == NID_undef)?"UNKNOWN":OBJ_nid2ln(i)); | 95 (i == NID_undef)?"UNKNOWN":OBJ_nid2ln(i)); |
121 | 96 |
122 n=spki->signature->length; | 97 n=spki->signature->length; |
123 s=(char *)spki->signature->data; | 98 s=(char *)spki->signature->data; |
124 for (i=0; i<n; i++) | 99 for (i=0; i<n; i++) |
125 { | 100 { |
126 if ((i%18) == 0) BIO_write(out,"\n ",7); | 101 if ((i%18) == 0) BIO_write(out,"\n ",7); |
127 BIO_printf(out,"%02x%s",(unsigned char)s[i], | 102 BIO_printf(out,"%02x%s",(unsigned char)s[i], |
128 ((i+1) == n)?"":":"); | 103 ((i+1) == n)?"":":"); |
129 } | 104 } |
130 BIO_write(out,"\n",1); | 105 BIO_write(out,"\n",1); |
131 return 1; | 106 return 1; |
132 } | 107 } |
OLD | NEW |