spkac.c (312826) | spkac.c (325337) |
---|---|
1/* apps/spkac.c */ 2 3/* 4 * Written by Dr Stephen N Henson (steve@openssl.org) for the OpenSSL project 5 * 1999. Based on an original idea by Massimiliano Pala (madwolf@openca.org). 6 */ 7/* ==================================================================== | 1/* apps/spkac.c */ 2 3/* 4 * Written by Dr Stephen N Henson (steve@openssl.org) for the OpenSSL project 5 * 1999. Based on an original idea by Massimiliano Pala (madwolf@openca.org). 6 */ 7/* ==================================================================== |
8 * Copyright (c) 1999 The OpenSSL Project. All rights reserved. | 8 * Copyright (c) 1999-2017 The OpenSSL Project. All rights reserved. |
9 * 10 * Redistribution and use in source and binary forms, with or without 11 * modification, are permitted provided that the following conditions 12 * are met: 13 * 14 * 1. Redistributions of source code must retain the above copyright 15 * notice, this list of conditions and the following disclaimer. 16 * --- 163 unchanged lines hidden (view full) --- 180 181 ERR_load_crypto_strings(); 182 if (!app_passwd(bio_err, passargin, NULL, &passin, NULL)) { 183 BIO_printf(bio_err, "Error getting password\n"); 184 goto end; 185 } 186 e = setup_engine(bio_err, engine, 0); 187 | 9 * 10 * Redistribution and use in source and binary forms, with or without 11 * modification, are permitted provided that the following conditions 12 * are met: 13 * 14 * 1. Redistributions of source code must retain the above copyright 15 * notice, this list of conditions and the following disclaimer. 16 * --- 163 unchanged lines hidden (view full) --- 180 181 ERR_load_crypto_strings(); 182 if (!app_passwd(bio_err, passargin, NULL, &passin, NULL)) { 183 BIO_printf(bio_err, "Error getting password\n"); 184 goto end; 185 } 186 e = setup_engine(bio_err, engine, 0); 187 |
188 if (keyfile) { | 188 if (keyfile != NULL) { |
189 pkey = load_key(bio_err, 190 strcmp(keyfile, "-") ? keyfile : NULL, 191 FORMAT_PEM, 1, passin, e, "private key"); | 189 pkey = load_key(bio_err, 190 strcmp(keyfile, "-") ? keyfile : NULL, 191 FORMAT_PEM, 1, passin, e, "private key"); |
192 if (!pkey) { | 192 if (pkey == NULL) |
193 goto end; | 193 goto end; |
194 } | |
195 spki = NETSCAPE_SPKI_new(); | 194 spki = NETSCAPE_SPKI_new(); |
196 if (challenge) | 195 if (spki == NULL) 196 goto end; 197 if (challenge != NULL) |
197 ASN1_STRING_set(spki->spkac->challenge, 198 challenge, (int)strlen(challenge)); 199 NETSCAPE_SPKI_set_pubkey(spki, pkey); 200 NETSCAPE_SPKI_sign(spki, pkey, EVP_md5()); 201 spkstr = NETSCAPE_SPKI_b64_encode(spki); | 198 ASN1_STRING_set(spki->spkac->challenge, 199 challenge, (int)strlen(challenge)); 200 NETSCAPE_SPKI_set_pubkey(spki, pkey); 201 NETSCAPE_SPKI_sign(spki, pkey, EVP_md5()); 202 spkstr = NETSCAPE_SPKI_b64_encode(spki); |
203 if (spkstr == NULL) 204 goto end; |
|
202 203 if (outfile) 204 out = BIO_new_file(outfile, "w"); 205 else { 206 out = BIO_new_fp(stdout, BIO_NOCLOSE); 207#ifdef OPENSSL_SYS_VMS 208 { 209 BIO *tmpbio = BIO_new(BIO_f_linebuffer()); --- 38 unchanged lines hidden (view full) --- 248 if (!spkstr) { 249 BIO_printf(bio_err, "Can't find SPKAC called \"%s\"\n", spkac); 250 ERR_print_errors(bio_err); 251 goto end; 252 } 253 254 spki = NETSCAPE_SPKI_b64_decode(spkstr, -1); 255 | 205 206 if (outfile) 207 out = BIO_new_file(outfile, "w"); 208 else { 209 out = BIO_new_fp(stdout, BIO_NOCLOSE); 210#ifdef OPENSSL_SYS_VMS 211 { 212 BIO *tmpbio = BIO_new(BIO_f_linebuffer()); --- 38 unchanged lines hidden (view full) --- 251 if (!spkstr) { 252 BIO_printf(bio_err, "Can't find SPKAC called \"%s\"\n", spkac); 253 ERR_print_errors(bio_err); 254 goto end; 255 } 256 257 spki = NETSCAPE_SPKI_b64_decode(spkstr, -1); 258 |
256 if (!spki) { | 259 if (spki == NULL) { |
257 BIO_printf(bio_err, "Error loading SPKAC\n"); 258 ERR_print_errors(bio_err); 259 goto end; 260 } 261 262 if (outfile) 263 out = BIO_new_file(outfile, "w"); 264 else { --- 12 unchanged lines hidden (view full) --- 277 goto end; 278 } 279 280 if (!noout) 281 NETSCAPE_SPKI_print(out, spki); 282 pkey = NETSCAPE_SPKI_get_pubkey(spki); 283 if (verify) { 284 i = NETSCAPE_SPKI_verify(spki, pkey); | 260 BIO_printf(bio_err, "Error loading SPKAC\n"); 261 ERR_print_errors(bio_err); 262 goto end; 263 } 264 265 if (outfile) 266 out = BIO_new_file(outfile, "w"); 267 else { --- 12 unchanged lines hidden (view full) --- 280 goto end; 281 } 282 283 if (!noout) 284 NETSCAPE_SPKI_print(out, spki); 285 pkey = NETSCAPE_SPKI_get_pubkey(spki); 286 if (verify) { 287 i = NETSCAPE_SPKI_verify(spki, pkey); |
285 if (i > 0) | 288 if (i > 0) { |
286 BIO_printf(bio_err, "Signature OK\n"); | 289 BIO_printf(bio_err, "Signature OK\n"); |
287 else { | 290 } else { |
288 BIO_printf(bio_err, "Signature Failure\n"); 289 ERR_print_errors(bio_err); 290 goto end; 291 } 292 } 293 if (pubkey) 294 PEM_write_bio_PUBKEY(out, pkey); 295 --- 14 unchanged lines hidden --- | 291 BIO_printf(bio_err, "Signature Failure\n"); 292 ERR_print_errors(bio_err); 293 goto end; 294 } 295 } 296 if (pubkey) 297 PEM_write_bio_PUBKEY(out, pkey); 298 --- 14 unchanged lines hidden --- |