Merge the remainder of the projects/openssl111 branch to head.
- Update OpenSSL to version 1.1.1. - Update Kerberos/Heimdal API for OpenSSL 1.1.1 compatibility. - Bump __FreeBSD_version. Approved by: re (kib) Sponsored by: The FreeBSD Foundation
This commit is contained in:
commit
1da7787f71
@ -38,6 +38,229 @@
|
||||
# xargs -n1 | sort | uniq -d;
|
||||
# done
|
||||
|
||||
# 20181009: OpenSSL 1.1.1
|
||||
OLD_FILES+=usr/include/openssl/des_old.h
|
||||
OLD_FILES+=usr/include/openssl/dso.h
|
||||
OLD_FILES+=usr/include/openssl/krb5_asn.h
|
||||
OLD_FILES+=usr/include/openssl/kssl.h
|
||||
OLD_FILES+=usr/include/openssl/pqueue.h
|
||||
OLD_FILES+=usr/include/openssl/ssl23.h
|
||||
OLD_FILES+=usr/include/openssl/ui_compat.h
|
||||
OLD_FILES+=usr/share/openssl/man/man1/dss1.1.gz
|
||||
OLD_FILES+=usr/share/openssl/man/man1/md2.1.gz
|
||||
OLD_FILES+=usr/share/openssl/man/man1/md4.1.gz
|
||||
OLD_FILES+=usr/share/openssl/man/man1/md5.1.gz
|
||||
OLD_FILES+=usr/share/openssl/man/man1/mdc2.1.gz
|
||||
OLD_FILES+=usr/share/openssl/man/man1/ripemd160.1.gz
|
||||
OLD_FILES+=usr/share/openssl/man/man1/sha.1.gz
|
||||
OLD_FILES+=usr/share/openssl/man/man1/sha1.1.gz
|
||||
OLD_FILES+=usr/share/openssl/man/man1/sha224.1.gz
|
||||
OLD_FILES+=usr/share/openssl/man/man1/sha256.1.gz
|
||||
OLD_FILES+=usr/share/openssl/man/man1/sha384.1.gz
|
||||
OLD_FILES+=usr/share/openssl/man/man1/sha512.1.gz
|
||||
OLD_FILES+=usr/share/openssl/man/man1/x509v3_config.1.gz
|
||||
OLD_FILES+=usr/share/openssl/man/man3/ASN1_STRING_length_set.3.gz
|
||||
OLD_FILES+=usr/share/openssl/man/man3/BIO_get_conn_int_port.3.gz
|
||||
OLD_FILES+=usr/share/openssl/man/man3/BIO_get_conn_ip.3.gz
|
||||
OLD_FILES+=usr/share/openssl/man/man3/BIO_set.3.gz
|
||||
OLD_FILES+=usr/share/openssl/man/man3/BIO_set_conn_int_port.3.gz
|
||||
OLD_FILES+=usr/share/openssl/man/man3/BIO_set_conn_ip.3.gz
|
||||
OLD_FILES+=usr/share/openssl/man/man3/BN_BLINDING_get_thread_id.3.gz
|
||||
OLD_FILES+=usr/share/openssl/man/man3/BN_BLINDING_set_thread_id.3.gz
|
||||
OLD_FILES+=usr/share/openssl/man/man3/BN_BLINDING_thread_id.3.gz
|
||||
OLD_FILES+=usr/share/openssl/man/man3/BN_CTX_init.3.gz
|
||||
OLD_FILES+=usr/share/openssl/man/man3/BN_MONT_CTX_init.3.gz
|
||||
OLD_FILES+=usr/share/openssl/man/man3/BN_RECP_CTX_init.3.gz
|
||||
OLD_FILES+=usr/share/openssl/man/man3/BN_init.3.gz
|
||||
OLD_FILES+=usr/share/openssl/man/man3/BUF_memdup.3.gz
|
||||
OLD_FILES+=usr/share/openssl/man/man3/BUF_memdup.3.gz
|
||||
OLD_FILES+=usr/share/openssl/man/man3/BUF_strdup.3.gz
|
||||
OLD_FILES+=usr/share/openssl/man/man3/BUF_strlcat.3.gz
|
||||
OLD_FILES+=usr/share/openssl/man/man3/BUF_strlcpy.3.gz
|
||||
OLD_FILES+=usr/share/openssl/man/man3/BUF_strndup.3.gz
|
||||
OLD_FILES+=usr/share/openssl/man/man3/CMS_set1_signer_cert.3.gz
|
||||
OLD_FILES+=usr/share/openssl/man/man3/CRYPTO_THREADID_cmp.3.gz
|
||||
OLD_FILES+=usr/share/openssl/man/man3/CRYPTO_THREADID_cpy.3.gz
|
||||
OLD_FILES+=usr/share/openssl/man/man3/CRYPTO_THREADID_current.3.gz
|
||||
OLD_FILES+=usr/share/openssl/man/man3/CRYPTO_THREADID_get_callback.3.gz
|
||||
OLD_FILES+=usr/share/openssl/man/man3/CRYPTO_THREADID_hash.3.gz
|
||||
OLD_FILES+=usr/share/openssl/man/man3/CRYPTO_THREADID_set_callback.3.gz
|
||||
OLD_FILES+=usr/share/openssl/man/man3/CRYPTO_destroy_dynlockid.3.gz
|
||||
OLD_FILES+=usr/share/openssl/man/man3/CRYPTO_get_new_dynlockid.3.gz
|
||||
OLD_FILES+=usr/share/openssl/man/man3/CRYPTO_lock.3.gz
|
||||
OLD_FILES+=usr/share/openssl/man/man3/CRYPTO_num_locks.3.gz
|
||||
OLD_FILES+=usr/share/openssl/man/man3/CRYPTO_set_dynlock_create_callback.3.gz
|
||||
OLD_FILES+=usr/share/openssl/man/man3/CRYPTO_set_dynlock_destroy_callback.3.gz
|
||||
OLD_FILES+=usr/share/openssl/man/man3/CRYPTO_set_dynlock_lock_callback.3.gz
|
||||
OLD_FILES+=usr/share/openssl/man/man3/CRYPTO_set_locking_callback.3.gz
|
||||
OLD_FILES+=usr/share/openssl/man/man3/DES_ede3_cbcm_encrypt.3.gz
|
||||
OLD_FILES+=usr/share/openssl/man/man3/DES_enc_read.3.gz
|
||||
OLD_FILES+=usr/share/openssl/man/man3/DES_enc_write.3.gz
|
||||
OLD_FILES+=usr/share/openssl/man/man3/EC_KEY_get_key_method_data.3.gz
|
||||
OLD_FILES+=usr/share/openssl/man/man3/EC_KEY_insert_key_method_data.3.gz
|
||||
OLD_FILES+=usr/share/openssl/man/man3/EC_POINT_set_Jprojective_coordinates.3.gz
|
||||
OLD_FILES+=usr/share/openssl/man/man3/ERR_load_UI_strings.3.gz
|
||||
OLD_FILES+=usr/share/openssl/man/man3/EVP_CIPHER_CTX_cleanup.3.gz
|
||||
OLD_FILES+=usr/share/openssl/man/man3/EVP_CIPHER_CTX_init.3.gz
|
||||
OLD_FILES+=usr/share/openssl/man/man3/EVP_MAX_MD_SIZE.3.gz
|
||||
OLD_FILES+=usr/share/openssl/man/man3/EVP_MD_CTX_cleanup.3.gz
|
||||
OLD_FILES+=usr/share/openssl/man/man3/EVP_MD_CTX_create.3.gz
|
||||
OLD_FILES+=usr/share/openssl/man/man3/EVP_MD_CTX_destroy.3.gz
|
||||
OLD_FILES+=usr/share/openssl/man/man3/EVP_MD_CTX_init.3.gz
|
||||
OLD_FILES+=usr/share/openssl/man/man3/EVP_PKEVP_PKEY_CTX_set_app_data.3.gz
|
||||
OLD_FILES+=usr/share/openssl/man/man3/EVP_PKEY_CTX_set_rsa_rsa_keygen_bits.3.gz
|
||||
OLD_FILES+=usr/share/openssl/man/man3/EVP_PKEY_get_default_digest.3.gz
|
||||
OLD_FILES+=usr/share/openssl/man/man3/EVP_dss.3.gz
|
||||
OLD_FILES+=usr/share/openssl/man/man3/EVP_dss1.3.gz
|
||||
OLD_FILES+=usr/share/openssl/man/man3/EVP_sha.3.gz
|
||||
OLD_FILES+=usr/share/openssl/man/man3/HMAC_CTX_cleanup.3.gz
|
||||
OLD_FILES+=usr/share/openssl/man/man3/HMAC_CTX_init.3.gz
|
||||
OLD_FILES+=usr/share/openssl/man/man3/HMAC_cleanup.3.gz
|
||||
OLD_FILES+=usr/share/openssl/man/man3/OPENSSL_ia32cap_loc.3.gz
|
||||
OLD_FILES+=usr/share/openssl/man/man3/PEM.3.gz
|
||||
OLD_FILES+=usr/share/openssl/man/man3/RAND_SSLeay.3.gz
|
||||
OLD_FILES+=usr/share/openssl/man/man3/RSA_PKCS1_SSLeay.3.gz
|
||||
OLD_FILES+=usr/share/openssl/man/man3/RSA_null_method.3.gz
|
||||
OLD_FILES+=usr/share/openssl/man/man3/SSL.3.gz
|
||||
OLD_FILES+=usr/share/openssl/man/man3/SSL_CTX_get_ex_new_index.3.gz
|
||||
OLD_FILES+=usr/share/openssl/man/man3/SSL_CTX_need_tmp_rsa.3.gz
|
||||
OLD_FILES+=usr/share/openssl/man/man3/SSL_CTX_set_custom_cli_ext.3.gz
|
||||
OLD_FILES+=usr/share/openssl/man/man3/SSL_CTX_set_default_read_ahead.3.gz
|
||||
OLD_FILES+=usr/share/openssl/man/man3/SSL_CTX_set_ecdh_auto.3.gz
|
||||
OLD_FILES+=usr/share/openssl/man/man3/SSL_CTX_set_tmp_rsa.3.gz
|
||||
OLD_FILES+=usr/share/openssl/man/man3/SSL_CTX_set_tmp_rsa_callback.3.gz
|
||||
OLD_FILES+=usr/share/openssl/man/man3/SSL_SESSION_get_ex_new_index.3.gz
|
||||
OLD_FILES+=usr/share/openssl/man/man3/SSL_add_session.3.gz
|
||||
OLD_FILES+=usr/share/openssl/man/man3/SSL_flush_sessions.3.gz
|
||||
OLD_FILES+=usr/share/openssl/man/man3/SSL_get_accept_state.3.gz
|
||||
OLD_FILES+=usr/share/openssl/man/man3/SSL_get_ex_new_index.3.gz
|
||||
OLD_FILES+=usr/share/openssl/man/man3/SSL_get_msg_callback_arg.3.gz
|
||||
OLD_FILES+=usr/share/openssl/man/man3/SSL_need_tmp_rsa.3.gz
|
||||
OLD_FILES+=usr/share/openssl/man/man3/SSL_remove_session.3.gz
|
||||
OLD_FILES+=usr/share/openssl/man/man3/SSL_set_ecdh_auto.3.gz
|
||||
OLD_FILES+=usr/share/openssl/man/man3/SSL_set_tmp_rsa.3.gz
|
||||
OLD_FILES+=usr/share/openssl/man/man3/SSL_set_tmp_rsa_callback.3.gz
|
||||
OLD_FILES+=usr/share/openssl/man/man3/SSLeay.3.gz
|
||||
OLD_FILES+=usr/share/openssl/man/man3/SSLeay_add_ssl_algorithms.3.gz
|
||||
OLD_FILES+=usr/share/openssl/man/man3/SSLeay_version.3.gz
|
||||
OLD_FILES+=usr/share/openssl/man/man3/SSLv2_client_method.3.gz
|
||||
OLD_FILES+=usr/share/openssl/man/man3/SSLv2_method.3.gz
|
||||
OLD_FILES+=usr/share/openssl/man/man3/SSLv2_server_method.3.gz
|
||||
OLD_FILES+=usr/share/openssl/man/man3/X509_STORE_CTX_set_chain.3.gz
|
||||
OLD_FILES+=usr/share/openssl/man/man3/X509_STORE_CTX_trusted_stack.3.gz
|
||||
OLD_FILES+=usr/share/openssl/man/man3/bio.3.gz
|
||||
OLD_FILES+=usr/share/openssl/man/man3/blowfish.3.gz
|
||||
OLD_FILES+=usr/share/openssl/man/man3/bn.3.gz
|
||||
OLD_FILES+=usr/share/openssl/man/man3/bn_add_words.3.gz
|
||||
OLD_FILES+=usr/share/openssl/man/man3/bn_check_top.3.gz
|
||||
OLD_FILES+=usr/share/openssl/man/man3/bn_cmp_words.3.gz
|
||||
OLD_FILES+=usr/share/openssl/man/man3/bn_div_words.3.gz
|
||||
OLD_FILES+=usr/share/openssl/man/man3/bn_dump.3.gz
|
||||
OLD_FILES+=usr/share/openssl/man/man3/bn_expand.3.gz
|
||||
OLD_FILES+=usr/share/openssl/man/man3/bn_expand2.3.gz
|
||||
OLD_FILES+=usr/share/openssl/man/man3/bn_fix_top.3.gz
|
||||
OLD_FILES+=usr/share/openssl/man/man3/bn_internal.3.gz
|
||||
OLD_FILES+=usr/share/openssl/man/man3/bn_mul_add_words.3.gz
|
||||
OLD_FILES+=usr/share/openssl/man/man3/bn_mul_comba4.3.gz
|
||||
OLD_FILES+=usr/share/openssl/man/man3/bn_mul_comba8.3.gz
|
||||
OLD_FILES+=usr/share/openssl/man/man3/bn_mul_high.3.gz
|
||||
OLD_FILES+=usr/share/openssl/man/man3/bn_mul_low_normal.3.gz
|
||||
OLD_FILES+=usr/share/openssl/man/man3/bn_mul_low_recursive.3.gz
|
||||
OLD_FILES+=usr/share/openssl/man/man3/bn_mul_normal.3.gz
|
||||
OLD_FILES+=usr/share/openssl/man/man3/bn_mul_part_recursive.3.gz
|
||||
OLD_FILES+=usr/share/openssl/man/man3/bn_mul_recursive.3.gz
|
||||
OLD_FILES+=usr/share/openssl/man/man3/bn_mul_words.3.gz
|
||||
OLD_FILES+=usr/share/openssl/man/man3/bn_print.3.gz
|
||||
OLD_FILES+=usr/share/openssl/man/man3/bn_set_high.3.gz
|
||||
OLD_FILES+=usr/share/openssl/man/man3/bn_set_low.3.gz
|
||||
OLD_FILES+=usr/share/openssl/man/man3/bn_set_max.3.gz
|
||||
OLD_FILES+=usr/share/openssl/man/man3/bn_sqr_comba4.3.gz
|
||||
OLD_FILES+=usr/share/openssl/man/man3/bn_sqr_comba8.3.gz
|
||||
OLD_FILES+=usr/share/openssl/man/man3/bn_sqr_normal.3.gz
|
||||
OLD_FILES+=usr/share/openssl/man/man3/bn_sqr_recursive.3.gz
|
||||
OLD_FILES+=usr/share/openssl/man/man3/bn_sqr_words.3.gz
|
||||
OLD_FILES+=usr/share/openssl/man/man3/bn_sub_words.3.gz
|
||||
OLD_FILES+=usr/share/openssl/man/man3/bn_wexpand.3.gz
|
||||
OLD_FILES+=usr/share/openssl/man/man3/buffer.3.gz
|
||||
OLD_FILES+=usr/share/openssl/man/man3/crypto.3.gz
|
||||
OLD_FILES+=usr/share/openssl/man/man3/d2i_ECPKParameters_bio.3.gz
|
||||
OLD_FILES+=usr/share/openssl/man/man3/d2i_ECPKParameters_fp.3.gz
|
||||
OLD_FILES+=usr/share/openssl/man/man3/d2i_ECPrivate_key.3.gz
|
||||
OLD_FILES+=usr/share/openssl/man/man3/d2i_Netscape_RSA.3.gz
|
||||
OLD_FILES+=usr/share/openssl/man/man3/d2i_PKCS8PrivateKey.3.gz
|
||||
OLD_FILES+=usr/share/openssl/man/man3/d2i_Private_key.3.gz
|
||||
OLD_FILES+=usr/share/openssl/man/man3/d2i_X509_bio.3.gz
|
||||
OLD_FILES+=usr/share/openssl/man/man3/d2i_X509_fp.3.gz
|
||||
OLD_FILES+=usr/share/openssl/man/man3/des.3.gz
|
||||
OLD_FILES+=usr/share/openssl/man/man3/des_read_2passwords.3.gz
|
||||
OLD_FILES+=usr/share/openssl/man/man3/des_read_password.3.gz
|
||||
OLD_FILES+=usr/share/openssl/man/man3/des_read_pw.3.gz
|
||||
OLD_FILES+=usr/share/openssl/man/man3/des_read_pw_string.3.gz
|
||||
OLD_FILES+=usr/share/openssl/man/man3/dh.3.gz
|
||||
OLD_FILES+=usr/share/openssl/man/man3/dsa.3.gz
|
||||
OLD_FILES+=usr/share/openssl/man/man3/ec.3.gz
|
||||
OLD_FILES+=usr/share/openssl/man/man3/ecdsa.3.gz
|
||||
OLD_FILES+=usr/share/openssl/man/man3/engine.3.gz
|
||||
OLD_FILES+=usr/share/openssl/man/man3/err.3.gz
|
||||
OLD_FILES+=usr/share/openssl/man/man3/evp.3.gz
|
||||
OLD_FILES+=usr/share/openssl/man/man3/hmac.3.gz
|
||||
OLD_FILES+=usr/share/openssl/man/man3/i2d_ECPKParameters_bio.3.gz
|
||||
OLD_FILES+=usr/share/openssl/man/man3/i2d_ECPKParameters_fp.3.gz
|
||||
OLD_FILES+=usr/share/openssl/man/man3/i2d_Netscape_RSA.3.gz
|
||||
OLD_FILES+=usr/share/openssl/man/man3/i2d_X509_bio.3.gz
|
||||
OLD_FILES+=usr/share/openssl/man/man3/i2d_X509_fp.3.gz
|
||||
OLD_FILES+=usr/share/openssl/man/man3/lh_delete.3.gz
|
||||
OLD_FILES+=usr/share/openssl/man/man3/lh_doall.3.gz
|
||||
OLD_FILES+=usr/share/openssl/man/man3/lh_doall_arg.3.gz
|
||||
OLD_FILES+=usr/share/openssl/man/man3/lh_error.3.gz
|
||||
OLD_FILES+=usr/share/openssl/man/man3/lh_free.3.gz
|
||||
OLD_FILES+=usr/share/openssl/man/man3/lh_insert.3.gz
|
||||
OLD_FILES+=usr/share/openssl/man/man3/lh_new.3.gz
|
||||
OLD_FILES+=usr/share/openssl/man/man3/lh_node_stats.3.gz
|
||||
OLD_FILES+=usr/share/openssl/man/man3/lh_node_stats_bio.3.gz
|
||||
OLD_FILES+=usr/share/openssl/man/man3/lh_node_usage_stats.3.gz
|
||||
OLD_FILES+=usr/share/openssl/man/man3/lh_node_usage_stats_bio.3.gz
|
||||
OLD_FILES+=usr/share/openssl/man/man3/lh_retrieve.3.gz
|
||||
OLD_FILES+=usr/share/openssl/man/man3/lh_stats.3.gz
|
||||
OLD_FILES+=usr/share/openssl/man/man3/lh_stats_bio.3.gz
|
||||
OLD_FILES+=usr/share/openssl/man/man3/lhash.3.gz
|
||||
OLD_FILES+=usr/share/openssl/man/man3/md5.3.gz
|
||||
OLD_FILES+=usr/share/openssl/man/man3/mdc2.3.gz
|
||||
OLD_FILES+=usr/share/openssl/man/man3/pem.3.gz
|
||||
OLD_FILES+=usr/share/openssl/man/man3/rand.3.gz
|
||||
OLD_FILES+=usr/share/openssl/man/man3/rc4.3.gz
|
||||
OLD_FILES+=usr/share/openssl/man/man3/ripemd.3.gz
|
||||
OLD_FILES+=usr/share/openssl/man/man3/rsa.3.gz
|
||||
OLD_FILES+=usr/share/openssl/man/man3/sha.3.gz
|
||||
OLD_FILES+=usr/share/openssl/man/man3/ssl.3.gz
|
||||
OLD_FILES+=usr/share/openssl/man/man3/threads.3.gz
|
||||
OLD_FILES+=usr/share/openssl/man/man3/ui.3.gz
|
||||
OLD_FILES+=usr/share/openssl/man/man3/ui_compat.3.gz
|
||||
OLD_FILES+=usr/share/openssl/man/man3/x509.3.gz
|
||||
OLD_LIBS+=lib/libcrypto.so.8
|
||||
OLD_LIBS+=usr/lib/engines/lib4758cca.so
|
||||
OLD_LIBS+=usr/lib/engines/libaep.so
|
||||
OLD_LIBS+=usr/lib/engines/libatalla.so
|
||||
OLD_LIBS+=usr/lib/engines/libcapi.so
|
||||
OLD_LIBS+=usr/lib/engines/libchil.so
|
||||
OLD_LIBS+=usr/lib/engines/libcswift.so
|
||||
OLD_LIBS+=usr/lib/engines/libgost.so
|
||||
OLD_LIBS+=usr/lib/engines/libnuron.so
|
||||
OLD_LIBS+=usr/lib/engines/libsureware.so
|
||||
OLD_LIBS+=usr/lib/engines/libubsec.so
|
||||
OLD_LIBS+=usr/lib/libssl.so.8
|
||||
OLD_LIBS+=usr/lib32/libcrypto.so.8
|
||||
OLD_LIBS+=usr/lib32/lib4758cca.so
|
||||
OLD_LIBS+=usr/lib32/libaep.so
|
||||
OLD_LIBS+=usr/lib32/libatalla.so
|
||||
OLD_LIBS+=usr/lib32/libcapi.so
|
||||
OLD_LIBS+=usr/lib32/libchil.so
|
||||
OLD_LIBS+=usr/lib32/libcswift.so
|
||||
OLD_LIBS+=usr/lib32/libgost.so
|
||||
OLD_LIBS+=usr/lib32/libnuron.so
|
||||
OLD_LIBS+=usr/lib32/libsureware.so
|
||||
OLD_LIBS+=usr/lib32/libubsec.so
|
||||
OLD_LIBS+=usr/lib32/libssl.so.8
|
||||
# 20180824: libbe(3) SHLIBDIR fixed to reflect correct location
|
||||
OLD_LIBS+=usr/lib/libbe.so.1
|
||||
# 20180819: Remove deprecated arc4random(3) stir/addrandom interfaces
|
||||
|
6
UPDATING
6
UPDATING
@ -31,6 +31,12 @@ NOTE TO PEOPLE WHO THINK THAT FreeBSD 12.x IS SLOW:
|
||||
disable the most expensive debugging functionality run
|
||||
"ln -s 'abort:false,junk:false' /etc/malloc.conf".)
|
||||
|
||||
20181009:
|
||||
OpenSSL has been updated to version 1.1.1. This update included
|
||||
additional various API changes througout the base system. It is
|
||||
important to rebuild third-party software after upgrading. The value
|
||||
of __FreeBSD_version has been bumped accordingly.
|
||||
|
||||
20181006:
|
||||
The legacy DRM modules and drivers have now been added to the loader's
|
||||
module blacklist, in favor of loading them with kld_list in rc.conf(5).
|
||||
|
@ -94,9 +94,14 @@ snmp_pdu_calc_digest(const struct snmp_pdu *pdu, uint8_t *digest)
|
||||
uint32_t i, keylen, olen;
|
||||
int32_t err;
|
||||
const EVP_MD *dtype;
|
||||
EVP_MD_CTX ctx;
|
||||
EVP_MD_CTX *ctx;
|
||||
|
||||
err = snmp_digest_init(&pdu->user, &ctx, &dtype, &keylen);
|
||||
ctx = EVP_MD_CTX_new();
|
||||
if (ctx == NULL)
|
||||
return (SNMP_CODE_FAILED);
|
||||
err = snmp_digest_init(&pdu->user, ctx, &dtype, &keylen);
|
||||
if (err <= 0)
|
||||
EVP_MD_CTX_free(ctx);
|
||||
if (err < 0)
|
||||
return (SNMP_CODE_BADDIGEST);
|
||||
else if (err == 0)
|
||||
@ -111,29 +116,29 @@ snmp_pdu_calc_digest(const struct snmp_pdu *pdu, uint8_t *digest)
|
||||
key2[i] = extkey[i] ^ opad;
|
||||
}
|
||||
|
||||
if (EVP_DigestUpdate(&ctx, key1, SNMP_EXTENDED_KEY_SIZ) != 1 ||
|
||||
EVP_DigestUpdate(&ctx, pdu->outer_ptr, pdu->outer_len) != 1 ||
|
||||
EVP_DigestFinal(&ctx, md, &olen) != 1)
|
||||
if (EVP_DigestUpdate(ctx, key1, SNMP_EXTENDED_KEY_SIZ) != 1 ||
|
||||
EVP_DigestUpdate(ctx, pdu->outer_ptr, pdu->outer_len) != 1 ||
|
||||
EVP_DigestFinal(ctx, md, &olen) != 1)
|
||||
goto failed;
|
||||
|
||||
if (EVP_DigestInit(&ctx, dtype) != 1 ||
|
||||
EVP_DigestUpdate(&ctx, key2, SNMP_EXTENDED_KEY_SIZ) != 1 ||
|
||||
EVP_DigestUpdate(&ctx, md, olen) != 1 ||
|
||||
EVP_DigestFinal(&ctx, md, &olen) != 1)
|
||||
if (EVP_DigestInit(ctx, dtype) != 1 ||
|
||||
EVP_DigestUpdate(ctx, key2, SNMP_EXTENDED_KEY_SIZ) != 1 ||
|
||||
EVP_DigestUpdate(ctx, md, olen) != 1 ||
|
||||
EVP_DigestFinal(ctx, md, &olen) != 1)
|
||||
goto failed;
|
||||
|
||||
if (olen < SNMP_USM_AUTH_SIZE) {
|
||||
snmp_error("bad digest size - %d", olen);
|
||||
EVP_MD_CTX_cleanup(&ctx);
|
||||
EVP_MD_CTX_free(ctx);
|
||||
return (SNMP_CODE_BADDIGEST);
|
||||
}
|
||||
|
||||
memcpy(digest, md, SNMP_USM_AUTH_SIZE);
|
||||
EVP_MD_CTX_cleanup(&ctx);
|
||||
EVP_MD_CTX_free(ctx);
|
||||
return (SNMP_CODE_OK);
|
||||
|
||||
failed:
|
||||
EVP_MD_CTX_cleanup(&ctx);
|
||||
EVP_MD_CTX_free(ctx);
|
||||
return (SNMP_CODE_BADDIGEST);
|
||||
}
|
||||
|
||||
@ -176,7 +181,7 @@ snmp_pdu_encrypt(const struct snmp_pdu *pdu)
|
||||
int32_t err, olen;
|
||||
uint8_t iv[SNMP_PRIV_AES_IV_SIZ];
|
||||
const EVP_CIPHER *ctype;
|
||||
EVP_CIPHER_CTX ctx;
|
||||
EVP_CIPHER_CTX *ctx;
|
||||
|
||||
err = snmp_pdu_cipher_init(pdu, pdu->scoped_len, &ctype, iv);
|
||||
if (err < 0)
|
||||
@ -184,18 +189,23 @@ snmp_pdu_encrypt(const struct snmp_pdu *pdu)
|
||||
else if (err == 0)
|
||||
return (SNMP_CODE_OK);
|
||||
|
||||
if (EVP_EncryptInit(&ctx, ctype, pdu->user.priv_key, iv) != 1)
|
||||
ctx = EVP_CIPHER_CTX_new();
|
||||
if (ctx == NULL)
|
||||
return (SNMP_CODE_FAILED);
|
||||
if (EVP_EncryptInit(ctx, ctype, pdu->user.priv_key, iv) != 1)
|
||||
goto failed;
|
||||
|
||||
if (EVP_EncryptUpdate(&ctx, pdu->scoped_ptr, &olen, pdu->scoped_ptr,
|
||||
if (EVP_EncryptUpdate(ctx, pdu->scoped_ptr, &olen, pdu->scoped_ptr,
|
||||
pdu->scoped_len) != 1 ||
|
||||
EVP_EncryptFinal(&ctx, pdu->scoped_ptr + olen, &olen) != 1) {
|
||||
EVP_CIPHER_CTX_cleanup(&ctx);
|
||||
return (SNMP_CODE_FAILED);
|
||||
}
|
||||
EVP_EncryptFinal(ctx, pdu->scoped_ptr + olen, &olen) != 1)
|
||||
goto failed;
|
||||
|
||||
EVP_CIPHER_CTX_cleanup(&ctx);
|
||||
EVP_CIPHER_CTX_free(ctx);
|
||||
return (SNMP_CODE_OK);
|
||||
|
||||
failed:
|
||||
EVP_CIPHER_CTX_free(ctx);
|
||||
return (SNMP_CODE_FAILED);
|
||||
}
|
||||
|
||||
enum snmp_code
|
||||
@ -204,7 +214,7 @@ snmp_pdu_decrypt(const struct snmp_pdu *pdu)
|
||||
int32_t err, olen;
|
||||
uint8_t iv[SNMP_PRIV_AES_IV_SIZ];
|
||||
const EVP_CIPHER *ctype;
|
||||
EVP_CIPHER_CTX ctx;
|
||||
EVP_CIPHER_CTX *ctx;
|
||||
|
||||
err = snmp_pdu_cipher_init(pdu, pdu->scoped_len, &ctype, iv);
|
||||
if (err < 0)
|
||||
@ -212,19 +222,24 @@ snmp_pdu_decrypt(const struct snmp_pdu *pdu)
|
||||
else if (err == 0)
|
||||
return (SNMP_CODE_OK);
|
||||
|
||||
if (EVP_DecryptInit(&ctx, ctype, pdu->user.priv_key, iv) != 1 ||
|
||||
EVP_CIPHER_CTX_set_padding(&ctx, 0) != 1)
|
||||
return (SNMP_CODE_EDECRYPT);
|
||||
ctx = EVP_CIPHER_CTX_new();
|
||||
if (ctx == NULL)
|
||||
return (SNMP_CODE_FAILED);
|
||||
if (EVP_DecryptInit(ctx, ctype, pdu->user.priv_key, iv) != 1 ||
|
||||
EVP_CIPHER_CTX_set_padding(ctx, 0) != 1)
|
||||
goto failed;
|
||||
|
||||
if (EVP_DecryptUpdate(&ctx, pdu->scoped_ptr, &olen, pdu->scoped_ptr,
|
||||
if (EVP_DecryptUpdate(ctx, pdu->scoped_ptr, &olen, pdu->scoped_ptr,
|
||||
pdu->scoped_len) != 1 ||
|
||||
EVP_DecryptFinal(&ctx, pdu->scoped_ptr + olen, &olen) != 1) {
|
||||
EVP_CIPHER_CTX_cleanup(&ctx);
|
||||
return (SNMP_CODE_EDECRYPT);
|
||||
}
|
||||
EVP_DecryptFinal(ctx, pdu->scoped_ptr + olen, &olen) != 1)
|
||||
goto failed;
|
||||
|
||||
EVP_CIPHER_CTX_cleanup(&ctx);
|
||||
EVP_CIPHER_CTX_free(ctx);
|
||||
return (SNMP_CODE_OK);
|
||||
|
||||
failed:
|
||||
EVP_CIPHER_CTX_free(ctx);
|
||||
return (SNMP_CODE_EDECRYPT);
|
||||
}
|
||||
|
||||
/* [RFC 3414] - A.2. Password to Key Algorithm */
|
||||
@ -234,13 +249,19 @@ snmp_passwd_to_keys(struct snmp_user *user, char *passwd)
|
||||
int err, loop, i, pwdlen;
|
||||
uint32_t keylen, olen;
|
||||
const EVP_MD *dtype;
|
||||
EVP_MD_CTX ctx;
|
||||
EVP_MD_CTX *ctx;
|
||||
uint8_t authbuf[SNMP_AUTH_BUF_SIZE];
|
||||
|
||||
if (passwd == NULL || user == NULL)
|
||||
return (SNMP_CODE_FAILED);
|
||||
|
||||
err = snmp_digest_init(user, &ctx, &dtype, &keylen);
|
||||
ctx = EVP_MD_CTX_new();
|
||||
if (ctx == NULL)
|
||||
return (SNMP_CODE_FAILED);
|
||||
|
||||
err = snmp_digest_init(user, ctx, &dtype, &keylen);
|
||||
if (err <= 0)
|
||||
EVP_MD_CTX_free(ctx);
|
||||
if (err < 0)
|
||||
return (SNMP_CODE_BADDIGEST);
|
||||
else if (err == 0)
|
||||
@ -252,18 +273,18 @@ snmp_passwd_to_keys(struct snmp_user *user, char *passwd)
|
||||
for (loop = 0; loop < SNMP_AUTH_KEY_LOOPCNT; loop += i) {
|
||||
for (i = 0; i < SNMP_EXTENDED_KEY_SIZ; i++)
|
||||
authbuf[i] = passwd[(loop + i) % pwdlen];
|
||||
if (EVP_DigestUpdate(&ctx, authbuf, SNMP_EXTENDED_KEY_SIZ) != 1)
|
||||
if (EVP_DigestUpdate(ctx, authbuf, SNMP_EXTENDED_KEY_SIZ) != 1)
|
||||
goto failed;
|
||||
}
|
||||
|
||||
if (EVP_DigestFinal(&ctx, user->auth_key, &olen) != 1)
|
||||
if (EVP_DigestFinal(ctx, user->auth_key, &olen) != 1)
|
||||
goto failed;
|
||||
|
||||
EVP_MD_CTX_cleanup(&ctx);
|
||||
EVP_MD_CTX_free(ctx);
|
||||
return (SNMP_CODE_OK);
|
||||
|
||||
failed:
|
||||
EVP_MD_CTX_cleanup(&ctx);
|
||||
EVP_MD_CTX_free(ctx);
|
||||
return (SNMP_CODE_BADDIGEST);
|
||||
}
|
||||
|
||||
@ -274,16 +295,22 @@ snmp_get_local_keys(struct snmp_user *user, uint8_t *eid, uint32_t elen)
|
||||
int err;
|
||||
uint32_t keylen, olen;
|
||||
const EVP_MD *dtype;
|
||||
EVP_MD_CTX ctx;
|
||||
EVP_MD_CTX *ctx;
|
||||
uint8_t authbuf[SNMP_AUTH_BUF_SIZE];
|
||||
|
||||
if (user == NULL || eid == NULL || elen > SNMP_ENGINE_ID_SIZ)
|
||||
return (SNMP_CODE_FAILED);
|
||||
|
||||
ctx = EVP_MD_CTX_new();
|
||||
if (ctx == NULL)
|
||||
return (SNMP_CODE_FAILED);
|
||||
|
||||
memset(user->priv_key, 0, sizeof(user->priv_key));
|
||||
memset(authbuf, 0, sizeof(authbuf));
|
||||
|
||||
err = snmp_digest_init(user, &ctx, &dtype, &keylen);
|
||||
err = snmp_digest_init(user, ctx, &dtype, &keylen);
|
||||
if (err <= 0)
|
||||
EVP_MD_CTX_free(ctx);
|
||||
if (err < 0)
|
||||
return (SNMP_CODE_BADDIGEST);
|
||||
else if (err == 0)
|
||||
@ -293,12 +320,12 @@ snmp_get_local_keys(struct snmp_user *user, uint8_t *eid, uint32_t elen)
|
||||
memcpy(authbuf + keylen, eid, elen);
|
||||
memcpy(authbuf + keylen + elen, user->auth_key, keylen);
|
||||
|
||||
if (EVP_DigestUpdate(&ctx, authbuf, 2 * keylen + elen) != 1 ||
|
||||
EVP_DigestFinal(&ctx, user->auth_key, &olen) != 1) {
|
||||
EVP_MD_CTX_cleanup(&ctx);
|
||||
if (EVP_DigestUpdate(ctx, authbuf, 2 * keylen + elen) != 1 ||
|
||||
EVP_DigestFinal(ctx, user->auth_key, &olen) != 1) {
|
||||
EVP_MD_CTX_free(ctx);
|
||||
return (SNMP_CODE_BADDIGEST);
|
||||
}
|
||||
EVP_MD_CTX_cleanup(&ctx);
|
||||
EVP_MD_CTX_free(ctx);
|
||||
|
||||
if (user->priv_proto != SNMP_PRIV_NOPRIV)
|
||||
memcpy(user->priv_key, user->auth_key, sizeof(user->priv_key));
|
||||
@ -312,9 +339,15 @@ snmp_calc_keychange(struct snmp_user *user, uint8_t *keychange)
|
||||
int32_t err, rvalue[SNMP_AUTH_HMACSHA_KEY_SIZ / 4];
|
||||
uint32_t i, keylen, olen;
|
||||
const EVP_MD *dtype;
|
||||
EVP_MD_CTX ctx;
|
||||
EVP_MD_CTX *ctx;
|
||||
|
||||
err = snmp_digest_init(user, &ctx, &dtype, &keylen);
|
||||
ctx = EVP_MD_CTX_new();
|
||||
if (ctx == NULL)
|
||||
return (SNMP_CODE_FAILED);
|
||||
|
||||
err = snmp_digest_init(user, ctx, &dtype, &keylen);
|
||||
if (err <= 0)
|
||||
EVP_MD_CTX_free(ctx);
|
||||
if (err < 0)
|
||||
return (SNMP_CODE_BADDIGEST);
|
||||
else if (err == 0)
|
||||
@ -326,13 +359,13 @@ snmp_calc_keychange(struct snmp_user *user, uint8_t *keychange)
|
||||
memcpy(keychange, user->auth_key, keylen);
|
||||
memcpy(keychange + keylen, rvalue, keylen);
|
||||
|
||||
if (EVP_DigestUpdate(&ctx, keychange, 2 * keylen) != 1 ||
|
||||
EVP_DigestFinal(&ctx, keychange, &olen) != 1) {
|
||||
EVP_MD_CTX_cleanup(&ctx);
|
||||
if (EVP_DigestUpdate(ctx, keychange, 2 * keylen) != 1 ||
|
||||
EVP_DigestFinal(ctx, keychange, &olen) != 1) {
|
||||
EVP_MD_CTX_free(ctx);
|
||||
return (SNMP_CODE_BADDIGEST);
|
||||
}
|
||||
|
||||
EVP_MD_CTX_cleanup(&ctx);
|
||||
EVP_MD_CTX_free(ctx);
|
||||
return (SNMP_CODE_OK);
|
||||
}
|
||||
|
||||
|
@ -40,6 +40,7 @@
|
||||
#include <openssl/pem.h>
|
||||
#include <openssl/rand.h>
|
||||
|
||||
#include <string.h>
|
||||
#include <syslog.h>
|
||||
|
||||
#include "dma.h"
|
||||
|
@ -56,6 +56,7 @@
|
||||
#include <paths.h>
|
||||
#include <pwd.h>
|
||||
#include <stdio.h>
|
||||
#include <string.h>
|
||||
#include <syslog.h>
|
||||
#include <unistd.h>
|
||||
|
||||
|
@ -44,6 +44,7 @@
|
||||
#include <signal.h>
|
||||
#include <stdint.h>
|
||||
#include <stdio.h>
|
||||
#include <string.h>
|
||||
#include <syslog.h>
|
||||
#include <unistd.h>
|
||||
|
||||
|
@ -36,6 +36,7 @@
|
||||
#include <errno.h>
|
||||
#include <inttypes.h>
|
||||
#include <signal.h>
|
||||
#include <string.h>
|
||||
#include <syslog.h>
|
||||
#include <unistd.h>
|
||||
|
||||
|
@ -53,6 +53,7 @@
|
||||
#include <netdb.h>
|
||||
#include <setjmp.h>
|
||||
#include <signal.h>
|
||||
#include <string.h>
|
||||
#include <syslog.h>
|
||||
#include <unistd.h>
|
||||
|
||||
|
@ -45,6 +45,7 @@
|
||||
#include <fcntl.h>
|
||||
#include <inttypes.h>
|
||||
#include <unistd.h>
|
||||
#include <string.h>
|
||||
#include <syslog.h>
|
||||
|
||||
#include "dma.h"
|
||||
|
@ -44,6 +44,7 @@
|
||||
#include <setjmp.h>
|
||||
#include <signal.h>
|
||||
#include <stdio.h>
|
||||
#include <string.h>
|
||||
#include <syslog.h>
|
||||
#include <unistd.h>
|
||||
|
||||
|
@ -60,19 +60,19 @@
|
||||
#define HAVE_DLFCN_H 1
|
||||
|
||||
/* Define to 1 if you have the `DSA_get0_key' function. */
|
||||
/* #undef HAVE_DSA_GET0_KEY */
|
||||
#define HAVE_DSA_GET0_KEY 1
|
||||
|
||||
/* Define to 1 if you have the `DSA_get0_pqg' function. */
|
||||
/* #undef HAVE_DSA_GET0_PQG */
|
||||
#define HAVE_DSA_GET0_PQG 1
|
||||
|
||||
/* Define to 1 if you have the `DSA_SIG_get0' function. */
|
||||
/* #undef HAVE_DSA_SIG_GET0 */
|
||||
#define HAVE_DSA_SIG_GET0 1
|
||||
|
||||
/* Define to 1 if you have the `DSA_SIG_set0' function. */
|
||||
/* #undef HAVE_DSA_SIG_SET0 */
|
||||
#define HAVE_DSA_SIG_SET0 1
|
||||
|
||||
/* Define to 1 if you have the `ECDSA_SIG_get0' function. */
|
||||
/* #undef HAVE_ECDSA_SIG_GET0 */
|
||||
#define HAVE_ECDSA_SIG_GET0 1
|
||||
|
||||
/* Define to 1 if you have the `endprotoent' function. */
|
||||
#define HAVE_ENDPROTOENT 1
|
||||
@ -84,10 +84,10 @@
|
||||
#define HAVE_ENGINE_LOAD_CRYPTODEV 1
|
||||
|
||||
/* Define to 1 if you have the `EVP_dss1' function. */
|
||||
#define HAVE_EVP_DSS1 1
|
||||
/* #undef HAVE_EVP_DSS1 */
|
||||
|
||||
/* Define to 1 if you have the `EVP_MD_CTX_new' function. */
|
||||
/* #undef HAVE_EVP_MD_CTX_NEW */
|
||||
#define HAVE_EVP_MD_CTX_NEW 1
|
||||
|
||||
/* Define to 1 if you have the `EVP_PKEY_base_id' function. */
|
||||
#define HAVE_EVP_PKEY_BASE_ID 1
|
||||
|
@ -379,7 +379,7 @@ tls_exec_client(const char *user, int startfd, const char *srcaddr,
|
||||
* libcrypto use sysctl kern.arandom to obtain random data
|
||||
* instead of /dev/urandom and friends.
|
||||
*/
|
||||
sslctx = SSL_CTX_new(TLSv1_client_method());
|
||||
sslctx = SSL_CTX_new(TLS_client_method());
|
||||
if (sslctx == NULL)
|
||||
pjdlog_exitx(EX_TEMPFAIL, "SSL_CTX_new() failed.");
|
||||
|
||||
@ -666,7 +666,7 @@ tls_exec_server(const char *user, int startfd, const char *privkey,
|
||||
SSL_load_error_strings();
|
||||
SSL_library_init();
|
||||
|
||||
sslctx = SSL_CTX_new(TLSv1_server_method());
|
||||
sslctx = SSL_CTX_new(TLS_server_method());
|
||||
if (sslctx == NULL)
|
||||
pjdlog_exitx(EX_TEMPFAIL, "SSL_CTX_new() failed.");
|
||||
|
||||
|
@ -207,9 +207,9 @@ fb64_start(struct fb *fbp, int dir, int server __unused)
|
||||
/*
|
||||
* Create a random feed and send it over.
|
||||
*/
|
||||
des_random_key((Block *)fbp->temp_feed);
|
||||
des_ecb_encrypt((Block *)fbp->temp_feed, (Block *)fbp->temp_feed,
|
||||
fbp->krbdes_sched, 1);
|
||||
DES_random_key((Block *)fbp->temp_feed);
|
||||
DES_ecb_encrypt((Block *)fbp->temp_feed, (Block *)fbp->temp_feed,
|
||||
&fbp->krbdes_sched, 1);
|
||||
p = fbp->fb_feed + 3;
|
||||
*p++ = ENCRYPT_IS;
|
||||
p++;
|
||||
@ -393,7 +393,7 @@ fb64_session(Session_Key *key, int server, struct fb *fbp)
|
||||
fb64_stream_key(fbp->krbdes_key, &fbp->streams[DIR_ENCRYPT-1]);
|
||||
fb64_stream_key(fbp->krbdes_key, &fbp->streams[DIR_DECRYPT-1]);
|
||||
|
||||
des_key_sched((Block *)fbp->krbdes_key, fbp->krbdes_sched);
|
||||
DES_key_sched((Block *)fbp->krbdes_key, &fbp->krbdes_sched);
|
||||
/*
|
||||
* Now look to see if krbdes_start() was was waiting for
|
||||
* the key to show up. If so, go ahead an call it now
|
||||
@ -499,7 +499,7 @@ fb64_stream_iv(Block seed, struct stinfo *stp)
|
||||
memmove((void *)stp->str_iv, (void *)seed, sizeof(Block));
|
||||
memmove((void *)stp->str_output, (void *)seed, sizeof(Block));
|
||||
|
||||
des_key_sched((Block *)stp->str_ikey, stp->str_sched);
|
||||
DES_key_sched((Block *)stp->str_ikey, &stp->str_sched);
|
||||
|
||||
stp->str_index = sizeof(Block);
|
||||
}
|
||||
@ -508,7 +508,7 @@ void
|
||||
fb64_stream_key(Block key, struct stinfo *stp)
|
||||
{
|
||||
memmove((void *)stp->str_ikey, (void *)key, sizeof(Block));
|
||||
des_key_sched((Block *)key, stp->str_sched);
|
||||
DES_key_sched((Block *)key, &stp->str_sched);
|
||||
|
||||
memmove((void *)stp->str_output, (void *)stp->str_iv, sizeof(Block));
|
||||
|
||||
@ -547,7 +547,7 @@ cfb64_encrypt(unsigned char *s, int c)
|
||||
while (c-- > 0) {
|
||||
if (idx == sizeof(Block)) {
|
||||
Block b;
|
||||
des_ecb_encrypt((Block *)stp->str_output, (Block *)b, stp->str_sched, 1);
|
||||
DES_ecb_encrypt((Block *)stp->str_output, (Block *)b, &stp->str_sched, 1);
|
||||
memmove((void *)stp->str_feed, (void *)b, sizeof(Block));
|
||||
idx = 0;
|
||||
}
|
||||
@ -580,7 +580,7 @@ cfb64_decrypt(int data)
|
||||
idx = stp->str_index++;
|
||||
if (idx == sizeof(Block)) {
|
||||
Block b;
|
||||
des_ecb_encrypt((Block *)stp->str_output, (Block *)b, stp->str_sched, 1);
|
||||
DES_ecb_encrypt((Block *)stp->str_output, (Block *)b, &stp->str_sched, 1);
|
||||
memmove((void *)stp->str_feed, (void *)b, sizeof(Block));
|
||||
stp->str_index = 1; /* Next time will be 1 */
|
||||
idx = 0; /* But now use 0 */
|
||||
@ -620,7 +620,7 @@ ofb64_encrypt(unsigned char *s, int c)
|
||||
while (c-- > 0) {
|
||||
if (idx == sizeof(Block)) {
|
||||
Block b;
|
||||
des_ecb_encrypt((Block *)stp->str_feed, (Block *)b, stp->str_sched, 1);
|
||||
DES_ecb_encrypt((Block *)stp->str_feed, (Block *)b, &stp->str_sched, 1);
|
||||
memmove((void *)stp->str_feed, (void *)b, sizeof(Block));
|
||||
idx = 0;
|
||||
}
|
||||
@ -650,7 +650,7 @@ ofb64_decrypt(int data)
|
||||
idx = stp->str_index++;
|
||||
if (idx == sizeof(Block)) {
|
||||
Block b;
|
||||
des_ecb_encrypt((Block *)stp->str_feed, (Block *)b, stp->str_sched, 1);
|
||||
DES_ecb_encrypt((Block *)stp->str_feed, (Block *)b, &stp->str_sched, 1);
|
||||
memmove((void *)stp->str_feed, (void *)b, sizeof(Block));
|
||||
stp->str_index = 1; /* Next time will be 1 */
|
||||
idx = 0; /* But now use 0 */
|
||||
|
@ -67,7 +67,7 @@ typedef unsigned char *BlockT;
|
||||
#if 0
|
||||
typedef struct { Block __; } Schedule[16];
|
||||
#else
|
||||
#define Schedule des_key_schedule
|
||||
#define Schedule DES_key_schedule
|
||||
#endif
|
||||
|
||||
#define VALIDKEY(key) ( key[0] | key[1] | key[2] | key[3] | \
|
||||
|
@ -91,7 +91,7 @@ static char name[ANAME_SZ];
|
||||
static AUTH_DAT adat = { 0, "", "", "", 0, {}, 0, 0, 0, { 0, "", 0 } };
|
||||
#ifdef ENCRYPTION
|
||||
static Block session_key = { 0 };
|
||||
static des_key_schedule sched;
|
||||
static DES_key_schedule sched;
|
||||
static Block challenge = { 0 };
|
||||
#endif /* ENCRYPTION */
|
||||
|
||||
@ -206,10 +206,10 @@ kerberos4_send(Authenticator *ap)
|
||||
if ((ap->way & AUTH_HOW_MASK) == AUTH_HOW_MUTUAL) {
|
||||
register int i;
|
||||
|
||||
des_key_sched(&cred.session, sched);
|
||||
des_random_key(&session_key);
|
||||
des_ecb_encrypt(&session_key, &session_key, sched, 0);
|
||||
des_ecb_encrypt(&session_key, &challenge, sched, 0);
|
||||
DES_key_sched(&cred.session, sched);
|
||||
DES_random_key(&session_key);
|
||||
DES_ecb_encrypt(&session_key, &session_key, sched, 0);
|
||||
DES_ecb_encrypt(&session_key, &challenge, sched, 0);
|
||||
/*
|
||||
* Increment the challenge by 1, and encrypt it for
|
||||
* later comparison.
|
||||
@ -221,7 +221,7 @@ kerberos4_send(Authenticator *ap)
|
||||
if (x < 256) /* if no overflow, all done */
|
||||
break;
|
||||
}
|
||||
des_ecb_encrypt(&challenge, &challenge, sched, 1);
|
||||
DES_ecb_encrypt(&challenge, &challenge, sched, 1);
|
||||
}
|
||||
#endif /* ENCRYPTION */
|
||||
|
||||
@ -298,14 +298,14 @@ kerberos4_is(Authenticator *ap, unsigned char *data, int cnt)
|
||||
break;
|
||||
}
|
||||
|
||||
des_key_sched(&session_key, sched);
|
||||
DES_key_sched(&session_key, sched);
|
||||
memmove((void *)datablock, (void *)data, sizeof(Block));
|
||||
/*
|
||||
* Take the received encrypted challenge, and encrypt
|
||||
* it again to get a unique session_key for the
|
||||
* ENCRYPT option.
|
||||
*/
|
||||
des_ecb_encrypt(&datablock, &session_key, sched, 1);
|
||||
DES_ecb_encrypt(&datablock, &session_key, sched, 1);
|
||||
skey.type = SK_DES;
|
||||
skey.length = 8;
|
||||
skey.data = session_key;
|
||||
@ -314,7 +314,7 @@ kerberos4_is(Authenticator *ap, unsigned char *data, int cnt)
|
||||
* Now decrypt the received encrypted challenge,
|
||||
* increment by one, re-encrypt it and send it back.
|
||||
*/
|
||||
des_ecb_encrypt(&datablock, &challenge, sched, 0);
|
||||
DES_ecb_encrypt(&datablock, &challenge, sched, 0);
|
||||
for (r = 7; r >= 0; r--) {
|
||||
register int t;
|
||||
t = (unsigned int)challenge[r] + 1;
|
||||
@ -322,7 +322,7 @@ kerberos4_is(Authenticator *ap, unsigned char *data, int cnt)
|
||||
if (t < 256) /* if no overflow, all done */
|
||||
break;
|
||||
}
|
||||
des_ecb_encrypt(&challenge, &challenge, sched, 1);
|
||||
DES_ecb_encrypt(&challenge, &challenge, sched, 1);
|
||||
Data(ap, KRB_RESPONSE, challenge, sizeof(challenge));
|
||||
#endif /* ENCRYPTION */
|
||||
break;
|
||||
@ -364,7 +364,7 @@ kerberos4_reply(Authenticator *ap, unsigned char *data, int cnt)
|
||||
#else /* ENCRYPTION */
|
||||
Data(ap, KRB_CHALLENGE, session_key,
|
||||
sizeof(session_key));
|
||||
des_ecb_encrypt(&session_key, &session_key, sched, 1);
|
||||
DES_ecb_encrypt(&session_key, &session_key, sched, 1);
|
||||
skey.type = SK_DES;
|
||||
skey.length = 8;
|
||||
skey.data = session_key;
|
||||
|
@ -129,7 +129,7 @@ common_key(char *xsecret, char *xpublic, IdeaData *ideakey, DesData *deskey)
|
||||
mp_pow(public, secret, modulus, common);
|
||||
extractdeskey(common, deskey);
|
||||
extractideakey(common, ideakey);
|
||||
des_set_odd_parity(deskey);
|
||||
DES_set_odd_parity(deskey);
|
||||
mp_mfree(common);
|
||||
mp_mfree(secret);
|
||||
mp_mfree(public);
|
||||
@ -221,14 +221,14 @@ pk_encode(char *in, char *out, DesData *key)
|
||||
{
|
||||
char buf[256];
|
||||
DesData i;
|
||||
des_key_schedule k;
|
||||
DES_key_schedule k;
|
||||
int l,op,deslen;
|
||||
|
||||
memset(&i,0,sizeof(i));
|
||||
memset(buf,0,sizeof(buf));
|
||||
deslen = ((strlen(in) + 7)/8)*8;
|
||||
des_key_sched(key, k);
|
||||
des_cbc_encrypt(in,buf,deslen, k,&i,DES_ENCRYPT);
|
||||
DES_key_sched(key, &k);
|
||||
DES_cbc_encrypt(in, buf, deslen, &k, &i, DES_ENCRYPT);
|
||||
for (l=0,op=0;l<deslen;l++) {
|
||||
out[op++] = hextab[(buf[l] & 0xf0) >> 4];
|
||||
out[op++] = hextab[(buf[l] & 0x0f)];
|
||||
@ -242,7 +242,7 @@ pk_decode(char *in, char *out, DesData *key)
|
||||
{
|
||||
char buf[256];
|
||||
DesData i;
|
||||
des_key_schedule k;
|
||||
DES_key_schedule k;
|
||||
int n1,n2,op;
|
||||
size_t l;
|
||||
|
||||
@ -259,7 +259,7 @@ pk_decode(char *in, char *out, DesData *key)
|
||||
n2 = in[op+1] - '0';
|
||||
buf[l] = n1*16 +n2;
|
||||
}
|
||||
des_key_sched(key, k);
|
||||
des_cbc_encrypt(buf,out,strlen(in)/2, k,&i,DES_DECRYPT);
|
||||
DES_key_sched(key, &k);
|
||||
DES_cbc_encrypt(buf, out, strlen(in) / 2, &k, &i, DES_DECRYPT);
|
||||
out[strlen(in)/2] = '\0';
|
||||
}
|
||||
|
@ -32,7 +32,7 @@
|
||||
/* header for the des routines that we will use */
|
||||
|
||||
typedef unsigned char byte, DesData[ 8], IdeaData[16];
|
||||
#define DesKeys des_key_schedule
|
||||
#define DesKeys DES_key_schedule
|
||||
|
||||
#define DES_DECRYPT 0
|
||||
#define DES_ENCRYPT 1
|
||||
|
@ -135,7 +135,7 @@
|
||||
#define HAVE_DLFCN_H 1
|
||||
|
||||
/* Define to 1 if you have the `DSA_SIG_set0' function. */
|
||||
/* #undef HAVE_DSA_SIG_SET0 */
|
||||
#define HAVE_DSA_SIG_SET0 1
|
||||
|
||||
/* Define to 1 if you have the <endian.h> header file. */
|
||||
/* #undef HAVE_ENDIAN_H */
|
||||
@ -177,10 +177,10 @@
|
||||
/* #undef HAVE_EVP_DIGESTVERIFY */
|
||||
|
||||
/* Define to 1 if you have the `EVP_dss1' function. */
|
||||
#define HAVE_EVP_DSS1 1
|
||||
/* #undef HAVE_EVP_DSS1 */
|
||||
|
||||
/* Define to 1 if you have the `EVP_MD_CTX_new' function. */
|
||||
/* #undef HAVE_EVP_MD_CTX_NEW */
|
||||
#define HAVE_EVP_MD_CTX_NEW 1
|
||||
|
||||
/* Define to 1 if you have the `EVP_sha1' function. */
|
||||
#define HAVE_EVP_SHA1 1
|
||||
|
@ -375,8 +375,8 @@ _kdc_do_digest(krb5_context context,
|
||||
case choice_DigestReqInner_init: {
|
||||
unsigned char server_nonce[16], identifier;
|
||||
|
||||
RAND_pseudo_bytes(&identifier, sizeof(identifier));
|
||||
RAND_pseudo_bytes(server_nonce, sizeof(server_nonce));
|
||||
RAND_bytes(&identifier, sizeof(identifier));
|
||||
RAND_bytes(server_nonce, sizeof(server_nonce));
|
||||
|
||||
server_nonce[0] = kdc_time & 0xff;
|
||||
server_nonce[1] = (kdc_time >> 8) & 0xff;
|
||||
@ -1333,7 +1333,7 @@ _kdc_do_digest(krb5_context context,
|
||||
|
||||
if (ireq.u.ntlmRequest.sessionkey) {
|
||||
unsigned char masterkey[MD4_DIGEST_LENGTH];
|
||||
EVP_CIPHER_CTX rc4;
|
||||
EVP_CIPHER_CTX *rc4;
|
||||
size_t len;
|
||||
|
||||
if ((flags & NTLM_NEG_KEYEX) == 0) {
|
||||
@ -1354,12 +1354,18 @@ _kdc_do_digest(krb5_context context,
|
||||
}
|
||||
|
||||
|
||||
EVP_CIPHER_CTX_init(&rc4);
|
||||
EVP_CipherInit_ex(&rc4, EVP_rc4(), NULL, sessionkey, NULL, 1);
|
||||
EVP_Cipher(&rc4,
|
||||
rc4 = EVP_CIPHER_CTX_new();
|
||||
if (rc4 == NULL) {
|
||||
ret = ENOMEM;
|
||||
krb5_set_error_message(context, ret,
|
||||
"NTLM failed to malloc cipher context");
|
||||
goto failed;
|
||||
}
|
||||
EVP_CipherInit_ex(rc4, EVP_rc4(), NULL, sessionkey, NULL, 1);
|
||||
EVP_Cipher(rc4,
|
||||
masterkey, ireq.u.ntlmRequest.sessionkey->data,
|
||||
sizeof(masterkey));
|
||||
EVP_CIPHER_CTX_cleanup(&rc4);
|
||||
EVP_CIPHER_CTX_free(rc4);
|
||||
|
||||
r.u.ntlmResponse.sessionkey =
|
||||
malloc(sizeof(*r.u.ntlmResponse.sessionkey));
|
||||
|
@ -64,7 +64,7 @@ verify_req_hash(krb5_context context,
|
||||
krb5_keyblock *key)
|
||||
{
|
||||
unsigned char digest[SHA_DIGEST_LENGTH];
|
||||
HMAC_CTX ctx;
|
||||
HMAC_CTX *ctx;
|
||||
|
||||
if (req->pk_hash.length != sizeof(digest)) {
|
||||
krb5_set_error_message(context, KRB5KDC_ERR_PREAUTH_FAILED,
|
||||
@ -73,16 +73,21 @@ verify_req_hash(krb5_context context,
|
||||
return KRB5KDC_ERR_PREAUTH_FAILED;
|
||||
}
|
||||
|
||||
HMAC_CTX_init(&ctx);
|
||||
HMAC_Init_ex(&ctx,
|
||||
ctx = HMAC_CTX_new();
|
||||
if (ctx == NULL) {
|
||||
krb5_set_error_message(context, ENOMEM,
|
||||
"HMAC context malloc failed");
|
||||
return ENOMEM;
|
||||
}
|
||||
HMAC_Init_ex(ctx,
|
||||
key->keyvalue.data, key->keyvalue.length,
|
||||
EVP_sha1(), NULL);
|
||||
if (sizeof(digest) != HMAC_size(&ctx))
|
||||
if (sizeof(digest) != HMAC_size(ctx))
|
||||
krb5_abortx(context, "runtime error, hmac buffer wrong size in kx509");
|
||||
HMAC_Update(&ctx, version_2_0, sizeof(version_2_0));
|
||||
HMAC_Update(&ctx, req->pk_key.data, req->pk_key.length);
|
||||
HMAC_Final(&ctx, digest, 0);
|
||||
HMAC_CTX_cleanup(&ctx);
|
||||
HMAC_Update(ctx, version_2_0, sizeof(version_2_0));
|
||||
HMAC_Update(ctx, req->pk_key.data, req->pk_key.length);
|
||||
HMAC_Final(ctx, digest, 0);
|
||||
HMAC_CTX_free(ctx);
|
||||
|
||||
if (memcmp(req->pk_hash.data, digest, sizeof(digest)) != 0) {
|
||||
krb5_set_error_message(context, KRB5KDC_ERR_PREAUTH_FAILED,
|
||||
@ -98,35 +103,40 @@ calculate_reply_hash(krb5_context context,
|
||||
Kx509Response *rep)
|
||||
{
|
||||
krb5_error_code ret;
|
||||
HMAC_CTX ctx;
|
||||
HMAC_CTX *ctx;
|
||||
|
||||
HMAC_CTX_init(&ctx);
|
||||
ctx = HMAC_CTX_new();
|
||||
if (ctx == NULL) {
|
||||
krb5_set_error_message(context, ENOMEM,
|
||||
"HMAC context malloc failed");
|
||||
return ENOMEM;
|
||||
}
|
||||
|
||||
HMAC_Init_ex(&ctx, key->keyvalue.data, key->keyvalue.length,
|
||||
HMAC_Init_ex(ctx, key->keyvalue.data, key->keyvalue.length,
|
||||
EVP_sha1(), NULL);
|
||||
ret = krb5_data_alloc(rep->hash, HMAC_size(&ctx));
|
||||
ret = krb5_data_alloc(rep->hash, HMAC_size(ctx));
|
||||
if (ret) {
|
||||
HMAC_CTX_cleanup(&ctx);
|
||||
HMAC_CTX_free(ctx);
|
||||
krb5_set_error_message(context, ENOMEM, "malloc: out of memory");
|
||||
return ENOMEM;
|
||||
}
|
||||
|
||||
HMAC_Update(&ctx, version_2_0, sizeof(version_2_0));
|
||||
HMAC_Update(ctx, version_2_0, sizeof(version_2_0));
|
||||
if (rep->error_code) {
|
||||
int32_t t = *rep->error_code;
|
||||
do {
|
||||
unsigned char p = (t & 0xff);
|
||||
HMAC_Update(&ctx, &p, 1);
|
||||
HMAC_Update(ctx, &p, 1);
|
||||
t >>= 8;
|
||||
} while (t);
|
||||
}
|
||||
if (rep->certificate)
|
||||
HMAC_Update(&ctx, rep->certificate->data, rep->certificate->length);
|
||||
HMAC_Update(ctx, rep->certificate->data, rep->certificate->length);
|
||||
if (rep->e_text)
|
||||
HMAC_Update(&ctx, (unsigned char *)*rep->e_text, strlen(*rep->e_text));
|
||||
HMAC_Update(ctx, (unsigned char *)*rep->e_text, strlen(*rep->e_text));
|
||||
|
||||
HMAC_Final(&ctx, rep->hash->data, 0);
|
||||
HMAC_CTX_cleanup(&ctx);
|
||||
HMAC_Final(ctx, rep->hash->data, 0);
|
||||
HMAC_CTX_free(ctx);
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
@ -331,6 +331,7 @@ get_dh_param(krb5_context context,
|
||||
{
|
||||
DomainParameters dhparam;
|
||||
DH *dh = NULL;
|
||||
BIGNUM *p, *q, *g;
|
||||
krb5_error_code ret;
|
||||
|
||||
memset(&dhparam, 0, sizeof(dhparam));
|
||||
@ -375,15 +376,21 @@ get_dh_param(krb5_context context,
|
||||
goto out;
|
||||
}
|
||||
ret = KRB5_BADMSGTYPE;
|
||||
dh->p = integer_to_BN(context, "DH prime", &dhparam.p);
|
||||
if (dh->p == NULL)
|
||||
p = integer_to_BN(context, "DH prime", &dhparam.p);
|
||||
g = integer_to_BN(context, "DH base", &dhparam.g);
|
||||
q = integer_to_BN(context, "DH p-1 factor", &dhparam.q);
|
||||
if (p == NULL || g == NULL || q == NULL) {
|
||||
BN_free(p);
|
||||
BN_free(g);
|
||||
BN_free(q);
|
||||
goto out;
|
||||
dh->g = integer_to_BN(context, "DH base", &dhparam.g);
|
||||
if (dh->g == NULL)
|
||||
goto out;
|
||||
dh->q = integer_to_BN(context, "DH p-1 factor", &dhparam.q);
|
||||
if (dh->g == NULL)
|
||||
}
|
||||
if (DH_set0_pqg(dh, p, g, q) != 1) {
|
||||
BN_free(p);
|
||||
BN_free(g);
|
||||
BN_free(q);
|
||||
goto out;
|
||||
}
|
||||
|
||||
{
|
||||
heim_integer glue;
|
||||
@ -895,7 +902,7 @@ _kdc_pk_rd_padata(krb5_context context,
|
||||
*/
|
||||
|
||||
static krb5_error_code
|
||||
BN_to_integer(krb5_context context, BIGNUM *bn, heim_integer *integer)
|
||||
BN_to_integer(krb5_context context, const BIGNUM *bn, heim_integer *integer)
|
||||
{
|
||||
integer->length = BN_num_bytes(bn);
|
||||
integer->data = malloc(integer->length);
|
||||
@ -1112,9 +1119,11 @@ pk_mk_pa_reply_dh(krb5_context context,
|
||||
|
||||
if (cp->keyex == USE_DH) {
|
||||
DH *kdc_dh = cp->u.dh.key;
|
||||
const BIGNUM *pub_key;
|
||||
heim_integer i;
|
||||
|
||||
ret = BN_to_integer(context, kdc_dh->pub_key, &i);
|
||||
DH_get0_key(kdc_dh, &pub_key, NULL);
|
||||
ret = BN_to_integer(context, pub_key, &i);
|
||||
if (ret)
|
||||
return ret;
|
||||
|
||||
|
@ -173,7 +173,7 @@ _gssapi_get_mic_arcfour(OM_uint32 * minor_status,
|
||||
int32_t seq_number;
|
||||
size_t len, total_len;
|
||||
u_char k6_data[16], *p0, *p;
|
||||
EVP_CIPHER_CTX rc4_key;
|
||||
EVP_CIPHER_CTX *rc4_key;
|
||||
|
||||
_gsskrb5_encap_length (22, &len, &total_len, GSS_KRB5_MECHANISM);
|
||||
|
||||
@ -235,10 +235,16 @@ _gssapi_get_mic_arcfour(OM_uint32 * minor_status,
|
||||
|
||||
memset (p + 4, (context_handle->more_flags & LOCAL) ? 0 : 0xff, 4);
|
||||
|
||||
EVP_CIPHER_CTX_init(&rc4_key);
|
||||
EVP_CipherInit_ex(&rc4_key, EVP_rc4(), NULL, k6_data, NULL, 1);
|
||||
EVP_Cipher(&rc4_key, p, p, 8);
|
||||
EVP_CIPHER_CTX_cleanup(&rc4_key);
|
||||
rc4_key = EVP_CIPHER_CTX_new();
|
||||
if (rc4_key == NULL) {
|
||||
_gsskrb5_release_buffer(minor_status, message_token);
|
||||
*minor_status = ENOMEM;
|
||||
return GSS_S_FAILURE;
|
||||
}
|
||||
|
||||
EVP_CipherInit_ex(rc4_key, EVP_rc4(), NULL, k6_data, NULL, 1);
|
||||
EVP_Cipher(rc4_key, p, p, 8);
|
||||
EVP_CIPHER_CTX_free(rc4_key);
|
||||
|
||||
memset(k6_data, 0, sizeof(k6_data));
|
||||
|
||||
@ -308,12 +314,16 @@ _gssapi_verify_mic_arcfour(OM_uint32 * minor_status,
|
||||
}
|
||||
|
||||
{
|
||||
EVP_CIPHER_CTX rc4_key;
|
||||
EVP_CIPHER_CTX *rc4_key;
|
||||
|
||||
EVP_CIPHER_CTX_init(&rc4_key);
|
||||
EVP_CipherInit_ex(&rc4_key, EVP_rc4(), NULL, (void *)k6_data, NULL, 0);
|
||||
EVP_Cipher(&rc4_key, SND_SEQ, p, 8);
|
||||
EVP_CIPHER_CTX_cleanup(&rc4_key);
|
||||
rc4_key = EVP_CIPHER_CTX_new();
|
||||
if (rc4_key == NULL) {
|
||||
*minor_status = ENOMEM;
|
||||
return GSS_S_FAILURE;
|
||||
}
|
||||
EVP_CipherInit_ex(rc4_key, EVP_rc4(), NULL, (void *)k6_data, NULL, 0);
|
||||
EVP_Cipher(rc4_key, SND_SEQ, p, 8);
|
||||
EVP_CIPHER_CTX_free(rc4_key);
|
||||
|
||||
memset(k6_data, 0, sizeof(k6_data));
|
||||
}
|
||||
@ -461,12 +471,17 @@ _gssapi_wrap_arcfour(OM_uint32 * minor_status,
|
||||
|
||||
|
||||
if(conf_req_flag) {
|
||||
EVP_CIPHER_CTX rc4_key;
|
||||
EVP_CIPHER_CTX *rc4_key;
|
||||
|
||||
EVP_CIPHER_CTX_init(&rc4_key);
|
||||
EVP_CipherInit_ex(&rc4_key, EVP_rc4(), NULL, k6_data, NULL, 1);
|
||||
EVP_Cipher(&rc4_key, p0 + 24, p0 + 24, 8 + datalen);
|
||||
EVP_CIPHER_CTX_cleanup(&rc4_key);
|
||||
rc4_key = EVP_CIPHER_CTX_new();
|
||||
if (rc4_key == NULL) {
|
||||
_gsskrb5_release_buffer(minor_status, output_message_buffer);
|
||||
*minor_status = ENOMEM;
|
||||
return GSS_S_FAILURE;
|
||||
}
|
||||
EVP_CipherInit_ex(rc4_key, EVP_rc4(), NULL, k6_data, NULL, 1);
|
||||
EVP_Cipher(rc4_key, p0 + 24, p0 + 24, 8 + datalen);
|
||||
EVP_CIPHER_CTX_free(rc4_key);
|
||||
}
|
||||
memset(k6_data, 0, sizeof(k6_data));
|
||||
|
||||
@ -480,12 +495,17 @@ _gssapi_wrap_arcfour(OM_uint32 * minor_status,
|
||||
}
|
||||
|
||||
{
|
||||
EVP_CIPHER_CTX rc4_key;
|
||||
EVP_CIPHER_CTX *rc4_key;
|
||||
|
||||
EVP_CIPHER_CTX_init(&rc4_key);
|
||||
EVP_CipherInit_ex(&rc4_key, EVP_rc4(), NULL, k6_data, NULL, 1);
|
||||
EVP_Cipher(&rc4_key, p0 + 8, p0 + 8 /* SND_SEQ */, 8);
|
||||
EVP_CIPHER_CTX_cleanup(&rc4_key);
|
||||
rc4_key = EVP_CIPHER_CTX_new();
|
||||
if (rc4_key == NULL) {
|
||||
_gsskrb5_release_buffer(minor_status, output_message_buffer);
|
||||
*minor_status = ENOMEM;
|
||||
return GSS_S_FAILURE;
|
||||
}
|
||||
EVP_CipherInit_ex(rc4_key, EVP_rc4(), NULL, k6_data, NULL, 1);
|
||||
EVP_Cipher(rc4_key, p0 + 8, p0 + 8 /* SND_SEQ */, 8);
|
||||
EVP_CIPHER_CTX_free(rc4_key);
|
||||
memset(k6_data, 0, sizeof(k6_data));
|
||||
}
|
||||
|
||||
@ -580,12 +600,16 @@ OM_uint32 _gssapi_unwrap_arcfour(OM_uint32 *minor_status,
|
||||
}
|
||||
|
||||
{
|
||||
EVP_CIPHER_CTX rc4_key;
|
||||
EVP_CIPHER_CTX *rc4_key;
|
||||
|
||||
EVP_CIPHER_CTX_init(&rc4_key);
|
||||
EVP_CipherInit_ex(&rc4_key, EVP_rc4(), NULL, k6_data, NULL, 1);
|
||||
EVP_Cipher(&rc4_key, SND_SEQ, p0 + 8, 8);
|
||||
EVP_CIPHER_CTX_cleanup(&rc4_key);
|
||||
rc4_key = EVP_CIPHER_CTX_new();
|
||||
if (rc4_key == NULL) {
|
||||
*minor_status = ENOMEM;
|
||||
return GSS_S_FAILURE;
|
||||
}
|
||||
EVP_CipherInit_ex(rc4_key, EVP_rc4(), NULL, k6_data, NULL, 1);
|
||||
EVP_Cipher(rc4_key, SND_SEQ, p0 + 8, 8);
|
||||
EVP_CIPHER_CTX_free(rc4_key);
|
||||
memset(k6_data, 0, sizeof(k6_data));
|
||||
}
|
||||
|
||||
@ -628,13 +652,18 @@ OM_uint32 _gssapi_unwrap_arcfour(OM_uint32 *minor_status,
|
||||
output_message_buffer->length = datalen;
|
||||
|
||||
if(conf_flag) {
|
||||
EVP_CIPHER_CTX rc4_key;
|
||||
EVP_CIPHER_CTX *rc4_key;
|
||||
|
||||
EVP_CIPHER_CTX_init(&rc4_key);
|
||||
EVP_CipherInit_ex(&rc4_key, EVP_rc4(), NULL, k6_data, NULL, 1);
|
||||
EVP_Cipher(&rc4_key, Confounder, p0 + 24, 8);
|
||||
EVP_Cipher(&rc4_key, output_message_buffer->value, p0 + GSS_ARCFOUR_WRAP_TOKEN_SIZE, datalen);
|
||||
EVP_CIPHER_CTX_cleanup(&rc4_key);
|
||||
rc4_key = EVP_CIPHER_CTX_new();
|
||||
if (rc4_key == NULL) {
|
||||
_gsskrb5_release_buffer(minor_status, output_message_buffer);
|
||||
*minor_status = ENOMEM;
|
||||
return GSS_S_FAILURE;
|
||||
}
|
||||
EVP_CipherInit_ex(rc4_key, EVP_rc4(), NULL, k6_data, NULL, 1);
|
||||
EVP_Cipher(rc4_key, Confounder, p0 + 24, 8);
|
||||
EVP_Cipher(rc4_key, output_message_buffer->value, p0 + GSS_ARCFOUR_WRAP_TOKEN_SIZE, datalen);
|
||||
EVP_CIPHER_CTX_free(rc4_key);
|
||||
} else {
|
||||
memcpy(Confounder, p0 + 24, 8); /* Confounder */
|
||||
memcpy(output_message_buffer->value,
|
||||
|
@ -50,7 +50,7 @@ mic_des
|
||||
EVP_MD_CTX *md5;
|
||||
u_char hash[16];
|
||||
DES_key_schedule schedule;
|
||||
EVP_CIPHER_CTX des_ctx;
|
||||
EVP_CIPHER_CTX *des_ctx;
|
||||
DES_cblock deskey;
|
||||
DES_cblock zero;
|
||||
int32_t seq_number;
|
||||
@ -96,6 +96,17 @@ mic_des
|
||||
&schedule, &zero);
|
||||
memcpy (p - 8, hash, 8); /* SGN_CKSUM */
|
||||
|
||||
des_ctx = EVP_CIPHER_CTX_new();
|
||||
if (des_ctx == NULL) {
|
||||
memset (deskey, 0, sizeof(deskey));
|
||||
memset (&schedule, 0, sizeof(schedule));
|
||||
free (message_token->value);
|
||||
message_token->value = NULL;
|
||||
message_token->length = 0;
|
||||
*minor_status = ENOMEM;
|
||||
return GSS_S_FAILURE;
|
||||
}
|
||||
|
||||
HEIMDAL_MUTEX_lock(&ctx->ctx_id_mutex);
|
||||
/* sequence number */
|
||||
krb5_auth_con_getlocalseqnumber (context,
|
||||
@ -111,10 +122,9 @@ mic_des
|
||||
(ctx->more_flags & LOCAL) ? 0 : 0xFF,
|
||||
4);
|
||||
|
||||
EVP_CIPHER_CTX_init(&des_ctx);
|
||||
EVP_CipherInit_ex(&des_ctx, EVP_des_cbc(), NULL, key->keyvalue.data, p + 8, 1);
|
||||
EVP_Cipher(&des_ctx, p, p, 8);
|
||||
EVP_CIPHER_CTX_cleanup(&des_ctx);
|
||||
EVP_CipherInit_ex(des_ctx, EVP_des_cbc(), NULL, key->keyvalue.data, p + 8, 1);
|
||||
EVP_Cipher(des_ctx, p, p, 8);
|
||||
EVP_CIPHER_CTX_free(des_ctx);
|
||||
|
||||
krb5_auth_con_setlocalseqnumber (context,
|
||||
ctx->auth_context,
|
||||
|
@ -50,7 +50,7 @@ unwrap_des
|
||||
size_t len;
|
||||
EVP_MD_CTX *md5;
|
||||
u_char hash[16];
|
||||
EVP_CIPHER_CTX des_ctx;
|
||||
EVP_CIPHER_CTX *des_ctx;
|
||||
DES_key_schedule schedule;
|
||||
DES_cblock deskey;
|
||||
DES_cblock zero;
|
||||
@ -104,12 +104,17 @@ unwrap_des
|
||||
deskey[i] ^= 0xf0;
|
||||
|
||||
|
||||
EVP_CIPHER_CTX_init(&des_ctx);
|
||||
EVP_CipherInit_ex(&des_ctx, EVP_des_cbc(), NULL, deskey, zero, 0);
|
||||
EVP_Cipher(&des_ctx, p, p, input_message_buffer->length - len);
|
||||
EVP_CIPHER_CTX_cleanup(&des_ctx);
|
||||
des_ctx = EVP_CIPHER_CTX_new();
|
||||
if (des_ctx == NULL) {
|
||||
memset (deskey, 0, sizeof(deskey));
|
||||
*minor_status = ENOMEM;
|
||||
return GSS_S_FAILURE;
|
||||
}
|
||||
EVP_CipherInit_ex(des_ctx, EVP_des_cbc(), NULL, deskey, zero, 0);
|
||||
EVP_Cipher(des_ctx, p, p, input_message_buffer->length - len);
|
||||
EVP_CIPHER_CTX_free(des_ctx);
|
||||
|
||||
memset (&schedule, 0, sizeof(schedule));
|
||||
memset (deskey, 0, sizeof(deskey));
|
||||
}
|
||||
|
||||
if (IS_DCE_STYLE(context_handle)) {
|
||||
@ -135,19 +140,29 @@ unwrap_des
|
||||
DES_set_key_unchecked (&deskey, &schedule);
|
||||
DES_cbc_cksum ((void *)hash, (void *)hash, sizeof(hash),
|
||||
&schedule, &zero);
|
||||
if (ct_memcmp (p - 8, hash, 8) != 0)
|
||||
if (ct_memcmp (p - 8, hash, 8) != 0) {
|
||||
memset (deskey, 0, sizeof(deskey));
|
||||
memset (&schedule, 0, sizeof(schedule));
|
||||
return GSS_S_BAD_MIC;
|
||||
}
|
||||
|
||||
/* verify sequence number */
|
||||
|
||||
des_ctx = EVP_CIPHER_CTX_new();
|
||||
if (des_ctx == NULL) {
|
||||
memset (deskey, 0, sizeof(deskey));
|
||||
memset (&schedule, 0, sizeof(schedule));
|
||||
*minor_status = ENOMEM;
|
||||
return GSS_S_FAILURE;
|
||||
}
|
||||
|
||||
HEIMDAL_MUTEX_lock(&context_handle->ctx_id_mutex);
|
||||
|
||||
p -= 16;
|
||||
|
||||
EVP_CIPHER_CTX_init(&des_ctx);
|
||||
EVP_CipherInit_ex(&des_ctx, EVP_des_cbc(), NULL, key->keyvalue.data, hash, 0);
|
||||
EVP_Cipher(&des_ctx, p, p, 8);
|
||||
EVP_CIPHER_CTX_cleanup(&des_ctx);
|
||||
EVP_CipherInit_ex(des_ctx, EVP_des_cbc(), NULL, key->keyvalue.data, hash, 0);
|
||||
EVP_Cipher(des_ctx, p, p, 8);
|
||||
EVP_CIPHER_CTX_free(des_ctx);
|
||||
|
||||
memset (deskey, 0, sizeof(deskey));
|
||||
memset (&schedule, 0, sizeof(schedule));
|
||||
|
@ -51,7 +51,7 @@ verify_mic_des
|
||||
EVP_MD_CTX *md5;
|
||||
u_char hash[16], *seq;
|
||||
DES_key_schedule schedule;
|
||||
EVP_CIPHER_CTX des_ctx;
|
||||
EVP_CIPHER_CTX *des_ctx;
|
||||
DES_cblock zero;
|
||||
DES_cblock deskey;
|
||||
uint32_t seq_number;
|
||||
@ -96,14 +96,21 @@ verify_mic_des
|
||||
|
||||
/* verify sequence number */
|
||||
|
||||
des_ctx = EVP_CIPHER_CTX_new();
|
||||
if (des_ctx == NULL) {
|
||||
memset (deskey, 0, sizeof(deskey));
|
||||
memset (&schedule, 0, sizeof(schedule));
|
||||
*minor_status = ENOMEM;
|
||||
return GSS_S_FAILURE;
|
||||
}
|
||||
|
||||
HEIMDAL_MUTEX_lock(&context_handle->ctx_id_mutex);
|
||||
|
||||
p -= 16;
|
||||
|
||||
EVP_CIPHER_CTX_init(&des_ctx);
|
||||
EVP_CipherInit_ex(&des_ctx, EVP_des_cbc(), NULL, key->keyvalue.data, hash, 0);
|
||||
EVP_Cipher(&des_ctx, p, p, 8);
|
||||
EVP_CIPHER_CTX_cleanup(&des_ctx);
|
||||
EVP_CipherInit_ex(des_ctx, EVP_des_cbc(), NULL, key->keyvalue.data, hash, 0);
|
||||
EVP_Cipher(des_ctx, p, p, 8);
|
||||
EVP_CIPHER_CTX_free(des_ctx);
|
||||
|
||||
memset (deskey, 0, sizeof(deskey));
|
||||
memset (&schedule, 0, sizeof(schedule));
|
||||
|
@ -211,7 +211,7 @@ wrap_des
|
||||
EVP_MD_CTX *md5;
|
||||
u_char hash[16];
|
||||
DES_key_schedule schedule;
|
||||
EVP_CIPHER_CTX des_ctx;
|
||||
EVP_CIPHER_CTX *des_ctx;
|
||||
DES_cblock deskey;
|
||||
DES_cblock zero;
|
||||
size_t i;
|
||||
@ -283,6 +283,17 @@ wrap_des
|
||||
&schedule, &zero);
|
||||
memcpy (p - 8, hash, 8);
|
||||
|
||||
des_ctx = EVP_CIPHER_CTX_new();
|
||||
if (des_ctx == NULL) {
|
||||
memset (deskey, 0, sizeof(deskey));
|
||||
memset (&schedule, 0, sizeof(schedule));
|
||||
free(output_message_buffer->value);
|
||||
output_message_buffer->value = NULL;
|
||||
output_message_buffer->length = 0;
|
||||
*minor_status = ENOMEM;
|
||||
return GSS_S_FAILURE;
|
||||
}
|
||||
|
||||
/* sequence number */
|
||||
HEIMDAL_MUTEX_lock(&ctx->ctx_id_mutex);
|
||||
krb5_auth_con_getlocalseqnumber (context,
|
||||
@ -298,10 +309,8 @@ wrap_des
|
||||
(ctx->more_flags & LOCAL) ? 0 : 0xFF,
|
||||
4);
|
||||
|
||||
EVP_CIPHER_CTX_init(&des_ctx);
|
||||
EVP_CipherInit_ex(&des_ctx, EVP_des_cbc(), NULL, key->keyvalue.data, p + 8, 1);
|
||||
EVP_Cipher(&des_ctx, p, p, 8);
|
||||
EVP_CIPHER_CTX_cleanup(&des_ctx);
|
||||
EVP_CipherInit_ex(des_ctx, EVP_des_cbc(), NULL, key->keyvalue.data, p + 8, 1);
|
||||
EVP_Cipher(des_ctx, p, p, 8);
|
||||
|
||||
krb5_auth_con_setlocalseqnumber (context,
|
||||
ctx->auth_context,
|
||||
@ -317,11 +326,11 @@ wrap_des
|
||||
for (i = 0; i < sizeof(deskey); ++i)
|
||||
deskey[i] ^= 0xf0;
|
||||
|
||||
EVP_CIPHER_CTX_init(&des_ctx);
|
||||
EVP_CipherInit_ex(&des_ctx, EVP_des_cbc(), NULL, deskey, zero, 1);
|
||||
EVP_Cipher(&des_ctx, p, p, datalen);
|
||||
EVP_CIPHER_CTX_cleanup(&des_ctx);
|
||||
EVP_CIPHER_CTX_reset(des_ctx);
|
||||
EVP_CipherInit_ex(des_ctx, EVP_des_cbc(), NULL, deskey, zero, 1);
|
||||
EVP_Cipher(des_ctx, p, p, datalen);
|
||||
}
|
||||
EVP_CIPHER_CTX_free(des_ctx);
|
||||
memset (deskey, 0, sizeof(deskey));
|
||||
memset (&schedule, 0, sizeof(schedule));
|
||||
|
||||
|
@ -148,16 +148,18 @@ v2_sign_message(gss_buffer_t in,
|
||||
{
|
||||
unsigned char hmac[16];
|
||||
unsigned int hmaclen;
|
||||
HMAC_CTX c;
|
||||
HMAC_CTX *c;
|
||||
|
||||
HMAC_CTX_init(&c);
|
||||
HMAC_Init_ex(&c, signkey, 16, EVP_md5(), NULL);
|
||||
c = HMAC_CTX_new();
|
||||
if (c == NULL)
|
||||
return GSS_S_FAILURE;
|
||||
HMAC_Init_ex(c, signkey, 16, EVP_md5(), NULL);
|
||||
|
||||
encode_le_uint32(seq, hmac);
|
||||
HMAC_Update(&c, hmac, 4);
|
||||
HMAC_Update(&c, in->value, in->length);
|
||||
HMAC_Final(&c, hmac, &hmaclen);
|
||||
HMAC_CTX_cleanup(&c);
|
||||
HMAC_Update(c, hmac, 4);
|
||||
HMAC_Update(c, in->value, in->length);
|
||||
HMAC_Final(c, hmac, &hmaclen);
|
||||
HMAC_CTX_free(c);
|
||||
|
||||
encode_le_uint32(1, &out[0]);
|
||||
if (sealkey)
|
||||
|
@ -226,7 +226,8 @@ heim_int2BN(const heim_integer *i)
|
||||
BIGNUM *bn;
|
||||
|
||||
bn = BN_bin2bn(i->data, i->length, NULL);
|
||||
BN_set_negative(bn, i->negative);
|
||||
if (bn != NULL)
|
||||
BN_set_negative(bn, i->negative);
|
||||
return bn;
|
||||
}
|
||||
|
||||
@ -899,12 +900,15 @@ rsa_get_internal(hx509_context context,
|
||||
hx509_private_key key,
|
||||
const char *type)
|
||||
{
|
||||
const BIGNUM *n;
|
||||
|
||||
if (strcasecmp(type, "rsa-modulus") == 0) {
|
||||
return BN_dup(key->private_key.rsa->n);
|
||||
RSA_get0_key(key->private_key.rsa, &n, NULL, NULL);
|
||||
} else if (strcasecmp(type, "rsa-exponent") == 0) {
|
||||
return BN_dup(key->private_key.rsa->e);
|
||||
RSA_get0_key(key->private_key.rsa, NULL, &n, NULL);
|
||||
} else
|
||||
return NULL;
|
||||
return BN_dup(n);
|
||||
}
|
||||
|
||||
|
||||
@ -1045,6 +1049,7 @@ dsa_verify_signature(hx509_context context,
|
||||
DSAPublicKey pk;
|
||||
DSAParams param;
|
||||
size_t size;
|
||||
BIGNUM *key, *p, *q, *g;
|
||||
DSA *dsa;
|
||||
int ret;
|
||||
|
||||
@ -1062,16 +1067,25 @@ dsa_verify_signature(hx509_context context,
|
||||
if (ret)
|
||||
goto out;
|
||||
|
||||
dsa->pub_key = heim_int2BN(&pk);
|
||||
key = heim_int2BN(&pk);
|
||||
|
||||
free_DSAPublicKey(&pk);
|
||||
|
||||
if (dsa->pub_key == NULL) {
|
||||
if (key == NULL) {
|
||||
ret = ENOMEM;
|
||||
hx509_set_error_string(context, 0, ret, "out of memory");
|
||||
goto out;
|
||||
}
|
||||
|
||||
ret = DSA_set0_key(dsa, key, NULL);
|
||||
|
||||
if (ret != 1) {
|
||||
BN_free(key);
|
||||
ret = EINVAL;
|
||||
hx509_set_error_string(context, 0, ret, "failed to set DSA key");
|
||||
goto out;
|
||||
}
|
||||
|
||||
if (spi->algorithm.parameters == NULL) {
|
||||
ret = HX509_CRYPTO_SIG_INVALID_FORMAT;
|
||||
hx509_set_error_string(context, 0, ret, "DSA parameters missing");
|
||||
@ -1087,18 +1101,32 @@ dsa_verify_signature(hx509_context context,
|
||||
goto out;
|
||||
}
|
||||
|
||||
dsa->p = heim_int2BN(¶m.p);
|
||||
dsa->q = heim_int2BN(¶m.q);
|
||||
dsa->g = heim_int2BN(¶m.g);
|
||||
p = heim_int2BN(¶m.p);
|
||||
q = heim_int2BN(¶m.q);
|
||||
g = heim_int2BN(¶m.g);
|
||||
|
||||
free_DSAParams(¶m);
|
||||
|
||||
if (dsa->p == NULL || dsa->q == NULL || dsa->g == NULL) {
|
||||
if (p == NULL || q == NULL || g == NULL) {
|
||||
BN_free(p);
|
||||
BN_free(q);
|
||||
BN_free(g);
|
||||
ret = ENOMEM;
|
||||
hx509_set_error_string(context, 0, ret, "out of memory");
|
||||
goto out;
|
||||
}
|
||||
|
||||
ret = DSA_set0_pqg(dsa, p, q, g);
|
||||
|
||||
if (ret != 1) {
|
||||
BN_free(p);
|
||||
BN_free(q);
|
||||
BN_free(g);
|
||||
ret = EINVAL;
|
||||
hx509_set_error_string(context, 0, ret, "failed to set DSA parameters");
|
||||
goto out;
|
||||
}
|
||||
|
||||
ret = DSA_verify(-1, data->data, data->length,
|
||||
(unsigned char*)sig->data, sig->length,
|
||||
dsa);
|
||||
@ -2562,7 +2590,7 @@ hx509_crypto_encrypt(hx509_crypto crypto,
|
||||
const heim_octet_string *ivec,
|
||||
heim_octet_string **ciphertext)
|
||||
{
|
||||
EVP_CIPHER_CTX evp;
|
||||
EVP_CIPHER_CTX *evp;
|
||||
size_t padsize, bsize;
|
||||
int ret;
|
||||
|
||||
@ -2574,12 +2602,13 @@ hx509_crypto_encrypt(hx509_crypto crypto,
|
||||
|
||||
assert(EVP_CIPHER_iv_length(crypto->c) == (int)ivec->length);
|
||||
|
||||
EVP_CIPHER_CTX_init(&evp);
|
||||
evp = EVP_CIPHER_CTX_new();
|
||||
if (evp == NULL)
|
||||
return ENOMEM;
|
||||
|
||||
ret = EVP_CipherInit_ex(&evp, crypto->c, NULL,
|
||||
ret = EVP_CipherInit_ex(evp, crypto->c, NULL,
|
||||
crypto->key.data, ivec->data, 1);
|
||||
if (ret != 1) {
|
||||
EVP_CIPHER_CTX_cleanup(&evp);
|
||||
ret = HX509_CRYPTO_INTERNAL_ERROR;
|
||||
goto out;
|
||||
}
|
||||
@ -2619,7 +2648,7 @@ hx509_crypto_encrypt(hx509_crypto crypto,
|
||||
*p++ = padsize;
|
||||
}
|
||||
|
||||
ret = EVP_Cipher(&evp, (*ciphertext)->data,
|
||||
ret = EVP_Cipher(evp, (*ciphertext)->data,
|
||||
(*ciphertext)->data,
|
||||
length + padsize);
|
||||
if (ret != 1) {
|
||||
@ -2638,7 +2667,7 @@ hx509_crypto_encrypt(hx509_crypto crypto,
|
||||
*ciphertext = NULL;
|
||||
}
|
||||
}
|
||||
EVP_CIPHER_CTX_cleanup(&evp);
|
||||
EVP_CIPHER_CTX_free(evp);
|
||||
|
||||
return ret;
|
||||
}
|
||||
@ -2650,7 +2679,7 @@ hx509_crypto_decrypt(hx509_crypto crypto,
|
||||
heim_octet_string *ivec,
|
||||
heim_octet_string *clear)
|
||||
{
|
||||
EVP_CIPHER_CTX evp;
|
||||
EVP_CIPHER_CTX *evp;
|
||||
void *idata = NULL;
|
||||
int ret;
|
||||
|
||||
@ -2670,27 +2699,30 @@ hx509_crypto_decrypt(hx509_crypto crypto,
|
||||
if (ivec)
|
||||
idata = ivec->data;
|
||||
|
||||
EVP_CIPHER_CTX_init(&evp);
|
||||
evp = EVP_CIPHER_CTX_new();
|
||||
if (evp == NULL)
|
||||
return ENOMEM;
|
||||
|
||||
ret = EVP_CipherInit_ex(&evp, crypto->c, NULL,
|
||||
ret = EVP_CipherInit_ex(evp, crypto->c, NULL,
|
||||
crypto->key.data, idata, 0);
|
||||
if (ret != 1) {
|
||||
EVP_CIPHER_CTX_cleanup(&evp);
|
||||
EVP_CIPHER_CTX_free(evp);
|
||||
return HX509_CRYPTO_INTERNAL_ERROR;
|
||||
}
|
||||
|
||||
clear->length = length;
|
||||
clear->data = malloc(length);
|
||||
if (clear->data == NULL) {
|
||||
EVP_CIPHER_CTX_cleanup(&evp);
|
||||
EVP_CIPHER_CTX_free(evp);
|
||||
clear->length = 0;
|
||||
return ENOMEM;
|
||||
}
|
||||
|
||||
if (EVP_Cipher(&evp, clear->data, data, length) != 1) {
|
||||
if (EVP_Cipher(evp, clear->data, data, length) != 1) {
|
||||
EVP_CIPHER_CTX_free(evp);
|
||||
return HX509_CRYPTO_INTERNAL_ERROR;
|
||||
}
|
||||
EVP_CIPHER_CTX_cleanup(&evp);
|
||||
EVP_CIPHER_CTX_free(evp);
|
||||
|
||||
if ((crypto->flags & PADDING_PKCS7) && EVP_CIPHER_block_size(crypto->c) > 1) {
|
||||
int padsize;
|
||||
@ -2949,6 +2981,8 @@ match_keys_rsa(hx509_cert c, hx509_private_key private_key)
|
||||
const SubjectPublicKeyInfo *spi;
|
||||
RSAPublicKey pk;
|
||||
RSA *rsa;
|
||||
const BIGNUM *d, *p, *q, *dmp1, *dmq1, *iqmp;
|
||||
BIGNUM *new_d, *new_p, *new_q, *new_dmp1, *new_dmq1, *new_iqmp, *n, *e;
|
||||
size_t size;
|
||||
int ret;
|
||||
|
||||
@ -2956,7 +2990,10 @@ match_keys_rsa(hx509_cert c, hx509_private_key private_key)
|
||||
return 0;
|
||||
|
||||
rsa = private_key->private_key.rsa;
|
||||
if (rsa->d == NULL || rsa->p == NULL || rsa->q == NULL)
|
||||
RSA_get0_key(rsa, NULL, NULL, &d);
|
||||
RSA_get0_factors(rsa, &p, &q);
|
||||
RSA_get0_crt_params(rsa, &dmp1, &dmq1, &iqmp);
|
||||
if (d == NULL || p == NULL || q == NULL)
|
||||
return 0;
|
||||
|
||||
cert = _hx509_get_cert(c);
|
||||
@ -2973,21 +3010,66 @@ match_keys_rsa(hx509_cert c, hx509_private_key private_key)
|
||||
RSA_free(rsa);
|
||||
return 0;
|
||||
}
|
||||
rsa->n = heim_int2BN(&pk.modulus);
|
||||
rsa->e = heim_int2BN(&pk.publicExponent);
|
||||
n = heim_int2BN(&pk.modulus);
|
||||
e = heim_int2BN(&pk.publicExponent);
|
||||
|
||||
free_RSAPublicKey(&pk);
|
||||
|
||||
rsa->d = BN_dup(private_key->private_key.rsa->d);
|
||||
rsa->p = BN_dup(private_key->private_key.rsa->p);
|
||||
rsa->q = BN_dup(private_key->private_key.rsa->q);
|
||||
rsa->dmp1 = BN_dup(private_key->private_key.rsa->dmp1);
|
||||
rsa->dmq1 = BN_dup(private_key->private_key.rsa->dmq1);
|
||||
rsa->iqmp = BN_dup(private_key->private_key.rsa->iqmp);
|
||||
new_d = BN_dup(d);
|
||||
new_p = BN_dup(p);
|
||||
new_q = BN_dup(q);
|
||||
new_dmp1 = BN_dup(dmp1);
|
||||
new_dmq1 = BN_dup(dmq1);
|
||||
new_iqmp = BN_dup(iqmp);
|
||||
|
||||
if (rsa->n == NULL || rsa->e == NULL ||
|
||||
rsa->d == NULL || rsa->p == NULL|| rsa->q == NULL ||
|
||||
rsa->dmp1 == NULL || rsa->dmq1 == NULL) {
|
||||
if (n == NULL || e == NULL ||
|
||||
new_d == NULL || new_p == NULL|| new_q == NULL ||
|
||||
new_dmp1 == NULL || new_dmq1 == NULL || new_iqmp == NULL) {
|
||||
BN_free(n);
|
||||
BN_free(e);
|
||||
BN_free(new_d);
|
||||
BN_free(new_p);
|
||||
BN_free(new_q);
|
||||
BN_free(new_dmp1);
|
||||
BN_free(new_dmq1);
|
||||
BN_free(new_iqmp);
|
||||
RSA_free(rsa);
|
||||
return 0;
|
||||
}
|
||||
|
||||
ret = RSA_set0_key(rsa, new_d, n, e);
|
||||
|
||||
if (ret != 1) {
|
||||
BN_free(n);
|
||||
BN_free(e);
|
||||
BN_free(new_d);
|
||||
BN_free(new_p);
|
||||
BN_free(new_q);
|
||||
BN_free(new_dmp1);
|
||||
BN_free(new_dmq1);
|
||||
BN_free(new_iqmp);
|
||||
RSA_free(rsa);
|
||||
return 0;
|
||||
}
|
||||
|
||||
ret = RSA_set0_factors(rsa, new_p, new_q);
|
||||
|
||||
if (ret != 1) {
|
||||
BN_free(new_p);
|
||||
BN_free(new_q);
|
||||
BN_free(new_dmp1);
|
||||
BN_free(new_dmq1);
|
||||
BN_free(new_iqmp);
|
||||
RSA_free(rsa);
|
||||
return 0;
|
||||
}
|
||||
|
||||
ret = RSA_set0_crt_params(rsa, new_dmp1, new_dmq1, new_iqmp);
|
||||
|
||||
if (ret != 1) {
|
||||
BN_free(new_dmp1);
|
||||
BN_free(new_dmq1);
|
||||
BN_free(new_iqmp);
|
||||
RSA_free(rsa);
|
||||
return 0;
|
||||
}
|
||||
|
@ -1387,12 +1387,12 @@ info(void *opt, int argc, char **argv)
|
||||
{
|
||||
const RSA_METHOD *m = RSA_get_default_method();
|
||||
if (m != NULL)
|
||||
printf("rsa: %s\n", m->name);
|
||||
printf("rsa: %s\n", RSA_meth_get0_name(m));
|
||||
}
|
||||
{
|
||||
const DH_METHOD *m = DH_get_default_method();
|
||||
if (m != NULL)
|
||||
printf("dh: %s\n", m->name);
|
||||
printf("dh: %s\n", DH_meth_get0_name(m));
|
||||
}
|
||||
#ifdef HAVE_OPENSSL
|
||||
{
|
||||
|
@ -107,11 +107,18 @@ try_decrypt(hx509_context context,
|
||||
clear.length = len;
|
||||
|
||||
{
|
||||
EVP_CIPHER_CTX ctx;
|
||||
EVP_CIPHER_CTX_init(&ctx);
|
||||
EVP_CipherInit_ex(&ctx, c, NULL, key, ivdata, 0);
|
||||
EVP_Cipher(&ctx, clear.data, cipher, len);
|
||||
EVP_CIPHER_CTX_cleanup(&ctx);
|
||||
EVP_CIPHER_CTX *ctx;
|
||||
|
||||
ctx = EVP_CIPHER_CTX_new();
|
||||
if (ctx == NULL) {
|
||||
hx509_set_error_string(context, 0, ENOMEM,
|
||||
"Out of memory to decrypt for private key");
|
||||
ret = ENOMEM;
|
||||
goto out;
|
||||
}
|
||||
EVP_CipherInit_ex(ctx, c, NULL, key, ivdata, 0);
|
||||
EVP_Cipher(ctx, clear.data, cipher, len);
|
||||
EVP_CIPHER_CTX_free(ctx);
|
||||
}
|
||||
|
||||
ret = _hx509_collector_private_key_add(context,
|
||||
@ -122,8 +129,8 @@ try_decrypt(hx509_context context,
|
||||
NULL);
|
||||
|
||||
memset(clear.data, 0, clear.length);
|
||||
free(clear.data);
|
||||
out:
|
||||
free(clear.data);
|
||||
memset(key, 0, keylen);
|
||||
free(key);
|
||||
return ret;
|
||||
|
@ -213,21 +213,47 @@ p11_rsa_finish(RSA *rsa)
|
||||
return 1;
|
||||
}
|
||||
|
||||
static const RSA_METHOD p11_rsa_pkcs1_method = {
|
||||
"hx509 PKCS11 PKCS#1 RSA",
|
||||
p11_rsa_public_encrypt,
|
||||
p11_rsa_public_decrypt,
|
||||
p11_rsa_private_encrypt,
|
||||
p11_rsa_private_decrypt,
|
||||
NULL,
|
||||
NULL,
|
||||
p11_rsa_init,
|
||||
p11_rsa_finish,
|
||||
0,
|
||||
NULL,
|
||||
NULL,
|
||||
NULL
|
||||
};
|
||||
static const RSA_METHOD *
|
||||
get_p11_rsa_pkcs1_method(void)
|
||||
{
|
||||
static const RSA_METHOD *p11_rsa_pkcs1_method;
|
||||
RSA_METHOD *new_method;
|
||||
|
||||
if (p11_rsa_pkcs1_method != NULL)
|
||||
return p11_rsa_pkcs1_method;
|
||||
|
||||
new_method = RSA_meth_new("hx509 PKCS11 PKCS#1 RSA", 0);
|
||||
if (new_method == NULL)
|
||||
return NULL;
|
||||
|
||||
if (RSA_meth_set_pub_enc(new_method, p11_rsa_public_encrypt) != 1)
|
||||
goto out;
|
||||
|
||||
if (RSA_meth_set_pub_dec(new_method, p11_rsa_public_decrypt) != 1)
|
||||
goto out;
|
||||
|
||||
if (RSA_meth_set_priv_enc(new_method, p11_rsa_private_encrypt) != 1)
|
||||
goto out;
|
||||
|
||||
if (RSA_meth_set_priv_dec(new_method, p11_rsa_private_decrypt) != 1)
|
||||
goto out;
|
||||
|
||||
if (RSA_meth_set_init(new_method, p11_rsa_init) != 1)
|
||||
goto out;
|
||||
|
||||
if (RSA_meth_set_finish(new_method, p11_rsa_finish) != 1)
|
||||
goto out;
|
||||
|
||||
/*
|
||||
* This might overwrite a previously-created method if multiple
|
||||
* threads invoke this concurrently which will leak memory.
|
||||
*/
|
||||
p11_rsa_pkcs1_method = new_method;
|
||||
return p11_rsa_pkcs1_method;
|
||||
out:
|
||||
RSA_meth_free(new_method);
|
||||
return NULL;
|
||||
}
|
||||
|
||||
/*
|
||||
*
|
||||
@ -607,6 +633,8 @@ collect_private_key(hx509_context context,
|
||||
hx509_private_key key;
|
||||
heim_octet_string localKeyId;
|
||||
int ret;
|
||||
const RSA_METHOD *meth;
|
||||
BIGNUM *n, *e;
|
||||
RSA *rsa;
|
||||
struct p11_rsa *p11rsa;
|
||||
|
||||
@ -626,8 +654,15 @@ collect_private_key(hx509_context context,
|
||||
* the pkcs11 specification, but some smartcards leaves it out,
|
||||
* let ignore any failure to fetch it.
|
||||
*/
|
||||
rsa->n = getattr_bn(p, slot, session, object, CKA_MODULUS);
|
||||
rsa->e = getattr_bn(p, slot, session, object, CKA_PUBLIC_EXPONENT);
|
||||
n = getattr_bn(p, slot, session, object, CKA_MODULUS);
|
||||
e = getattr_bn(p, slot, session, object, CKA_PUBLIC_EXPONENT);
|
||||
if (RSA_set0_key(rsa, n, e, NULL) != 1) {
|
||||
BN_free(n);
|
||||
BN_free(e);
|
||||
RSA_free(rsa);
|
||||
hx509_private_key_free(&key);
|
||||
return EINVAL;
|
||||
}
|
||||
|
||||
p11rsa = calloc(1, sizeof(*p11rsa));
|
||||
if (p11rsa == NULL)
|
||||
@ -643,7 +678,10 @@ collect_private_key(hx509_context context,
|
||||
if (p->ref == UINT_MAX)
|
||||
_hx509_abort("pkcs11 ref == UINT_MAX on alloc");
|
||||
|
||||
RSA_set_method(rsa, &p11_rsa_pkcs1_method);
|
||||
meth = get_p11_rsa_pkcs1_method();
|
||||
if (meth == NULL)
|
||||
_hx509_abort("failed to create RSA method");
|
||||
RSA_set_method(rsa, meth);
|
||||
ret = RSA_set_app_data(rsa, p11rsa);
|
||||
if (ret != 1)
|
||||
_hx509_abort("RSA_set_app_data");
|
||||
|
@ -124,13 +124,15 @@ AES_PRF(krb5_context context,
|
||||
|
||||
{
|
||||
const EVP_CIPHER *c = (*crypto->et->keytype->evp)();
|
||||
EVP_CIPHER_CTX ctx;
|
||||
EVP_CIPHER_CTX *ctx;
|
||||
|
||||
EVP_CIPHER_CTX_init(&ctx); /* ivec all zero */
|
||||
EVP_CipherInit_ex(&ctx, c, NULL, derived->keyvalue.data, NULL, 1);
|
||||
EVP_Cipher(&ctx, out->data, result.checksum.data,
|
||||
ctx = EVP_CIPHER_CTX_new(); /* ivec all zero */
|
||||
if (ctx == NULL)
|
||||
krb5_abortx(context, "malloc failed");
|
||||
EVP_CipherInit_ex(ctx, c, NULL, derived->keyvalue.data, NULL, 1);
|
||||
EVP_Cipher(ctx, out->data, result.checksum.data,
|
||||
crypto->et->blocksize);
|
||||
EVP_CIPHER_CTX_cleanup(&ctx);
|
||||
EVP_CIPHER_CTX_free(ctx);
|
||||
}
|
||||
|
||||
krb5_data_free(&result.checksum);
|
||||
|
@ -129,7 +129,7 @@ ARCFOUR_subencrypt(krb5_context context,
|
||||
unsigned usage,
|
||||
void *ivec)
|
||||
{
|
||||
EVP_CIPHER_CTX ctx;
|
||||
EVP_CIPHER_CTX *ctx;
|
||||
struct _krb5_checksum_type *c = _krb5_find_checksum (CKSUMTYPE_RSA_MD5);
|
||||
Checksum k1_c, k2_c, k3_c, cksum;
|
||||
struct _krb5_key_data ke;
|
||||
@ -176,11 +176,13 @@ ARCFOUR_subencrypt(krb5_context context,
|
||||
if (ret)
|
||||
krb5_abortx(context, "hmac failed");
|
||||
|
||||
EVP_CIPHER_CTX_init(&ctx);
|
||||
ctx = EVP_CIPHER_CTX_new();
|
||||
if (ctx == NULL)
|
||||
krb5_abortx(context, "malloc failed");
|
||||
|
||||
EVP_CipherInit_ex(&ctx, EVP_rc4(), NULL, k3_c.checksum.data, NULL, 1);
|
||||
EVP_Cipher(&ctx, cdata + 16, cdata + 16, len - 16);
|
||||
EVP_CIPHER_CTX_cleanup(&ctx);
|
||||
EVP_CipherInit_ex(ctx, EVP_rc4(), NULL, k3_c.checksum.data, NULL, 1);
|
||||
EVP_Cipher(ctx, cdata + 16, cdata + 16, len - 16);
|
||||
EVP_CIPHER_CTX_free(ctx);
|
||||
|
||||
memset (k1_c_data, 0, sizeof(k1_c_data));
|
||||
memset (k2_c_data, 0, sizeof(k2_c_data));
|
||||
@ -196,7 +198,7 @@ ARCFOUR_subdecrypt(krb5_context context,
|
||||
unsigned usage,
|
||||
void *ivec)
|
||||
{
|
||||
EVP_CIPHER_CTX ctx;
|
||||
EVP_CIPHER_CTX *ctx;
|
||||
struct _krb5_checksum_type *c = _krb5_find_checksum (CKSUMTYPE_RSA_MD5);
|
||||
Checksum k1_c, k2_c, k3_c, cksum;
|
||||
struct _krb5_key_data ke;
|
||||
@ -234,10 +236,12 @@ ARCFOUR_subdecrypt(krb5_context context,
|
||||
if (ret)
|
||||
krb5_abortx(context, "hmac failed");
|
||||
|
||||
EVP_CIPHER_CTX_init(&ctx);
|
||||
EVP_CipherInit_ex(&ctx, EVP_rc4(), NULL, k3_c.checksum.data, NULL, 0);
|
||||
EVP_Cipher(&ctx, cdata + 16, cdata + 16, len - 16);
|
||||
EVP_CIPHER_CTX_cleanup(&ctx);
|
||||
ctx = EVP_CIPHER_CTX_new();
|
||||
if (ctx == NULL)
|
||||
krb5_abortx(context, "malloc failed");
|
||||
EVP_CipherInit_ex(ctx, EVP_rc4(), NULL, k3_c.checksum.data, NULL, 0);
|
||||
EVP_Cipher(ctx, cdata + 16, cdata + 16, len - 16);
|
||||
EVP_CIPHER_CTX_free(ctx);
|
||||
|
||||
ke.key = &kb;
|
||||
kb.keyvalue = k2_c.checksum;
|
||||
|
@ -81,8 +81,8 @@ _krb5_des_checksum(krb5_context context,
|
||||
EVP_DigestFinal_ex (m, p + 8, NULL);
|
||||
EVP_MD_CTX_destroy(m);
|
||||
memset (&ivec, 0, sizeof(ivec));
|
||||
EVP_CipherInit_ex(&ctx->ectx, NULL, NULL, NULL, (void *)&ivec, -1);
|
||||
EVP_Cipher(&ctx->ectx, p, p, 24);
|
||||
EVP_CipherInit_ex(ctx->ectx, NULL, NULL, NULL, (void *)&ivec, -1);
|
||||
EVP_Cipher(ctx->ectx, p, p, 24);
|
||||
|
||||
return 0;
|
||||
}
|
||||
@ -109,8 +109,8 @@ _krb5_des_verify(krb5_context context,
|
||||
}
|
||||
|
||||
memset(&ivec, 0, sizeof(ivec));
|
||||
EVP_CipherInit_ex(&ctx->dctx, NULL, NULL, NULL, (void *)&ivec, -1);
|
||||
EVP_Cipher(&ctx->dctx, tmp, C->checksum.data, 24);
|
||||
EVP_CipherInit_ex(ctx->dctx, NULL, NULL, NULL, (void *)&ivec, -1);
|
||||
EVP_Cipher(ctx->dctx, tmp, C->checksum.data, 24);
|
||||
|
||||
EVP_DigestInit_ex(m, evp_md, NULL);
|
||||
EVP_DigestUpdate(m, tmp, 8); /* confounder */
|
||||
|
@ -225,7 +225,7 @@ evp_des_encrypt_null_ivec(krb5_context context,
|
||||
EVP_CIPHER_CTX *c;
|
||||
DES_cblock ivec;
|
||||
memset(&ivec, 0, sizeof(ivec));
|
||||
c = encryptp ? &ctx->ectx : &ctx->dctx;
|
||||
c = encryptp ? ctx->ectx : ctx->dctx;
|
||||
EVP_CipherInit_ex(c, NULL, NULL, NULL, (void *)&ivec, -1);
|
||||
EVP_Cipher(c, data, data, len);
|
||||
return 0;
|
||||
@ -244,7 +244,7 @@ evp_des_encrypt_key_ivec(krb5_context context,
|
||||
EVP_CIPHER_CTX *c;
|
||||
DES_cblock ivec;
|
||||
memcpy(&ivec, key->key->keyvalue.data, sizeof(ivec));
|
||||
c = encryptp ? &ctx->ectx : &ctx->dctx;
|
||||
c = encryptp ? ctx->ectx : ctx->dctx;
|
||||
EVP_CipherInit_ex(c, NULL, NULL, NULL, (void *)&ivec, -1);
|
||||
EVP_Cipher(c, data, data, len);
|
||||
return 0;
|
||||
|
@ -41,19 +41,21 @@ _krb5_evp_schedule(krb5_context context,
|
||||
struct _krb5_evp_schedule *key = kd->schedule->data;
|
||||
const EVP_CIPHER *c = (*kt->evp)();
|
||||
|
||||
EVP_CIPHER_CTX_init(&key->ectx);
|
||||
EVP_CIPHER_CTX_init(&key->dctx);
|
||||
key->ectx = EVP_CIPHER_CTX_new();
|
||||
key->dctx = EVP_CIPHER_CTX_new();
|
||||
if (key->ectx == NULL || key->dctx == NULL)
|
||||
krb5_abort(context, ENOMEM, "malloc failed");
|
||||
|
||||
EVP_CipherInit_ex(&key->ectx, c, NULL, kd->key->keyvalue.data, NULL, 1);
|
||||
EVP_CipherInit_ex(&key->dctx, c, NULL, kd->key->keyvalue.data, NULL, 0);
|
||||
EVP_CipherInit_ex(key->ectx, c, NULL, kd->key->keyvalue.data, NULL, 1);
|
||||
EVP_CipherInit_ex(key->dctx, c, NULL, kd->key->keyvalue.data, NULL, 0);
|
||||
}
|
||||
|
||||
void
|
||||
_krb5_evp_cleanup(krb5_context context, struct _krb5_key_data *kd)
|
||||
{
|
||||
struct _krb5_evp_schedule *key = kd->schedule->data;
|
||||
EVP_CIPHER_CTX_cleanup(&key->ectx);
|
||||
EVP_CIPHER_CTX_cleanup(&key->dctx);
|
||||
EVP_CIPHER_CTX_free(key->ectx);
|
||||
EVP_CIPHER_CTX_free(key->dctx);
|
||||
}
|
||||
|
||||
krb5_error_code
|
||||
@ -67,7 +69,7 @@ _krb5_evp_encrypt(krb5_context context,
|
||||
{
|
||||
struct _krb5_evp_schedule *ctx = key->schedule->data;
|
||||
EVP_CIPHER_CTX *c;
|
||||
c = encryptp ? &ctx->ectx : &ctx->dctx;
|
||||
c = encryptp ? ctx->ectx : ctx->dctx;
|
||||
if (ivec == NULL) {
|
||||
/* alloca ? */
|
||||
size_t len2 = EVP_CIPHER_CTX_iv_length(c);
|
||||
@ -102,7 +104,7 @@ _krb5_evp_encrypt_cts(krb5_context context,
|
||||
EVP_CIPHER_CTX *c;
|
||||
unsigned char *p;
|
||||
|
||||
c = encryptp ? &ctx->ectx : &ctx->dctx;
|
||||
c = encryptp ? ctx->ectx : ctx->dctx;
|
||||
|
||||
blocksize = EVP_CIPHER_CTX_block_size(c);
|
||||
|
||||
|
@ -63,6 +63,7 @@ seed_something(void)
|
||||
we do not have to deal with it. */
|
||||
if (RAND_status() != 1) {
|
||||
#ifndef _WIN32
|
||||
#ifndef OPENSSL_NO_EGD
|
||||
krb5_context context;
|
||||
const char *p;
|
||||
|
||||
@ -74,6 +75,7 @@ seed_something(void)
|
||||
RAND_egd_bytes(p, ENTROPY_NEEDED);
|
||||
krb5_free_context(context);
|
||||
}
|
||||
#endif
|
||||
#else
|
||||
/* TODO: Once a Windows CryptoAPI RAND method is defined, we
|
||||
can use that and failover to another method. */
|
||||
|
@ -174,6 +174,6 @@ extern int _krb5_num_etypes;
|
||||
|
||||
/* Interface to the EVP crypto layer provided by hcrypto */
|
||||
struct _krb5_evp_schedule {
|
||||
EVP_CIPHER_CTX ectx;
|
||||
EVP_CIPHER_CTX dctx;
|
||||
EVP_CIPHER_CTX *ectx;
|
||||
EVP_CIPHER_CTX *dctx;
|
||||
};
|
||||
|
@ -101,7 +101,7 @@ _krb5_pk_cert_free(struct krb5_pk_cert *cert)
|
||||
}
|
||||
|
||||
static krb5_error_code
|
||||
BN_to_integer(krb5_context context, BIGNUM *bn, heim_integer *integer)
|
||||
BN_to_integer(krb5_context context, const BIGNUM *bn, heim_integer *integer)
|
||||
{
|
||||
integer->length = BN_num_bytes(bn);
|
||||
integer->data = malloc(integer->length);
|
||||
@ -134,6 +134,7 @@ select_dh_group(krb5_context context, DH *dh, unsigned long bits,
|
||||
struct krb5_dh_moduli **moduli)
|
||||
{
|
||||
const struct krb5_dh_moduli *m;
|
||||
BIGNUM *p, *g, *q;
|
||||
|
||||
if (bits == 0) {
|
||||
m = moduli[1]; /* XXX */
|
||||
@ -155,15 +156,22 @@ select_dh_group(krb5_context context, DH *dh, unsigned long bits,
|
||||
m = moduli[i];
|
||||
}
|
||||
|
||||
dh->p = integer_to_BN(context, "p", &m->p);
|
||||
if (dh->p == NULL)
|
||||
return ENOMEM;
|
||||
dh->g = integer_to_BN(context, "g", &m->g);
|
||||
if (dh->g == NULL)
|
||||
return ENOMEM;
|
||||
dh->q = integer_to_BN(context, "q", &m->q);
|
||||
if (dh->q == NULL)
|
||||
p = integer_to_BN(context, "p", &m->p);
|
||||
g = integer_to_BN(context, "g", &m->g);
|
||||
q = integer_to_BN(context, "q", &m->q);
|
||||
if (p == NULL || g == NULL || q == NULL) {
|
||||
BN_free(p);
|
||||
BN_free(g);
|
||||
BN_free(q);
|
||||
return ENOMEM;
|
||||
}
|
||||
|
||||
if (DH_set0_pqg(dh, p, q, g) != 1) {
|
||||
BN_free(p);
|
||||
BN_free(g);
|
||||
BN_free(q);
|
||||
return EINVAL;
|
||||
}
|
||||
|
||||
return 0;
|
||||
}
|
||||
@ -477,6 +485,7 @@ build_auth_pack(krb5_context context,
|
||||
|
||||
if (ctx->keyex == USE_DH) {
|
||||
DH *dh = ctx->u.dh;
|
||||
const BIGNUM *p, *g, *q, *pub_key;
|
||||
DomainParameters dp;
|
||||
heim_integer dh_pub_key;
|
||||
|
||||
@ -487,17 +496,18 @@ build_auth_pack(krb5_context context,
|
||||
|
||||
memset(&dp, 0, sizeof(dp));
|
||||
|
||||
ret = BN_to_integer(context, dh->p, &dp.p);
|
||||
DH_get0_pqg(dh, &p, &q, &g);
|
||||
ret = BN_to_integer(context, p, &dp.p);
|
||||
if (ret) {
|
||||
free_DomainParameters(&dp);
|
||||
return ret;
|
||||
}
|
||||
ret = BN_to_integer(context, dh->g, &dp.g);
|
||||
ret = BN_to_integer(context, g, &dp.g);
|
||||
if (ret) {
|
||||
free_DomainParameters(&dp);
|
||||
return ret;
|
||||
}
|
||||
ret = BN_to_integer(context, dh->q, &dp.q);
|
||||
ret = BN_to_integer(context, q, &dp.q);
|
||||
if (ret) {
|
||||
free_DomainParameters(&dp);
|
||||
return ret;
|
||||
@ -522,7 +532,8 @@ build_auth_pack(krb5_context context,
|
||||
if (size != a->clientPublicValue->algorithm.parameters->length)
|
||||
krb5_abortx(context, "Internal ASN1 encoder error");
|
||||
|
||||
ret = BN_to_integer(context, dh->pub_key, &dh_pub_key);
|
||||
DH_get0_key(dh, &pub_key, NULL);
|
||||
ret = BN_to_integer(context, pub_key, &dh_pub_key);
|
||||
if (ret)
|
||||
return ret;
|
||||
|
||||
|
@ -87,7 +87,7 @@ heim_ntlm_decode_type3 (
|
||||
int /*ucs2*/,
|
||||
struct ntlm_type3 */*type3*/);
|
||||
|
||||
void
|
||||
int
|
||||
heim_ntlm_derive_ntlm2_sess (
|
||||
const unsigned char sessionkey[16],
|
||||
const unsigned char */*clnt_nonce*/,
|
||||
|
@ -1011,12 +1011,12 @@ heim_ntlm_encode_type3(const struct ntlm_type3 *type3, struct ntlm_buf *data)
|
||||
*
|
||||
*/
|
||||
|
||||
static void
|
||||
static int
|
||||
splitandenc(unsigned char *hash,
|
||||
unsigned char *challenge,
|
||||
unsigned char *answer)
|
||||
{
|
||||
EVP_CIPHER_CTX ctx;
|
||||
EVP_CIPHER_CTX *ctx;
|
||||
unsigned char key[8];
|
||||
|
||||
key[0] = hash[0];
|
||||
@ -1028,12 +1028,15 @@ splitandenc(unsigned char *hash,
|
||||
key[6] = (hash[5] << 2) | (hash[6] >> 6);
|
||||
key[7] = (hash[6] << 1);
|
||||
|
||||
EVP_CIPHER_CTX_init(&ctx);
|
||||
ctx = EVP_CIPHER_CTX_new();
|
||||
if (ctx == NULL)
|
||||
return ENOMEM;
|
||||
|
||||
EVP_CipherInit_ex(&ctx, EVP_des_cbc(), NULL, key, NULL, 1);
|
||||
EVP_Cipher(&ctx, answer, challenge, 8);
|
||||
EVP_CIPHER_CTX_cleanup(&ctx);
|
||||
EVP_CipherInit_ex(ctx, EVP_des_cbc(), NULL, key, NULL, 1);
|
||||
EVP_Cipher(ctx, answer, challenge, 8);
|
||||
EVP_CIPHER_CTX_free(ctx);
|
||||
memset(key, 0, sizeof(key));
|
||||
return 0;
|
||||
}
|
||||
|
||||
/**
|
||||
@ -1102,6 +1105,7 @@ heim_ntlm_calculate_ntlm1(void *key, size_t len,
|
||||
struct ntlm_buf *answer)
|
||||
{
|
||||
unsigned char res[21];
|
||||
int ret;
|
||||
|
||||
if (len != MD4_DIGEST_LENGTH)
|
||||
return HNTLM_ERR_INVALID_LENGTH;
|
||||
@ -1114,11 +1118,21 @@ heim_ntlm_calculate_ntlm1(void *key, size_t len,
|
||||
return ENOMEM;
|
||||
answer->length = 24;
|
||||
|
||||
splitandenc(&res[0], challenge, ((unsigned char *)answer->data) + 0);
|
||||
splitandenc(&res[7], challenge, ((unsigned char *)answer->data) + 8);
|
||||
splitandenc(&res[14], challenge, ((unsigned char *)answer->data) + 16);
|
||||
ret = splitandenc(&res[0], challenge, ((unsigned char *)answer->data) + 0);
|
||||
if (ret)
|
||||
goto out;
|
||||
ret = splitandenc(&res[7], challenge, ((unsigned char *)answer->data) + 8);
|
||||
if (ret)
|
||||
goto out;
|
||||
ret = splitandenc(&res[14], challenge, ((unsigned char *)answer->data) + 16);
|
||||
if (ret)
|
||||
goto out;
|
||||
|
||||
return 0;
|
||||
|
||||
out:
|
||||
heim_ntlm_free_buf(answer);
|
||||
return ret;
|
||||
}
|
||||
|
||||
int
|
||||
@ -1153,7 +1167,7 @@ heim_ntlm_v2_base_session(void *key, size_t len,
|
||||
struct ntlm_buf *session)
|
||||
{
|
||||
unsigned int hmaclen;
|
||||
HMAC_CTX c;
|
||||
HMAC_CTX *c;
|
||||
|
||||
if (ntlmResponse->length <= 16)
|
||||
return HNTLM_ERR_INVALID_LENGTH;
|
||||
@ -1164,11 +1178,15 @@ heim_ntlm_v2_base_session(void *key, size_t len,
|
||||
session->length = 16;
|
||||
|
||||
/* Note: key is the NTLMv2 key */
|
||||
HMAC_CTX_init(&c);
|
||||
HMAC_Init_ex(&c, key, len, EVP_md5(), NULL);
|
||||
HMAC_Update(&c, ntlmResponse->data, 16);
|
||||
HMAC_Final(&c, session->data, &hmaclen);
|
||||
HMAC_CTX_cleanup(&c);
|
||||
c = HMAC_CTX_new();
|
||||
if (c == NULL) {
|
||||
heim_ntlm_free_buf(session);
|
||||
return ENOMEM;
|
||||
}
|
||||
HMAC_Init_ex(c, key, len, EVP_md5(), NULL);
|
||||
HMAC_Update(c, ntlmResponse->data, 16);
|
||||
HMAC_Final(c, session->data, &hmaclen);
|
||||
HMAC_CTX_free(c);
|
||||
|
||||
return 0;
|
||||
}
|
||||
@ -1179,7 +1197,7 @@ heim_ntlm_keyex_wrap(struct ntlm_buf *base_session,
|
||||
struct ntlm_buf *session,
|
||||
struct ntlm_buf *encryptedSession)
|
||||
{
|
||||
EVP_CIPHER_CTX c;
|
||||
EVP_CIPHER_CTX *c;
|
||||
int ret;
|
||||
|
||||
session->length = MD4_DIGEST_LENGTH;
|
||||
@ -1196,25 +1214,30 @@ heim_ntlm_keyex_wrap(struct ntlm_buf *base_session,
|
||||
return ENOMEM;
|
||||
}
|
||||
|
||||
EVP_CIPHER_CTX_init(&c);
|
||||
c = EVP_CIPHER_CTX_new();
|
||||
if (c == NULL) {
|
||||
heim_ntlm_free_buf(encryptedSession);
|
||||
heim_ntlm_free_buf(session);
|
||||
return ENOMEM;
|
||||
}
|
||||
|
||||
ret = EVP_CipherInit_ex(&c, EVP_rc4(), NULL, base_session->data, NULL, 1);
|
||||
ret = EVP_CipherInit_ex(c, EVP_rc4(), NULL, base_session->data, NULL, 1);
|
||||
if (ret != 1) {
|
||||
EVP_CIPHER_CTX_cleanup(&c);
|
||||
EVP_CIPHER_CTX_free(c);
|
||||
heim_ntlm_free_buf(encryptedSession);
|
||||
heim_ntlm_free_buf(session);
|
||||
return HNTLM_ERR_CRYPTO;
|
||||
}
|
||||
|
||||
if (RAND_bytes(session->data, session->length) != 1) {
|
||||
EVP_CIPHER_CTX_cleanup(&c);
|
||||
EVP_CIPHER_CTX_free(c);
|
||||
heim_ntlm_free_buf(encryptedSession);
|
||||
heim_ntlm_free_buf(session);
|
||||
return HNTLM_ERR_RAND;
|
||||
}
|
||||
|
||||
EVP_Cipher(&c, encryptedSession->data, session->data, encryptedSession->length);
|
||||
EVP_CIPHER_CTX_cleanup(&c);
|
||||
EVP_Cipher(c, encryptedSession->data, session->data, encryptedSession->length);
|
||||
EVP_CIPHER_CTX_free(c);
|
||||
|
||||
return 0;
|
||||
|
||||
@ -1309,7 +1332,7 @@ heim_ntlm_keyex_unwrap(struct ntlm_buf *baseKey,
|
||||
struct ntlm_buf *encryptedSession,
|
||||
struct ntlm_buf *session)
|
||||
{
|
||||
EVP_CIPHER_CTX c;
|
||||
EVP_CIPHER_CTX *c;
|
||||
|
||||
memset(session, 0, sizeof(*session));
|
||||
|
||||
@ -1322,16 +1345,20 @@ heim_ntlm_keyex_unwrap(struct ntlm_buf *baseKey,
|
||||
session->length = 0;
|
||||
return ENOMEM;
|
||||
}
|
||||
EVP_CIPHER_CTX_init(&c);
|
||||
c = EVP_CIPHER_CTX_new();
|
||||
if (c == NULL) {
|
||||
heim_ntlm_free_buf(session);
|
||||
return ENOMEM;
|
||||
}
|
||||
|
||||
if (EVP_CipherInit_ex(&c, EVP_rc4(), NULL, baseKey->data, NULL, 0) != 1) {
|
||||
EVP_CIPHER_CTX_cleanup(&c);
|
||||
if (EVP_CipherInit_ex(c, EVP_rc4(), NULL, baseKey->data, NULL, 0) != 1) {
|
||||
EVP_CIPHER_CTX_free(c);
|
||||
heim_ntlm_free_buf(session);
|
||||
return HNTLM_ERR_CRYPTO;
|
||||
}
|
||||
|
||||
EVP_Cipher(&c, session->data, encryptedSession->data, session->length);
|
||||
EVP_CIPHER_CTX_cleanup(&c);
|
||||
EVP_Cipher(c, session->data, encryptedSession->data, session->length);
|
||||
EVP_CIPHER_CTX_free(c);
|
||||
|
||||
return 0;
|
||||
}
|
||||
@ -1359,28 +1386,30 @@ heim_ntlm_ntlmv2_key(const void *key, size_t len,
|
||||
{
|
||||
int ret;
|
||||
unsigned int hmaclen;
|
||||
HMAC_CTX c;
|
||||
HMAC_CTX *c;
|
||||
|
||||
HMAC_CTX_init(&c);
|
||||
HMAC_Init_ex(&c, key, len, EVP_md5(), NULL);
|
||||
c = HMAC_CTX_new();
|
||||
if (c == NULL)
|
||||
return ENOMEM;
|
||||
HMAC_Init_ex(c, key, len, EVP_md5(), NULL);
|
||||
{
|
||||
struct ntlm_buf buf;
|
||||
/* uppercase username and turn it into ucs2-le */
|
||||
ret = ascii2ucs2le(username, 1, &buf);
|
||||
if (ret)
|
||||
goto out;
|
||||
HMAC_Update(&c, buf.data, buf.length);
|
||||
HMAC_Update(c, buf.data, buf.length);
|
||||
free(buf.data);
|
||||
/* uppercase target and turn into ucs2-le */
|
||||
ret = ascii2ucs2le(target, 1, &buf);
|
||||
if (ret)
|
||||
goto out;
|
||||
HMAC_Update(&c, buf.data, buf.length);
|
||||
HMAC_Update(c, buf.data, buf.length);
|
||||
free(buf.data);
|
||||
}
|
||||
HMAC_Final(&c, ntlmv2, &hmaclen);
|
||||
HMAC_Final(c, ntlmv2, &hmaclen);
|
||||
out:
|
||||
HMAC_CTX_cleanup(&c);
|
||||
HMAC_CTX_free(c);
|
||||
|
||||
return ret;
|
||||
}
|
||||
@ -1434,6 +1463,7 @@ heim_ntlm_calculate_lm2(const void *key, size_t len,
|
||||
struct ntlm_buf *answer)
|
||||
{
|
||||
unsigned char clientchallenge[8];
|
||||
int ret;
|
||||
|
||||
if (RAND_bytes(clientchallenge, sizeof(clientchallenge)) != 1)
|
||||
return HNTLM_ERR_RAND;
|
||||
@ -1447,8 +1477,10 @@ heim_ntlm_calculate_lm2(const void *key, size_t len,
|
||||
return ENOMEM;
|
||||
answer->length = 24;
|
||||
|
||||
heim_ntlm_derive_ntlm2_sess(ntlmv2, clientchallenge, 8,
|
||||
ret = heim_ntlm_derive_ntlm2_sess(ntlmv2, clientchallenge, 8,
|
||||
serverchallenge, answer->data);
|
||||
if (ret)
|
||||
return ret;
|
||||
|
||||
memcpy(((uint8_t *)answer->data) + 16, clientchallenge, 8);
|
||||
|
||||
@ -1489,6 +1521,7 @@ heim_ntlm_calculate_ntlm2(const void *key, size_t len,
|
||||
krb5_storage *sp;
|
||||
unsigned char clientchallenge[8];
|
||||
uint64_t t;
|
||||
int code;
|
||||
|
||||
t = unix2nttime(time(NULL));
|
||||
|
||||
@ -1523,7 +1556,11 @@ heim_ntlm_calculate_ntlm2(const void *key, size_t len,
|
||||
krb5_storage_free(sp);
|
||||
sp = NULL;
|
||||
|
||||
heim_ntlm_derive_ntlm2_sess(ntlmv2, data.data, data.length, serverchallenge, ntlmv2answer);
|
||||
code = heim_ntlm_derive_ntlm2_sess(ntlmv2, data.data, data.length, serverchallenge, ntlmv2answer);
|
||||
if (code) {
|
||||
krb5_data_free(&data);
|
||||
return code;
|
||||
}
|
||||
|
||||
sp = krb5_storage_emem();
|
||||
if (sp == NULL) {
|
||||
@ -1588,6 +1625,7 @@ heim_ntlm_verify_ntlm2(const void *key, size_t len,
|
||||
time_t authtime;
|
||||
uint32_t temp;
|
||||
uint64_t t;
|
||||
int code;
|
||||
|
||||
infotarget->length = 0;
|
||||
infotarget->data = NULL;
|
||||
@ -1651,10 +1689,12 @@ heim_ntlm_verify_ntlm2(const void *key, size_t len,
|
||||
goto out;
|
||||
}
|
||||
|
||||
heim_ntlm_derive_ntlm2_sess(ntlmv2,
|
||||
ret = heim_ntlm_derive_ntlm2_sess(ntlmv2,
|
||||
((unsigned char *)answer->data) + 16, answer->length - 16,
|
||||
serverchallenge,
|
||||
serveranswer);
|
||||
if (ret)
|
||||
goto out;
|
||||
|
||||
if (memcmp(serveranswer, clientanswer, 16) != 0) {
|
||||
heim_ntlm_free_buf(infotarget);
|
||||
@ -1724,11 +1764,22 @@ heim_ntlm_calculate_ntlm2_sess(const unsigned char clnt_nonce[8],
|
||||
memcpy(res, ntlm_hash, 16);
|
||||
|
||||
resp = ntlm->data;
|
||||
splitandenc(&res[0], ntlm2_sess_hash, resp + 0);
|
||||
splitandenc(&res[7], ntlm2_sess_hash, resp + 8);
|
||||
splitandenc(&res[14], ntlm2_sess_hash, resp + 16);
|
||||
code = splitandenc(&res[0], ntlm2_sess_hash, resp + 0);
|
||||
if (code)
|
||||
goto out;
|
||||
code = splitandenc(&res[7], ntlm2_sess_hash, resp + 8);
|
||||
if (code)
|
||||
goto out;
|
||||
code = splitandenc(&res[14], ntlm2_sess_hash, resp + 16);
|
||||
if (code)
|
||||
goto out;
|
||||
|
||||
return 0;
|
||||
|
||||
out:
|
||||
heim_ntlm_free_buf(ntlm);
|
||||
heim_ntlm_free_buf(lm);
|
||||
return code;
|
||||
}
|
||||
|
||||
|
||||
@ -1783,21 +1834,24 @@ heim_ntlm_calculate_ntlm2_sess_hash(const unsigned char clnt_nonce[8],
|
||||
* @ingroup ntlm_core
|
||||
*/
|
||||
|
||||
void
|
||||
int
|
||||
heim_ntlm_derive_ntlm2_sess(const unsigned char sessionkey[16],
|
||||
const unsigned char *clnt_nonce, size_t clnt_nonce_length,
|
||||
const unsigned char svr_chal[8],
|
||||
unsigned char derivedkey[16])
|
||||
{
|
||||
unsigned int hmaclen;
|
||||
HMAC_CTX c;
|
||||
HMAC_CTX *c;
|
||||
|
||||
/* HMAC(Ksession, serverchallenge || clientchallenge) */
|
||||
HMAC_CTX_init(&c);
|
||||
HMAC_Init_ex(&c, sessionkey, 16, EVP_md5(), NULL);
|
||||
HMAC_Update(&c, svr_chal, 8);
|
||||
HMAC_Update(&c, clnt_nonce, clnt_nonce_length);
|
||||
HMAC_Final(&c, derivedkey, &hmaclen);
|
||||
HMAC_CTX_cleanup(&c);
|
||||
c = HMAC_CTX_new();
|
||||
if (c == NULL)
|
||||
return ENOMEM;
|
||||
HMAC_Init_ex(c, sessionkey, 16, EVP_md5(), NULL);
|
||||
HMAC_Update(c, svr_chal, 8);
|
||||
HMAC_Update(c, clnt_nonce, clnt_nonce_length);
|
||||
HMAC_Final(c, derivedkey, &hmaclen);
|
||||
HMAC_CTX_free(c);
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
@ -498,7 +498,7 @@ xyzprintf (struct snprintf_state *state, const char *char_format, va_list ap)
|
||||
break;
|
||||
}
|
||||
case 'p' : {
|
||||
u_longest arg = (u_longest)va_arg(ap, void*);
|
||||
u_longest arg = (uintptr_t)va_arg(ap, void*);
|
||||
|
||||
len += append_number (state, arg, 0x10, "0123456789ABCDEF",
|
||||
width, prec, flags, 0);
|
||||
|
@ -395,19 +395,19 @@
|
||||
/* #undef HAVE_DEV_PTS_AND_PTC */
|
||||
|
||||
/* Define if libcrypto has DH_get0_key */
|
||||
/* #undef HAVE_DH_GET0_KEY */
|
||||
#define HAVE_DH_GET0_KEY 1
|
||||
|
||||
/* Define if libcrypto has DH_get0_pqg */
|
||||
/* #undef HAVE_DH_GET0_PQG */
|
||||
#define HAVE_DH_GET0_PQG 1
|
||||
|
||||
/* Define if libcrypto has DH_set0_key */
|
||||
/* #undef HAVE_DH_SET0_KEY */
|
||||
#define HAVE_DH_SET0_KEY 1
|
||||
|
||||
/* Define if libcrypto has DH_set0_pqg */
|
||||
/* #undef HAVE_DH_SET0_PQG */
|
||||
#define HAVE_DH_SET0_PQG 1
|
||||
|
||||
/* Define if libcrypto has DH_set_length */
|
||||
/* #undef HAVE_DH_SET_LENGTH */
|
||||
#define HAVE_DH_SET_LENGTH 1
|
||||
|
||||
/* Define to 1 if you have the <dirent.h> header file. */
|
||||
#define HAVE_DIRENT_H 1
|
||||
@ -422,28 +422,28 @@
|
||||
#define HAVE_DSA_GENERATE_PARAMETERS_EX 1
|
||||
|
||||
/* Define if libcrypto has DSA_get0_key */
|
||||
/* #undef HAVE_DSA_GET0_KEY */
|
||||
#define HAVE_DSA_GET0_KEY 1
|
||||
|
||||
/* Define if libcrypto has DSA_get0_pqg */
|
||||
/* #undef HAVE_DSA_GET0_PQG */
|
||||
#define HAVE_DSA_GET0_PQG 1
|
||||
|
||||
/* Define if libcrypto has DSA_set0_key */
|
||||
/* #undef HAVE_DSA_SET0_KEY */
|
||||
#define HAVE_DSA_SET0_KEY 1
|
||||
|
||||
/* Define if libcrypto has DSA_set0_pqg */
|
||||
/* #undef HAVE_DSA_SET0_PQG */
|
||||
#define HAVE_DSA_SET0_PQG 1
|
||||
|
||||
/* Define if libcrypto has DSA_SIG_get0 */
|
||||
/* #undef HAVE_DSA_SIG_GET0 */
|
||||
#define HAVE_DSA_SIG_GET0 1
|
||||
|
||||
/* Define if libcrypto has DSA_SIG_set0 */
|
||||
/* #undef HAVE_DSA_SIG_SET0 */
|
||||
#define HAVE_DSA_SIG_SET0 1
|
||||
|
||||
/* Define if libcrypto has ECDSA_SIG_get0 */
|
||||
/* #undef HAVE_ECDSA_SIG_GET0 */
|
||||
#define HAVE_ECDSA_SIG_GET0 1
|
||||
|
||||
/* Define if libcrypto has ECDSA_SIG_set0 */
|
||||
/* #undef HAVE_ECDSA_SIG_SET0 */
|
||||
#define HAVE_ECDSA_SIG_SET0 1
|
||||
|
||||
/* Define to 1 if you have the <elf.h> header file. */
|
||||
#define HAVE_ELF_H 1
|
||||
@ -479,10 +479,10 @@
|
||||
/* #undef HAVE_EVP_CIPHER_CTX_GET_IV */
|
||||
|
||||
/* Define if libcrypto has EVP_CIPHER_CTX_iv */
|
||||
/* #undef HAVE_EVP_CIPHER_CTX_IV */
|
||||
#define HAVE_EVP_CIPHER_CTX_IV 1
|
||||
|
||||
/* Define if libcrypto has EVP_CIPHER_CTX_iv_noconst */
|
||||
/* #undef HAVE_EVP_CIPHER_CTX_IV_NOCONST */
|
||||
#define HAVE_EVP_CIPHER_CTX_IV_NOCONST 1
|
||||
|
||||
/* Define to 1 if you have the `EVP_DigestFinal_ex' function. */
|
||||
#define HAVE_EVP_DIGESTFINAL_EX 1
|
||||
@ -491,22 +491,22 @@
|
||||
#define HAVE_EVP_DIGESTINIT_EX 1
|
||||
|
||||
/* Define to 1 if you have the `EVP_MD_CTX_cleanup' function. */
|
||||
#define HAVE_EVP_MD_CTX_CLEANUP 1
|
||||
/* #undef HAVE_EVP_MD_CTX_CLEANUP */
|
||||
|
||||
/* Define to 1 if you have the `EVP_MD_CTX_copy_ex' function. */
|
||||
#define HAVE_EVP_MD_CTX_COPY_EX 1
|
||||
|
||||
/* Define if libcrypto has EVP_MD_CTX_free */
|
||||
/* #undef HAVE_EVP_MD_CTX_FREE */
|
||||
#define HAVE_EVP_MD_CTX_FREE 1
|
||||
|
||||
/* Define to 1 if you have the `EVP_MD_CTX_init' function. */
|
||||
#define HAVE_EVP_MD_CTX_INIT 1
|
||||
/* #undef HAVE_EVP_MD_CTX_INIT */
|
||||
|
||||
/* Define if libcrypto has EVP_MD_CTX_new */
|
||||
/* #undef HAVE_EVP_MD_CTX_NEW */
|
||||
#define HAVE_EVP_MD_CTX_NEW 1
|
||||
|
||||
/* Define if libcrypto has EVP_PKEY_get0_RSA */
|
||||
/* #undef HAVE_EVP_PKEY_GET0_RSA */
|
||||
#define HAVE_EVP_PKEY_GET0_RSA 1
|
||||
|
||||
/* Define to 1 if you have the `EVP_ripemd160' function. */
|
||||
#define HAVE_EVP_RIPEMD160 1
|
||||
@ -704,7 +704,7 @@
|
||||
#define HAVE_HEADER_AD 1
|
||||
|
||||
/* Define to 1 if you have the `HMAC_CTX_init' function. */
|
||||
#define HAVE_HMAC_CTX_INIT 1
|
||||
/* #undef HAVE_HMAC_CTX_INIT */
|
||||
|
||||
/* Define if you have ut_host in utmp.h */
|
||||
/* #undef HAVE_HOST_IN_UTMP */
|
||||
@ -1031,46 +1031,46 @@
|
||||
#define HAVE_RSA_GENERATE_KEY_EX 1
|
||||
|
||||
/* Define if libcrypto has RSA_get0_crt_params */
|
||||
/* #undef HAVE_RSA_GET0_CRT_PARAMS */
|
||||
#define HAVE_RSA_GET0_CRT_PARAMS 1
|
||||
|
||||
/* Define if libcrypto has RSA_get0_factors */
|
||||
/* #undef HAVE_RSA_GET0_FACTORS */
|
||||
#define HAVE_RSA_GET0_FACTORS 1
|
||||
|
||||
/* Define if libcrypto has RSA_get0_key */
|
||||
/* #undef HAVE_RSA_GET0_KEY */
|
||||
#define HAVE_RSA_GET0_KEY 1
|
||||
|
||||
/* Define to 1 if you have the `RSA_get_default_method' function. */
|
||||
#define HAVE_RSA_GET_DEFAULT_METHOD 1
|
||||
|
||||
/* Define if libcrypto has RSA_meth_dup */
|
||||
/* #undef HAVE_RSA_METH_DUP */
|
||||
#define HAVE_RSA_METH_DUP 1
|
||||
|
||||
/* Define if libcrypto has RSA_meth_free */
|
||||
/* #undef HAVE_RSA_METH_FREE */
|
||||
#define HAVE_RSA_METH_FREE 1
|
||||
|
||||
/* Define if libcrypto has RSA_meth_get_finish */
|
||||
/* #undef HAVE_RSA_METH_GET_FINISH */
|
||||
#define HAVE_RSA_METH_GET_FINISH 1
|
||||
|
||||
/* Define if libcrypto has RSA_meth_set1_name */
|
||||
/* #undef HAVE_RSA_METH_SET1_NAME */
|
||||
#define HAVE_RSA_METH_SET1_NAME 1
|
||||
|
||||
/* Define if libcrypto has RSA_meth_set_finish */
|
||||
/* #undef HAVE_RSA_METH_SET_FINISH */
|
||||
#define HAVE_RSA_METH_SET_FINISH 1
|
||||
|
||||
/* Define if libcrypto has RSA_meth_set_priv_dec */
|
||||
/* #undef HAVE_RSA_METH_SET_PRIV_DEC */
|
||||
#define HAVE_RSA_METH_SET_PRIV_DEC 1
|
||||
|
||||
/* Define if libcrypto has RSA_meth_set_priv_enc */
|
||||
/* #undef HAVE_RSA_METH_SET_PRIV_ENC */
|
||||
#define HAVE_RSA_METH_SET_PRIV_ENC 1
|
||||
|
||||
/* Define if libcrypto has RSA_get0_srt_params */
|
||||
/* #undef HAVE_RSA_SET0_CRT_PARAMS */
|
||||
#define HAVE_RSA_SET0_CRT_PARAMS 1
|
||||
|
||||
/* Define if libcrypto has RSA_set0_factors */
|
||||
/* #undef HAVE_RSA_SET0_FACTORS */
|
||||
#define HAVE_RSA_SET0_FACTORS 1
|
||||
|
||||
/* Define if libcrypto has RSA_set0_key */
|
||||
/* #undef HAVE_RSA_SET0_KEY */
|
||||
#define HAVE_RSA_SET0_KEY 1
|
||||
|
||||
/* Define to 1 if you have the <sandbox.h> header file. */
|
||||
/* #undef HAVE_SANDBOX_H */
|
||||
|
@ -8,37 +8,8 @@
|
||||
#define Blowfish_expandstate Fssh_Blowfish_expandstate
|
||||
#define Blowfish_initstate Fssh_Blowfish_initstate
|
||||
#define Blowfish_stream2word Fssh_Blowfish_stream2word
|
||||
#define DH_get0_key Fssh_DH_get0_key
|
||||
#define DH_get0_pqg Fssh_DH_get0_pqg
|
||||
#define DH_set0_key Fssh_DH_set0_key
|
||||
#define DH_set0_pqg Fssh_DH_set0_pqg
|
||||
#define DH_set_length Fssh_DH_set_length
|
||||
#define DSA_SIG_get0 Fssh_DSA_SIG_get0
|
||||
#define DSA_SIG_set0 Fssh_DSA_SIG_set0
|
||||
#define DSA_get0_key Fssh_DSA_get0_key
|
||||
#define DSA_get0_pqg Fssh_DSA_get0_pqg
|
||||
#define DSA_set0_key Fssh_DSA_set0_key
|
||||
#define DSA_set0_pqg Fssh_DSA_set0_pqg
|
||||
#define ECDSA_SIG_get0 Fssh_ECDSA_SIG_get0
|
||||
#define ECDSA_SIG_set0 Fssh_ECDSA_SIG_set0
|
||||
#define EVP_CIPHER_CTX_get_iv Fssh_EVP_CIPHER_CTX_get_iv
|
||||
#define EVP_CIPHER_CTX_set_iv Fssh_EVP_CIPHER_CTX_set_iv
|
||||
#define EVP_MD_CTX_free Fssh_EVP_MD_CTX_free
|
||||
#define EVP_MD_CTX_new Fssh_EVP_MD_CTX_new
|
||||
#define EVP_PKEY_get0_RSA Fssh_EVP_PKEY_get0_RSA
|
||||
#define RSA_get0_crt_params Fssh_RSA_get0_crt_params
|
||||
#define RSA_get0_factors Fssh_RSA_get0_factors
|
||||
#define RSA_get0_key Fssh_RSA_get0_key
|
||||
#define RSA_meth_dup Fssh_RSA_meth_dup
|
||||
#define RSA_meth_free Fssh_RSA_meth_free
|
||||
#define RSA_meth_get_finish Fssh_RSA_meth_get_finish
|
||||
#define RSA_meth_set1_name Fssh_RSA_meth_set1_name
|
||||
#define RSA_meth_set_finish Fssh_RSA_meth_set_finish
|
||||
#define RSA_meth_set_priv_dec Fssh_RSA_meth_set_priv_dec
|
||||
#define RSA_meth_set_priv_enc Fssh_RSA_meth_set_priv_enc
|
||||
#define RSA_set0_crt_params Fssh_RSA_set0_crt_params
|
||||
#define RSA_set0_factors Fssh_RSA_set0_factors
|
||||
#define RSA_set0_key Fssh_RSA_set0_key
|
||||
#define _ssh__compat_glob Fssh__ssh__compat_glob
|
||||
#define _ssh__compat_globfree Fssh__ssh__compat_globfree
|
||||
#define _ssh_compat_realpath Fssh__ssh_compat_realpath
|
||||
|
35
crypto/openssl/AUTHORS
Normal file
35
crypto/openssl/AUTHORS
Normal file
@ -0,0 +1,35 @@
|
||||
# This is the list of OpenSSL authors for copyright purposes.
|
||||
#
|
||||
# This does not necessarily list everyone who has contributed code, since in
|
||||
# some cases, their employer may be the copyright holder. To see the full list
|
||||
# of contributors, see the revision history in source control.
|
||||
OpenSSL Software Services, Inc.
|
||||
OpenSSL Software Foundation, Inc.
|
||||
|
||||
# Individuals
|
||||
Andy Polyakov
|
||||
Ben Laurie
|
||||
Ben Kaduk
|
||||
Bernd Edlinger
|
||||
Bodo Möller
|
||||
David Benjamin
|
||||
Emilia Käsper
|
||||
Eric Young
|
||||
Geoff Thorpe
|
||||
Holger Reif
|
||||
Kurt Roeckx
|
||||
Lutz Jänicke
|
||||
Mark J. Cox
|
||||
Matt Caswell
|
||||
Matthias St. Pierre
|
||||
Nils Larsch
|
||||
Paul Dale
|
||||
Paul C. Sutton
|
||||
Ralf S. Engelschall
|
||||
Rich Salz
|
||||
Richard Levitte
|
||||
Stephen Henson
|
||||
Steve Marquess
|
||||
Tim Hudson
|
||||
Ulf Möller
|
||||
Viktor Dukhovni
|
File diff suppressed because it is too large
Load Diff
@ -1,968 +0,0 @@
|
||||
This file contains the changes for the SSLeay library up to version
|
||||
0.9.0b. For later changes, see the file "CHANGES".
|
||||
|
||||
SSLeay CHANGES
|
||||
______________
|
||||
|
||||
Changes between 0.8.x and 0.9.0b
|
||||
|
||||
10-Apr-1998
|
||||
|
||||
I said the next version would go out at easter, and so it shall.
|
||||
I expect a 0.9.1 will follow with portability fixes in the next few weeks.
|
||||
|
||||
This is a quick, meet the deadline. Look to ssl-users for comments on what
|
||||
is new etc.
|
||||
|
||||
eric (about to go bushwalking for the 4 day easter break :-)
|
||||
|
||||
16-Mar-98
|
||||
- Patch for Cray T90 from Wayne Schroeder <schroede@SDSC.EDU>
|
||||
- Lots and lots of changes
|
||||
|
||||
29-Jan-98
|
||||
- ASN1_BIT_STRING_set_bit()/ASN1_BIT_STRING_get_bit() from
|
||||
Goetz Babin-Ebell <babinebell@trustcenter.de>.
|
||||
- SSL_version() now returns SSL2_VERSION, SSL3_VERSION or
|
||||
TLS1_VERSION.
|
||||
|
||||
7-Jan-98
|
||||
- Finally reworked the cipher string to ciphers again, so it
|
||||
works correctly
|
||||
- All the app_data stuff is now ex_data with funcion calls to access.
|
||||
The index is supplied by a function and 'methods' can be setup
|
||||
for the types that are called on XXX_new/XXX_free. This lets
|
||||
applications get notified on creation and destruction. Some of
|
||||
the RSA methods could be implemented this way and I may do so.
|
||||
- Oh yes, SSL under perl5 is working at the basic level.
|
||||
|
||||
15-Dec-97
|
||||
- Warning - the gethostbyname cache is not fully thread safe,
|
||||
but it should work well enough.
|
||||
- Major internal reworking of the app_data stuff. More functions
|
||||
but if you were accessing ->app_data directly, things will
|
||||
stop working.
|
||||
- The perlv5 stuff is working. Currently on message digests,
|
||||
ciphers and the bignum library.
|
||||
|
||||
9-Dec-97
|
||||
- Modified re-negotiation so that server initated re-neg
|
||||
will cause a SSL_read() to return -1 should retry.
|
||||
The danger otherwise was that the server and the
|
||||
client could end up both trying to read when using non-blocking
|
||||
sockets.
|
||||
|
||||
4-Dec-97
|
||||
- Lots of small changes
|
||||
- Fix for binaray mode in Windows for the FILE BIO, thanks to
|
||||
Bob Denny <rdenny@dc3.com>
|
||||
|
||||
17-Nov-97
|
||||
- Quite a few internal cleanups, (removal of errno, and using macros
|
||||
defined in e_os.h).
|
||||
- A bug in ca.c, pointed out by yasuyuki-ito@d-cruise.co.jp, where
|
||||
the automactic naming out output files was being stuffed up.
|
||||
|
||||
29-Oct-97
|
||||
- The Cast5 cipher has been added. MD5 and SHA-1 are now in assember
|
||||
for x86.
|
||||
|
||||
21-Oct-97
|
||||
- Fixed a bug in the BIO_gethostbyname() cache.
|
||||
|
||||
15-Oct-97
|
||||
- cbc mode for blowfish/des/3des is now in assember. Blowfish asm
|
||||
has also been improved. At this point in time, on the pentium,
|
||||
md5 is %80 faster, the unoptimesed sha-1 is %79 faster,
|
||||
des-cbc is %28 faster, des-ede3-cbc is %9 faster and blowfish-cbc
|
||||
is %62 faster.
|
||||
|
||||
12-Oct-97
|
||||
- MEM_BUF_grow() has been fixed so that it always sets the buf->length
|
||||
to the value we are 'growing' to. Think of MEM_BUF_grow() as the
|
||||
way to set the length value correctly.
|
||||
|
||||
10-Oct-97
|
||||
- I now hash for certificate lookup on the raw DER encoded RDN (md5).
|
||||
This breaks things again :-(. This is efficent since I cache
|
||||
the DER encoding of the RDN.
|
||||
- The text DN now puts in the numeric OID instead of UNKNOWN.
|
||||
- req can now process arbitary OIDs in the config file.
|
||||
- I've been implementing md5 in x86 asm, much faster :-).
|
||||
- Started sha1 in x86 asm, needs more work.
|
||||
- Quite a few speedups in the BN stuff. RSA public operation
|
||||
has been made faster by caching the BN_MONT_CTX structure.
|
||||
The calulating of the Ai where A*Ai === 1 mod m was rather
|
||||
expensive. Basically a 40-50% speedup on public operations.
|
||||
The RSA speedup is now 15% on pentiums and %20 on pentium
|
||||
pro.
|
||||
|
||||
30-Sep-97
|
||||
- After doing some profiling, I added x86 adm for bn_add_words(),
|
||||
which just adds 2 arrays of longs together. A %10 speedup
|
||||
for 512 and 1024 bit RSA on the pentium pro.
|
||||
|
||||
29-Sep-97
|
||||
- Converted the x86 bignum assembler to us the perl scripts
|
||||
for generation.
|
||||
|
||||
23-Sep-97
|
||||
- If SSL_set_session() is passed a NULL session, it now clears the
|
||||
current session-id.
|
||||
|
||||
22-Sep-97
|
||||
- Added a '-ss_cert file' to apps/ca.c. This will sign selfsigned
|
||||
certificates.
|
||||
- Bug in crypto/evp/encode.c where by decoding of 65 base64
|
||||
encoded lines, one line at a time (via a memory BIO) would report
|
||||
EOF after the first line was decoded.
|
||||
- Fix in X509_find_by_issuer_and_serial() from
|
||||
Dr Stephen Henson <shenson@bigfoot.com>
|
||||
|
||||
19-Sep-97
|
||||
- NO_FP_API and NO_STDIO added.
|
||||
- Put in sh config command. It auto runs Configure with the correct
|
||||
parameters.
|
||||
|
||||
18-Sep-97
|
||||
- Fix x509.c so if a DSA cert has different parameters to its parent,
|
||||
they are left in place. Not tested yet.
|
||||
|
||||
16-Sep-97
|
||||
- ssl_create_cipher_list() had some bugs, fixes from
|
||||
Patrick Eisenacher <eisenach@stud.uni-frankfurt.de>
|
||||
- Fixed a bug in the Base64 BIO, where it would return 1 instead
|
||||
of -1 when end of input was encountered but should retry.
|
||||
Basically a Base64/Memory BIO interaction problem.
|
||||
- Added a HMAC set of functions in preporarion for TLS work.
|
||||
|
||||
15-Sep-97
|
||||
- Top level makefile tweak - Cameron Simpson <cs@zip.com.au>
|
||||
- Prime generation spead up %25 (512 bit prime, pentium pro linux)
|
||||
by using montgomery multiplication in the prime number test.
|
||||
|
||||
11-Sep-97
|
||||
- Ugly bug in ssl3_write_bytes(). Basically if application land
|
||||
does a SSL_write(ssl,buf,len) where len > 16k, the SSLv3 write code
|
||||
did not check the size and tried to copy the entire buffer.
|
||||
This would tend to cause memory overwrites since SSLv3 has
|
||||
a maximum packet size of 16k. If your program uses
|
||||
buffers <= 16k, you would probably never see this problem.
|
||||
- Fixed a few errors that were cause by malloc() not returning
|
||||
0 initialised memory..
|
||||
- SSL_OP_NETSCAPE_CA_DN_BUG was being switched on when using
|
||||
SSL_CTX_set_options(ssl_ctx,SSL_OP_ALL); which was a bad thing
|
||||
since this flags stops SSLeay being able to handle client
|
||||
cert requests correctly.
|
||||
|
||||
08-Sep-97
|
||||
- SSL_SESS_CACHE_NO_INTERNAL_LOOKUP option added. When switched
|
||||
on, the SSL server routines will not use a SSL_SESSION that is
|
||||
held in it's cache. This in intended to be used with the session-id
|
||||
callbacks so that while the session-ids are still stored in the
|
||||
cache, the decision to use them and how to look them up can be
|
||||
done by the callbacks. The are the 'new', 'get' and 'remove'
|
||||
callbacks. This can be used to determine the session-id
|
||||
to use depending on information like which port/host the connection
|
||||
is coming from. Since the are also SSL_SESSION_set_app_data() and
|
||||
SSL_SESSION_get_app_data() functions, the application can hold
|
||||
information against the session-id as well.
|
||||
|
||||
03-Sep-97
|
||||
- Added lookup of CRLs to the by_dir method,
|
||||
X509_load_crl_file() also added. Basically it means you can
|
||||
lookup CRLs via the same system used to lookup certificates.
|
||||
- Changed things so that the X509_NAME structure can contain
|
||||
ASN.1 BIT_STRINGS which is required for the unique
|
||||
identifier OID.
|
||||
- Fixed some problems with the auto flushing of the session-id
|
||||
cache. It was not occuring on the server side.
|
||||
|
||||
02-Sep-97
|
||||
- Added SSL_CTX_sess_cache_size(SSL_CTX *ctx,unsigned long size)
|
||||
which is the maximum number of entries allowed in the
|
||||
session-id cache. This is enforced with a simple FIFO list.
|
||||
The default size is 20*1024 entries which is rather large :-).
|
||||
The Timeout code is still always operating.
|
||||
|
||||
01-Sep-97
|
||||
- Added an argument to all the 'generate private key/prime`
|
||||
callbacks. It is the last parameter so this should not
|
||||
break existing code but it is needed for C++.
|
||||
- Added the BIO_FLAGS_BASE64_NO_NL flag for the BIO_f_base64()
|
||||
BIO. This lets the BIO read and write base64 encoded data
|
||||
without inserting or looking for '\n' characters. The '-A'
|
||||
flag turns this on when using apps/enc.c.
|
||||
- RSA_NO_PADDING added to help BSAFE functionality. This is a
|
||||
very dangerous thing to use, since RSA private key
|
||||
operations without random padding bytes (as PKCS#1 adds) can
|
||||
be attacked such that the private key can be revealed.
|
||||
- ASN.1 bug and rc2-40-cbc and rc4-40 added by
|
||||
Dr Stephen Henson <shenson@bigfoot.com>
|
||||
|
||||
31-Aug-97 (stuff added while I was away)
|
||||
- Linux pthreads by Tim Hudson (tjh@cryptsoft.com).
|
||||
- RSA_flags() added allowing bypass of pub/priv match check
|
||||
in ssl/ssl_rsa.c - Tim Hudson.
|
||||
- A few minor bugs.
|
||||
|
||||
SSLeay 0.8.1 released.
|
||||
|
||||
19-Jul-97
|
||||
- Server side initated dynamic renegotiation is broken. I will fix
|
||||
it when I get back from holidays.
|
||||
|
||||
15-Jul-97
|
||||
- Quite a few small changes.
|
||||
- INVALID_SOCKET usage cleanups from Alex Kiernan <alex@hisoft.co.uk>
|
||||
|
||||
09-Jul-97
|
||||
- Added 2 new values to the SSL info callback.
|
||||
SSL_CB_START which is passed when the SSL protocol is started
|
||||
and SSL_CB_DONE when it has finished sucsessfully.
|
||||
|
||||
08-Jul-97
|
||||
- Fixed a few bugs problems in apps/req.c and crypto/asn1/x_pkey.c
|
||||
that related to DSA public/private keys.
|
||||
- Added all the relevent PEM and normal IO functions to support
|
||||
reading and writing RSAPublic keys.
|
||||
- Changed makefiles to use ${AR} instead of 'ar r'
|
||||
|
||||
07-Jul-97
|
||||
- Error in ERR_remove_state() that would leave a dangling reference
|
||||
to a free()ed location - thanks to Alex Kiernan <alex@hisoft.co.uk>
|
||||
- s_client now prints the X509_NAMEs passed from the server
|
||||
when requesting a client cert.
|
||||
- Added a ssl->type, which is one of SSL_ST_CONNECT or
|
||||
SSL_ST_ACCEPT. I had to add it so I could tell if I was
|
||||
a connect or an accept after the handshake had finished.
|
||||
- SSL_get_client_CA_list(SSL *s) now returns the CA names
|
||||
passed by the server if called by a client side SSL.
|
||||
|
||||
05-Jul-97
|
||||
- Bug in X509_NAME_get_text_by_OBJ(), looking starting at index
|
||||
0, not -1 :-( Fix from Tim Hudson (tjh@cryptsoft.com).
|
||||
|
||||
04-Jul-97
|
||||
- Fixed some things in X509_NAME_add_entry(), thanks to
|
||||
Matthew Donald <matthew@world.net>.
|
||||
- I had a look at the cipher section and though that it was a
|
||||
bit confused, so I've changed it.
|
||||
- I was not setting up the RC4-64-MD5 cipher correctly. It is
|
||||
a MS special that appears in exported MS Money.
|
||||
- Error in all my DH ciphers. Section 7.6.7.3 of the SSLv3
|
||||
spec. I was missing the two byte length header for the
|
||||
ClientDiffieHellmanPublic value. This is a packet sent from
|
||||
the client to the server. The SSL_OP_SSLEAY_080_CLIENT_DH_BUG
|
||||
option will enable SSLeay server side SSLv3 accept either
|
||||
the correct or my 080 packet format.
|
||||
- Fixed a few typos in crypto/pem.org.
|
||||
|
||||
02-Jul-97
|
||||
- Alias mapping for EVP_get_(digest|cipher)byname is now
|
||||
performed before a lookup for actual cipher. This means
|
||||
that an alias can be used to 're-direct' a cipher or a
|
||||
digest.
|
||||
- ASN1_read_bio() had a bug that only showed up when using a
|
||||
memory BIO. When EOF is reached in the memory BIO, it is
|
||||
reported as a -1 with BIO_should_retry() set to true.
|
||||
|
||||
01-Jul-97
|
||||
- Fixed an error in X509_verify_cert() caused by my
|
||||
miss-understanding how 'do { contine } while(0);' works.
|
||||
Thanks to Emil Sit <sit@mit.edu> for educating me :-)
|
||||
|
||||
30-Jun-97
|
||||
- Base64 decoding error. If the last data line did not end with
|
||||
a '=', sometimes extra data would be returned.
|
||||
- Another 'cut and paste' bug in x509.c related to setting up the
|
||||
STDout BIO.
|
||||
|
||||
27-Jun-97
|
||||
- apps/ciphers.c was not printing due to an editing error.
|
||||
- Alex Kiernan <alex@hisoft.co.uk> send in a nice fix for
|
||||
a library build error in util/mk1mf.pl
|
||||
|
||||
26-Jun-97
|
||||
- Still did not have the auto 'experimental' code removal
|
||||
script correct.
|
||||
- A few header tweaks for Watcom 11.0 under Win32 from
|
||||
Rolf Lindemann <Lindemann@maz-hh.de>
|
||||
- 0 length OCTET_STRING bug in asn1_parse
|
||||
- A minor fix with an non-existent function in the MS .def files.
|
||||
- A few changes to the PKCS7 stuff.
|
||||
|
||||
25-Jun-97
|
||||
SSLeay 0.8.0 finally it gets released.
|
||||
|
||||
24-Jun-97
|
||||
Added a SSL_OP_EPHEMERAL_RSA option which causes all SSLv3 RSA keys to
|
||||
use a temporary RSA key. This is experimental and needs some more work.
|
||||
Fixed a few Win16 build problems.
|
||||
|
||||
23-Jun-97
|
||||
SSLv3 bug. I was not doing the 'lookup' of the CERT structure
|
||||
correctly. I was taking the SSL->ctx->default_cert when I should
|
||||
have been using SSL->cert. The bug was in ssl/s3_srvr.c
|
||||
|
||||
20-Jun-97
|
||||
X509_ATTRIBUTES were being encoded wrongly by apps/reg.c and the
|
||||
rest of the library. Even though I had the code required to do
|
||||
it correctly, apps/req.c was doing the wrong thing. I have fixed
|
||||
and tested everything.
|
||||
|
||||
Missing a few #ifdef FIONBIO sections in crypto/bio/bss_acpt.c.
|
||||
|
||||
19-Jun-97
|
||||
Fixed a bug in the SSLv2 server side first packet handling. When
|
||||
using the non-blocking test BIO, the ssl->s2->first_packet flag
|
||||
was being reset when a would-block failure occurred when reading
|
||||
the first 5 bytes of the first packet. This caused the checking
|
||||
logic to run at the wrong time and cause an error.
|
||||
|
||||
Fixed a problem with specifying cipher. If RC4-MD5 were used,
|
||||
only the SSLv3 version would be picked up. Now this will pick
|
||||
up both SSLv2 and SSLv3 versions. This required changing the
|
||||
SSL_CIPHER->mask values so that they only mask the ciphers,
|
||||
digests, authentication, export type and key-exchange algorithms.
|
||||
|
||||
I found that when a SSLv23 session is established, a reused
|
||||
session, of type SSLv3 was attempting to write the SSLv2
|
||||
ciphers, which were invalid. The SSL_METHOD->put_cipher_by_char
|
||||
method has been modified so it will only write out cipher which
|
||||
that method knows about.
|
||||
|
||||
|
||||
Changes between 0.8.0 and 0.8.1
|
||||
|
||||
*) Mostly bug fixes.
|
||||
There is an Ephemeral DH cipher problem which is fixed.
|
||||
|
||||
SSLeay 0.8.0
|
||||
|
||||
This version of SSLeay has quite a lot of things different from the
|
||||
previous version.
|
||||
|
||||
Basically check all callback parameters, I will be producing documentation
|
||||
about how to use things in th future. Currently I'm just getting 080 out
|
||||
the door. Please not that there are several ways to do everything, and
|
||||
most of the applications in the apps directory are hybrids, some using old
|
||||
methods and some using new methods.
|
||||
|
||||
Have a look in demos/bio for some very simple programs and
|
||||
apps/s_client.c and apps/s_server.c for some more advanced versions.
|
||||
Notes are definitly needed but they are a week or so away.
|
||||
|
||||
Anyway, some quick nots from Tim Hudson (tjh@cryptsoft.com)
|
||||
---
|
||||
Quick porting notes for moving from SSLeay-0.6.x to SSLeay-0.8.x to
|
||||
get those people that want to move to using the new code base off to
|
||||
a quick start.
|
||||
|
||||
Note that Eric has tidied up a lot of the areas of the API that were
|
||||
less than desirable and renamed quite a few things (as he had to break
|
||||
the API in lots of places anyrate). There are a whole pile of additional
|
||||
functions for making dealing with (and creating) certificates a lot
|
||||
cleaner.
|
||||
|
||||
01-Jul-97
|
||||
Tim Hudson
|
||||
tjh@cryptsoft.com
|
||||
|
||||
---8<---
|
||||
|
||||
To maintain code that uses both SSLeay-0.6.x and SSLeay-0.8.x you could
|
||||
use something like the following (assuming you #include "crypto.h" which
|
||||
is something that you really should be doing).
|
||||
|
||||
#if SSLEAY_VERSION_NUMBER >= 0x0800
|
||||
#define SSLEAY8
|
||||
#endif
|
||||
|
||||
buffer.h -> splits into buffer.h and bio.h so you need to include bio.h
|
||||
too if you are working with BIO internal stuff (as distinct
|
||||
from simply using the interface in an opaque manner)
|
||||
|
||||
#include "bio.h" - required along with "buffer.h" if you write
|
||||
your own BIO routines as the buffer and bio
|
||||
stuff that was intermixed has been separated
|
||||
out
|
||||
|
||||
envelope.h -> evp.h (which should have been done ages ago)
|
||||
|
||||
Initialisation ... don't forget these or you end up with code that
|
||||
is missing the bits required to do useful things (like ciphers):
|
||||
|
||||
SSLeay_add_ssl_algorithms()
|
||||
(probably also want SSL_load_error_strings() too but you should have
|
||||
already had that call in place)
|
||||
|
||||
SSL_CTX_new() - requires an extra method parameter
|
||||
SSL_CTX_new(SSLv23_method())
|
||||
SSL_CTX_new(SSLv2_method())
|
||||
SSL_CTX_new(SSLv3_method())
|
||||
|
||||
OR to only have the server or the client code
|
||||
SSL_CTX_new(SSLv23_server_method())
|
||||
SSL_CTX_new(SSLv2_server_method())
|
||||
SSL_CTX_new(SSLv3_server_method())
|
||||
or
|
||||
SSL_CTX_new(SSLv23_client_method())
|
||||
SSL_CTX_new(SSLv2_client_method())
|
||||
SSL_CTX_new(SSLv3_client_method())
|
||||
|
||||
SSL_set_default_verify_paths() ... renamed to the more appropriate
|
||||
SSL_CTX_set_default_verify_paths()
|
||||
|
||||
If you want to use client certificates then you have to add in a bit
|
||||
of extra stuff in that a SSLv3 server sends a list of those CAs that
|
||||
it will accept certificates from ... so you have to provide a list to
|
||||
SSLeay otherwise certain browsers will not send client certs.
|
||||
|
||||
SSL_CTX_set_client_CA_list(ctx,SSL_load_client_CA_file(s_cert_file));
|
||||
|
||||
|
||||
X509_NAME_oneline(X) -> X509_NAME_oneline(X,NULL,0)
|
||||
or provide a buffer and size to copy the
|
||||
result into
|
||||
|
||||
X509_add_cert -> X509_STORE_add_cert (and you might want to read the
|
||||
notes on X509_NAME structure changes too)
|
||||
|
||||
|
||||
VERIFICATION CODE
|
||||
=================
|
||||
|
||||
The codes have all be renamed from VERIFY_ERR_* to X509_V_ERR_* to
|
||||
more accurately reflect things.
|
||||
|
||||
The verification callback args are now packaged differently so that
|
||||
extra fields for verification can be added easily in future without
|
||||
having to break things by adding extra parameters each release :-)
|
||||
|
||||
X509_cert_verify_error_string -> X509_verify_cert_error_string
|
||||
|
||||
|
||||
BIO INTERNALS
|
||||
=============
|
||||
|
||||
Eric has fixed things so that extra flags can be introduced in
|
||||
the BIO layer in future without having to play with all the BIO
|
||||
modules by adding in some macros.
|
||||
|
||||
The ugly stuff using
|
||||
b->flags ~= (BIO_FLAGS_RW|BIO_FLAGS_SHOULD_RETRY)
|
||||
becomes
|
||||
BIO_clear_retry_flags(b)
|
||||
|
||||
b->flags |= (BIO_FLAGS_READ|BIO_FLAGS_SHOULD_RETRY)
|
||||
becomes
|
||||
BIO_set_retry_read(b)
|
||||
|
||||
Also ... BIO_get_retry_flags(b), BIO_set_flags(b)
|
||||
|
||||
|
||||
|
||||
OTHER THINGS
|
||||
============
|
||||
|
||||
X509_NAME has been altered so that it isn't just a STACK ... the STACK
|
||||
is now in the "entries" field ... and there are a pile of nice functions
|
||||
for getting at the details in a much cleaner manner.
|
||||
|
||||
SSL_CTX has been altered ... "cert" is no longer a direct member of this
|
||||
structure ... things are now down under "cert_store" (see x509_vfy.h) and
|
||||
things are no longer in a CERTIFICATE_CTX but instead in a X509_STORE.
|
||||
If your code "knows" about this level of detail then it will need some
|
||||
surgery.
|
||||
|
||||
If you depending on the incorrect spelling of a number of the error codes
|
||||
then you will have to change your code as these have been fixed.
|
||||
|
||||
ENV_CIPHER "type" got renamed to "nid" and as that is what it actually
|
||||
has been all along so this makes things clearer.
|
||||
ify_cert_error_string(ctx->error));
|
||||
|
||||
SSL_R_NO_CIPHER_WE_TRUST -> SSL_R_NO_CIPHER_LIST
|
||||
and SSL_R_REUSE_CIPHER_LIST_NOT_ZERO
|
||||
|
||||
|
||||
|
||||
Changes between 0.7.x and 0.8.0
|
||||
|
||||
*) There have been lots of changes, mostly the addition of SSLv3.
|
||||
There have been many additions from people and amongst
|
||||
others, C2Net has assisted greatly.
|
||||
|
||||
Changes between 0.7.x and 0.7.x
|
||||
|
||||
*) Internal development version only
|
||||
|
||||
SSLeay 0.6.6 13-Jan-1997
|
||||
|
||||
The main additions are
|
||||
|
||||
- assember for x86 DES improvments.
|
||||
From 191,000 per second on a pentium 100, I now get 281,000. The inner
|
||||
loop and the IP/FP modifications are from
|
||||
Svend Olaf Mikkelsen <svolaf@inet.uni-c.dk>. Many thanks for his
|
||||
contribution.
|
||||
- The 'DES macros' introduced in 0.6.5 now have 3 types.
|
||||
DES_PTR1, DES_PTR2 and 'normal'. As per before, des_opts reports which
|
||||
is best and there is a summery of mine in crypto/des/options.txt
|
||||
- A few bug fixes.
|
||||
- Added blowfish. It is not used by SSL but all the other stuff that
|
||||
deals with ciphers can use it in either ecb, cbc, cfb64 or ofb64 modes.
|
||||
There are 3 options for optimising Blowfish. BF_PTR, BF_PTR2 and 'normal'.
|
||||
BF_PTR2 is pentium/x86 specific. The correct option is setup in
|
||||
the 'Configure' script.
|
||||
- There is now a 'get client certificate' callback which can be
|
||||
'non-blocking'. If more details are required, let me know. It will
|
||||
documented more in SSLv3 when I finish it.
|
||||
- Bug fixes from 0.6.5 including the infamous 'ca' bug. The 'make test'
|
||||
now tests the ca program.
|
||||
- Lots of little things modified and tweaked.
|
||||
|
||||
SSLeay 0.6.5
|
||||
|
||||
After quite some time (3 months), the new release. I have been very busy
|
||||
for the last few months and so this is mostly bug fixes and improvments.
|
||||
|
||||
The main additions are
|
||||
|
||||
- assember for x86 DES. For all those gcc based systems, this is a big
|
||||
improvement. From 117,000 DES operation a second on a pentium 100,
|
||||
I now get 191,000. I have also reworked the C version so it
|
||||
now gives 148,000 DESs per second.
|
||||
- As mentioned above, the inner DES macros now have some more variant that
|
||||
sometimes help, sometimes hinder performance. There are now 3 options
|
||||
DES_PTR (ptr vs array lookup), DES_UNROLL (full vs partial loop unrolling)
|
||||
and DES_RISC (a more register intensive version of the inner macro).
|
||||
The crypto/des/des_opts.c program, when compiled and run, will give
|
||||
an indication of the correct options to use.
|
||||
- The BIO stuff has been improved. Read doc/bio.doc. There are now
|
||||
modules for encryption and base64 encoding and a BIO_printf() function.
|
||||
- The CA program will accept simple one line X509v3 extensions in the
|
||||
ssleay.cnf file. Have a look at the example. Currently this just
|
||||
puts the text into the certificate as an OCTET_STRING so currently
|
||||
the more advanced X509v3 data types are not handled but this is enough
|
||||
for the netscape extensions.
|
||||
- There is the start of a nicer higher level interface to the X509
|
||||
strucutre.
|
||||
- Quite a lot of bug fixes.
|
||||
- CRYPTO_malloc_init() (or CRYPTO_set_mem_functions()) can be used
|
||||
to define the malloc(), free() and realloc() routines to use
|
||||
(look in crypto/crypto.h). This is mostly needed for Windows NT/95 when
|
||||
using DLLs and mixing CRT libraries.
|
||||
|
||||
In general, read the 'VERSION' file for changes and be aware that some of
|
||||
the new stuff may not have been tested quite enough yet, so don't just plonk
|
||||
in SSLeay 0.6.5 when 0.6.4 used to work and expect nothing to break.
|
||||
|
||||
SSLeay 0.6.4 30/08/96 eay
|
||||
|
||||
I've just finished some test builds on Windows NT, Windows 3.1, Solaris 2.3,
|
||||
Solaris 2.5, Linux, IRIX, HPUX 10 and everthing seems to work :-).
|
||||
|
||||
The main changes in this release
|
||||
|
||||
- Thread safe. have a read of doc/threads.doc and play in the mt directory.
|
||||
For anyone using 0.6.3 with threads, I found 2 major errors so consider
|
||||
moving to 0.6.4. I have a test program that builds under NT and
|
||||
solaris.
|
||||
- The get session-id callback has changed. Have a read of doc/callback.doc.
|
||||
- The X509_cert_verify callback (the SSL_verify callback) now
|
||||
has another argument. Have a read of doc/callback.doc
|
||||
- 'ca -preserve', sign without re-ordering the DN. Not tested much.
|
||||
- VMS support.
|
||||
- Compile time memory leak detection can now be built into SSLeay.
|
||||
Read doc/memory.doc
|
||||
- CONF routines now understand '\', '\n', '\r' etc. What this means is that
|
||||
the SPKAC object mentioned in doc/ns-ca.doc can be on multiple lines.
|
||||
- 'ssleay ciphers' added, lists the default cipher list for SSLeay.
|
||||
- RC2 key setup is now compatable with Netscape.
|
||||
- Modifed server side of SSL implementation, big performance difference when
|
||||
using session-id reuse.
|
||||
|
||||
0.6.3
|
||||
|
||||
Bug fixes and the addition of some nice stuff to the 'ca' program.
|
||||
Have a read of doc/ns-ca.doc for how hit has been modified so
|
||||
it can be driven from a CGI script. The CGI script is not provided,
|
||||
but that is just being left as an excersize for the reader :-).
|
||||
|
||||
0.6.2
|
||||
|
||||
This is most bug fixes and functionality improvements.
|
||||
|
||||
Additions are
|
||||
- More thread debugging patches, the thread stuff is still being
|
||||
tested, but for those keep to play with stuff, have a look in
|
||||
crypto/cryptlib.c. The application needs to define 1 (or optionaly
|
||||
a second) callback that is used to implement locking. Compiling
|
||||
with LOCK_DEBUG spits out lots of locking crud :-).
|
||||
This is what I'm currently working on.
|
||||
- SSL_CTX_set_default_passwd_cb() can be used to define the callback
|
||||
function used in the SSL*_file() functions used to load keys. I was
|
||||
always of the opinion that people should call
|
||||
PEM_read_RSAPrivateKey() and pass the callback they want to use, but
|
||||
it appears they just want to use the SSL_*_file() function() :-(.
|
||||
- 'enc' now has a -kfile so a key can be read from a file. This is
|
||||
mostly used so that the passwd does not appear when using 'ps',
|
||||
which appears imposible to stop under solaris.
|
||||
- X509v3 certificates now work correctly. I even have more examples
|
||||
in my tests :-). There is now a X509_EXTENSION type that is used in
|
||||
X509v3 certificates and CRLv2.
|
||||
- Fixed that signature type error :-(
|
||||
- Fixed quite a few potential memory leaks and problems when reusing
|
||||
X509, CRL and REQ structures.
|
||||
- EVP_set_pw_prompt() now sets the library wide default password
|
||||
prompt.
|
||||
- The 'pkcs7' command will now, given the -print_certs flag, output in
|
||||
pem format, all certificates and CRL contained within. This is more
|
||||
of a pre-emtive thing for the new verisign distribution method. I
|
||||
should also note, that this also gives and example in code, of how
|
||||
to do this :-), or for that matter, what is involved in going the
|
||||
other way (list of certs and crl -> pkcs7).
|
||||
- Added RSA's DESX to the DES library. It is also available via the
|
||||
EVP_desx_cbc() method and via 'enc desx'.
|
||||
|
||||
SSLeay 0.6.1
|
||||
|
||||
The main functional changes since 0.6.0 are as follows
|
||||
- Bad news, the Microsoft 060 DLL's are not compatable, but the good news is
|
||||
that from now on, I'll keep the .def numbers the same so they will be.
|
||||
- RSA private key operations are about 2 times faster that 0.6.0
|
||||
- The SSL_CTX now has more fields so default values can be put against
|
||||
it. When an SSL structure is created, these default values are used
|
||||
but can be overwritten. There are defaults for cipher, certificate,
|
||||
private key, verify mode and callback. This means SSL session
|
||||
creation can now be
|
||||
ssl=SSL_new()
|
||||
SSL_set_fd(ssl,sock);
|
||||
SSL_accept(ssl)
|
||||
....
|
||||
All the other uglyness with having to keep a global copy of the
|
||||
private key and certificate/verify mode in the server is now gone.
|
||||
- ssl/ssltest.c - one process talking SSL to its self for testing.
|
||||
- Storage of Session-id's can be controled via a session_cache_mode
|
||||
flag. There is also now an automatic default flushing of
|
||||
old session-id's.
|
||||
- The X509_cert_verify() function now has another parameter, this
|
||||
should not effect most people but it now means that the reason for
|
||||
the failure to verify is now available via SSL_get_verify_result(ssl).
|
||||
You don't have to use a global variable.
|
||||
- SSL_get_app_data() and SSL_set_app_data() can be used to keep some
|
||||
application data against the SSL structure. It is upto the application
|
||||
to free the data. I don't use it, but it is available.
|
||||
- SSL_CTX_set_cert_verify_callback() can be used to specify a
|
||||
verify callback function that completly replaces my certificate
|
||||
verification code. Xcert should be able to use this :-).
|
||||
The callback is of the form int app_verify_callback(arg,ssl,cert).
|
||||
This needs to be documented more.
|
||||
- I have started playing with shared library builds, have a look in
|
||||
the shlib directory. It is very simple. If you need a numbered
|
||||
list of functions, have a look at misc/crypto.num and misc/ssl.num.
|
||||
- There is some stuff to do locking to make the library thread safe.
|
||||
I have only started this stuff and have not finished. If anyone is
|
||||
keen to do so, please send me the patches when finished.
|
||||
|
||||
So I have finally made most of the additions to the SSL interface that
|
||||
I thought were needed.
|
||||
|
||||
There will probably be a pause before I make any non-bug/documentation
|
||||
related changes to SSLeay since I'm feeling like a bit of a break.
|
||||
|
||||
eric - 12 Jul 1996
|
||||
I saw recently a comment by some-one that we now seem to be entering
|
||||
the age of perpetual Beta software.
|
||||
Pioneered by packages like linux but refined to an art form by
|
||||
netscape.
|
||||
|
||||
I too wish to join this trend with the anouncement of SSLeay 0.6.0 :-).
|
||||
|
||||
There are quite a large number of sections that are 'works in
|
||||
progress' in this package. I will also list the major changes and
|
||||
what files you should read.
|
||||
|
||||
BIO - this is the new IO structure being used everywhere in SSLeay. I
|
||||
started out developing this because of microsoft, I wanted a mechanism
|
||||
to callback to the application for all IO, so Windows 3.1 DLL
|
||||
perversion could be hidden from me and the 15 different ways to write
|
||||
to a file under NT would also not be dictated by me at library build
|
||||
time. What the 'package' is is an API for a data structure containing
|
||||
functions. IO interfaces can be written to conform to the
|
||||
specification. This in not intended to hide the underlying data type
|
||||
from the application, but to hide it from SSLeay :-).
|
||||
I have only really finished testing the FILE * and socket/fd modules.
|
||||
There are also 'filter' BIO's. Currently I have only implemented
|
||||
message digests, and it is in use in the dgst application. This
|
||||
functionality will allow base64/encrypto/buffering modules to be
|
||||
'push' into a BIO without it affecting the semantics. I'm also
|
||||
working on an SSL BIO which will hide the SSL_accept()/SLL_connet()
|
||||
from an event loop which uses the interface.
|
||||
It is also possible to 'attach' callbacks to a BIO so they get called
|
||||
before and after each operation, alowing extensive debug output
|
||||
to be generated (try running dgst with -d).
|
||||
|
||||
Unfortunaly in the conversion from 0.5.x to 0.6.0, quite a few
|
||||
functions that used to take FILE *, now take BIO *.
|
||||
The wrappers are easy to write
|
||||
|
||||
function_fp(fp,x)
|
||||
FILE *fp;
|
||||
{
|
||||
BIO *b;
|
||||
int ret;
|
||||
|
||||
if ((b=BIO_new(BIO_s_file())) == NULL) error.....
|
||||
BIO_set_fp(b,fp,BIO_NOCLOSE);
|
||||
ret=function_bio(b,x);
|
||||
BIO_free(b);
|
||||
return(ret);
|
||||
}
|
||||
Remember, there are no functions that take FILE * in SSLeay when
|
||||
compiled for Windows 3.1 DLL's.
|
||||
|
||||
--
|
||||
I have added a general EVP_PKEY type that can hold a public/private
|
||||
key. This is now what is used by the EVP_ functions and is passed
|
||||
around internally. I still have not done the PKCS#8 stuff, but
|
||||
X509_PKEY is defined and waiting :-)
|
||||
|
||||
--
|
||||
For a full function name listings, have a look at ms/crypt32.def and
|
||||
ms/ssl32.def. These are auto-generated but are complete.
|
||||
Things like ASN1_INTEGER_get() have been added and are in here if you
|
||||
look. I have renamed a few things, again, have a look through the
|
||||
function list and you will probably find what you are after. I intend
|
||||
to at least put a one line descrition for each one.....
|
||||
|
||||
--
|
||||
Microsoft - thats what this release is about, read the MICROSOFT file.
|
||||
|
||||
--
|
||||
Multi-threading support. I have started hunting through the code and
|
||||
flaging where things need to be done. In a state of work but high on
|
||||
the list.
|
||||
|
||||
--
|
||||
For random numbers, edit e_os.h and set DEVRANDOM (it's near the top)
|
||||
be be you random data device, otherwise 'RFILE' in e_os.h
|
||||
will be used, in your home directory. It will be updated
|
||||
periodically. The environment variable RANDFILE will override this
|
||||
choice and read/write to that file instead. DEVRANDOM is used in
|
||||
conjunction to the RFILE/RANDFILE. If you wish to 'seed' the random
|
||||
number generator, pick on one of these files.
|
||||
|
||||
--
|
||||
|
||||
The list of things to read and do
|
||||
|
||||
dgst -d
|
||||
s_client -state (this uses a callback placed in the SSL state loop and
|
||||
will be used else-where to help debug/monitor what
|
||||
is happening.)
|
||||
|
||||
doc/why.doc
|
||||
doc/bio.doc <- hmmm, needs lots of work.
|
||||
doc/bss_file.doc <- one that is working :-)
|
||||
doc/session.doc <- it has changed
|
||||
doc/speed.doc
|
||||
also play with ssleay version -a. I have now added a SSLeay()
|
||||
function that returns a version number, eg 0600 for this release
|
||||
which is primarily to be used to check DLL version against the
|
||||
application.
|
||||
util/* Quite a few will not interest people, but some may, like
|
||||
mk1mf.pl, mkdef.pl,
|
||||
util/do_ms.sh
|
||||
|
||||
try
|
||||
cc -Iinclude -Icrypto -c crypto/crypto.c
|
||||
cc -Iinclude -Issl -c ssl/ssl.c
|
||||
You have just built the SSLeay libraries as 2 object files :-)
|
||||
|
||||
Have a general rummage around in the bin stall directory and look at
|
||||
what is in there, like CA.sh and c_rehash
|
||||
|
||||
There are lots more things but it is 12:30am on a Friday night and I'm
|
||||
heading home :-).
|
||||
|
||||
eric 22-Jun-1996
|
||||
This version has quite a few major bug fixes and improvements. It DOES NOT
|
||||
do SSLv3 yet.
|
||||
|
||||
The main things changed
|
||||
- A Few days ago I added the s_mult application to ssleay which is
|
||||
a demo of an SSL server running in an event loop type thing.
|
||||
It supports non-blocking IO, I have finally gotten it right, SSL_accept()
|
||||
can operate in non-blocking IO mode, look at the code to see how :-).
|
||||
Have a read of doc/s_mult as well. This program leaks memory and
|
||||
file descriptors everywhere but I have not cleaned it up yet.
|
||||
This is a demo of how to do non-blocking IO.
|
||||
- The SSL session management has been 'worked over' and there is now
|
||||
quite an expansive set of functions to manipulate them. Have a read of
|
||||
doc/session.doc for some-things I quickly whipped up about how it now works.
|
||||
This assume you know the SSLv2 protocol :-)
|
||||
- I can now read/write the netscape certificate format, use the
|
||||
-inform/-outform 'net' options to the x509 command. I have not put support
|
||||
for this type in the other demo programs, but it would be easy to add.
|
||||
- asn1parse and 'enc' have been modified so that when reading base64
|
||||
encoded files (pem format), they do not require '-----BEGIN' header lines.
|
||||
The 'enc' program had a buffering bug fixed, it can be used as a general
|
||||
base64 -> binary -> base64 filter by doing 'enc -a -e' and 'enc -a -d'
|
||||
respecivly. Leaving out the '-a' flag in this case makes the 'enc' command
|
||||
into a form of 'cat'.
|
||||
- The 'x509' and 'req' programs have been fixed and modified a little so
|
||||
that they generate self-signed certificates correctly. The test
|
||||
script actually generates a 'CA' certificate and then 'signs' a
|
||||
'user' certificate. Have a look at this shell script (test/sstest)
|
||||
to see how things work, it tests most possible combinations of what can
|
||||
be done.
|
||||
- The 'SSL_set_pref_cipher()' function has been 'fixed' and the prefered name
|
||||
of SSL_set_cipher_list() is now the correct API (stops confusion :-).
|
||||
If this function is used in the client, only the specified ciphers can
|
||||
be used, with preference given to the order the ciphers were listed.
|
||||
For the server, if this is used, only the specified ciphers will be used
|
||||
to accept connections. If this 'option' is not used, a default set of
|
||||
ciphers will be used. The SSL_CTX_set_cipher_list(SSL_CTX *ctx) sets this
|
||||
list for all ciphers started against the SSL_CTX. So the order is
|
||||
SSL cipher_list, if not present, SSL_CTX cipher list, if not
|
||||
present, then the library default.
|
||||
What this means is that normally ciphers like
|
||||
NULL-MD5 will never be used. The only way this cipher can be used
|
||||
for both ends to specify to use it.
|
||||
To enable or disable ciphers in the library at build time, modify the
|
||||
first field for the cipher in the ssl_ciphers array in ssl/ssl_lib.c.
|
||||
This file also contains the 'pref_cipher' list which is the default
|
||||
cipher preference order.
|
||||
- I'm not currently sure if the 'rsa -inform net' and the 'rsa -outform net'
|
||||
options work. They should, and they enable loading and writing the
|
||||
netscape rsa private key format. I will be re-working this section of
|
||||
SSLeay for the next version. What is currently in place is a quick and
|
||||
dirty hack.
|
||||
- I've re-written parts of the bignum library. This gives speedups
|
||||
for all platforms. I now provide assembler for use under Windows NT.
|
||||
I have not tested the Windows 3.1 assembler but it is quite simple code.
|
||||
This gives RSAprivate_key operation encryption times of 0.047s (512bit key)
|
||||
and 0.230s (1024bit key) on a pentium 100 which I consider reasonable.
|
||||
Basically the times available under linux/solaris x86 can be achieve under
|
||||
Windows NT. I still don't know how these times compare to RSA's BSAFE
|
||||
library but I have been emailing with people and with their help, I should
|
||||
be able to get my library's quite a bit faster still (more algorithm changes).
|
||||
The object file crypto/bn/asm/x86-32.obj should be used when linking
|
||||
under NT.
|
||||
- 'make makefile.one' in the top directory will generate a single makefile
|
||||
called 'makefile.one' This makefile contains no perl references and
|
||||
will build the SSLeay library into the 'tmp' and 'out' directories.
|
||||
util/mk1mf.pl >makefile.one is how this makefile is
|
||||
generated. The mk1mf.pl command take several option to generate the
|
||||
makefile for use with cc, gcc, Visual C++ and Borland C++. This is
|
||||
still under development. I have only build .lib's for NT and MSDOS
|
||||
I will be working on this more. I still need to play with the
|
||||
correct compiler setups for these compilers and add some more stuff but
|
||||
basically if you just want to compile the library
|
||||
on a 'non-unix' platform, this is a very very good file to start with :-).
|
||||
Have a look in the 'microsoft' directory for my current makefiles.
|
||||
I have not yet modified things to link with sockets under Windows NT.
|
||||
You guys should be able to do this since this is actually outside of the
|
||||
SSLeay scope :-). I will be doing it for myself soon.
|
||||
util/mk1mf.pl takes quite a few options including no-rc, rsaref and no-sock
|
||||
to build without RC2/RC4, to require RSAref for linking, and to
|
||||
build with no socket code.
|
||||
|
||||
- Oh yes, the cipher that was reported to be compatible with RSA's RC2 cipher
|
||||
that was posted to sci.crypt has been added to the library and SSL.
|
||||
I take the view that if RC2 is going to be included in a standard,
|
||||
I'll include the cipher to make my package complete.
|
||||
There are NO_RC2, NO_RC4 and NO_IDEA macros to remove these ciphers
|
||||
at compile time. I have not tested this recently but it should all work
|
||||
and if you are in the USA and don't want RSA threatening to sue you,
|
||||
you could probably remove the RC4/RC2 code inside these sections.
|
||||
I may in the future include a perl script that does this code
|
||||
removal automatically for those in the USA :-).
|
||||
- I have removed all references to sed in the makefiles. So basically,
|
||||
the development environment requires perl and sh. The build environment
|
||||
does not (use the makefile.one makefile).
|
||||
The Configure script still requires perl, this will probably stay that way
|
||||
since I have perl for Windows NT :-).
|
||||
|
||||
eric (03-May-1996)
|
||||
|
||||
PS Have a look in the VERSION file for more details on the changes and
|
||||
bug fixes.
|
||||
I have fixed a few bugs, added alpha and x86 assembler and generally cleaned
|
||||
things up. This version will be quite stable, mostly because I'm on
|
||||
holidays until 10-March-1996. For any problems in the interum, send email
|
||||
to Tim Hudson <tjh@mincom.oz.au>.
|
||||
|
||||
SSLeay 0.5.0
|
||||
|
||||
12-12-95
|
||||
This is going out before it should really be released.
|
||||
|
||||
I leave for 11 weeks holidays on the 22-12-95 and so I either sit on
|
||||
this for 11 weeks or get things out. It is still going to change a
|
||||
lot in the next week so if you do grab this version, please test and
|
||||
give me feed back ASAP, inculuding questions on how to do things with
|
||||
the library. This will prompt me to write documentation so I don't
|
||||
have to answer the same question again :-).
|
||||
|
||||
This 'pre' release version is for people who are interested in the
|
||||
library. The applications will have to be changed to use
|
||||
the new version of the SSL interface. I intend to finish more
|
||||
documentation before I leave but until then, look at the programs in
|
||||
the apps directory. As far as code goes, it is much much nicer than
|
||||
the old version.
|
||||
|
||||
The current library works, has no memory leaks (as far as I can tell)
|
||||
and is far more bug free that 0.4.5d. There are no global variable of
|
||||
consequence (I believe) and I will produce some documentation that
|
||||
tell where to look for those people that do want to do multi-threaded
|
||||
stuff.
|
||||
|
||||
There should be more documentation. Have a look in the
|
||||
doc directory. I'll be adding more before I leave, it is a start
|
||||
by mostly documents the crypto library. Tim Hudson will update
|
||||
the web page ASAP. The spelling and grammar are crap but
|
||||
it is better than nothing :-)
|
||||
|
||||
Reasons to start playing with version 0.5.0
|
||||
- All the programs in the apps directory build into one ssleay binary.
|
||||
- There is a new version of the 'req' program that generates certificate
|
||||
requests, there is even documentation for this one :-)
|
||||
- There is a demo certification authorithy program. Currently it will
|
||||
look at the simple database and update it. It will generate CRL from
|
||||
the data base. You need to edit the database by hand to revoke a
|
||||
certificate, it is my aim to use perl5/Tk but I don't have time to do
|
||||
this right now. It will generate the certificates but the management
|
||||
scripts still need to be written. This is not a hard task.
|
||||
- Things have been cleaned up alot.
|
||||
- Have a look at the enc and dgst programs in the apps directory.
|
||||
- It supports v3 of x509 certiticates.
|
||||
|
||||
|
||||
Major things missing.
|
||||
- I have been working on (and thinging about) the distributed x509
|
||||
hierachy problem. I have not had time to put my solution in place.
|
||||
It will have to wait until I come back.
|
||||
- I have not put in CRL checking in the certificate verification but
|
||||
it would not be hard to do. I was waiting until I could generate my
|
||||
own CRL (which has only been in the last week) and I don't have time
|
||||
to put it in correctly.
|
||||
- Montgomery multiplication need to be implemented. I know the
|
||||
algorithm, just ran out of time.
|
||||
- PKCS#7. I can load and write the DER version. I need to re-work
|
||||
things to support BER (if that means nothing, read the ASN1 spec :-).
|
||||
- Testing of the higher level digital envelope routines. I have not
|
||||
played with the *_seal() and *_open() type functions. They are
|
||||
written but need testing. The *_sign() and *_verify() functions are
|
||||
rock solid.
|
||||
- PEM. Doing this and PKCS#7 have been dependant on the distributed
|
||||
x509 heirachy problem. I started implementing my ideas, got
|
||||
distracted writing a CA program and then ran out of time. I provide
|
||||
the functionality of RSAref at least.
|
||||
- Re work the asm. code for the x86. I've changed by low level bignum
|
||||
interface again, so I really need to tweak the x86 stuff. gcc is
|
||||
good enough for the other boxes.
|
||||
|
@ -50,5 +50,23 @@ guidelines:
|
||||
test/README for information on the test framework.
|
||||
|
||||
6. New features or changed functionality must include
|
||||
documentation. Please look at the "pod" files in doc for
|
||||
examples of our style.
|
||||
documentation. Please look at the "pod" files in doc/man[1357] for
|
||||
examples of our style. Run "make doc-nits" to make sure that your
|
||||
documentation changes are clean.
|
||||
|
||||
7. For user visible changes (API changes, behaviour changes, ...),
|
||||
consider adding a note in CHANGES. This could be a summarising
|
||||
description of the change, and could explain the grander details.
|
||||
Have a look through existing entries for inspiration.
|
||||
Please note that this is NOT simply a copy of git-log oneliners.
|
||||
Also note that security fixes get an entry in CHANGES.
|
||||
This file helps users get more in depth information of what comes
|
||||
with a specific release without having to sift through the higher
|
||||
noise ratio in git-log.
|
||||
|
||||
8. For larger or more important user visible changes, as well as
|
||||
security fixes, please add a line in NEWS. On exception, it might be
|
||||
worth adding a multi-line entry (such as the entry that announces all
|
||||
the types that became opaque with OpenSSL 1.1.0).
|
||||
This file helps users get a very quick summary of what comes with a
|
||||
specific release, to see if an upgrade is worth the effort.
|
||||
|
File diff suppressed because it is too large
Load Diff
File diff suppressed because it is too large
Load Diff
@ -4,9 +4,7 @@
|
||||
|
||||
The OpenSSL toolkit stays under a double license, i.e. both the conditions of
|
||||
the OpenSSL License and the original SSLeay license apply to the toolkit.
|
||||
See below for the actual license texts. Actually both licenses are BSD-style
|
||||
Open Source licenses. In case of any license issues related to OpenSSL
|
||||
please contact openssl-core@openssl.org.
|
||||
See below for the actual license texts.
|
||||
|
||||
OpenSSL License
|
||||
---------------
|
||||
|
@ -1,692 +0,0 @@
|
||||
### Generated automatically from Makefile.org by Configure.
|
||||
|
||||
##
|
||||
## Makefile for OpenSSL
|
||||
##
|
||||
|
||||
VERSION=1.0.2p
|
||||
MAJOR=1
|
||||
MINOR=0.2
|
||||
SHLIB_VERSION_NUMBER=1.0.0
|
||||
SHLIB_VERSION_HISTORY=
|
||||
SHLIB_MAJOR=1
|
||||
SHLIB_MINOR=0.0
|
||||
SHLIB_EXT=
|
||||
PLATFORM=dist
|
||||
OPTIONS= no-ec_nistp_64_gcc_128 no-gmp no-jpake no-krb5 no-libunbound no-md2 no-rc5 no-rfc3779 no-sctp no-shared no-ssl-trace no-ssl2 no-store no-unit-test no-weak-ssl-ciphers no-zlib no-zlib-dynamic static-engine
|
||||
CONFIGURE_ARGS=dist
|
||||
SHLIB_TARGET=
|
||||
|
||||
# HERE indicates where this Makefile lives. This can be used to indicate
|
||||
# where sub-Makefiles are expected to be. Currently has very limited usage,
|
||||
# and should probably not be bothered with at all.
|
||||
HERE=.
|
||||
|
||||
# INSTALL_PREFIX is for package builders so that they can configure
|
||||
# for, say, /usr/ and yet have everything installed to /tmp/somedir/usr/.
|
||||
# Normally it is left empty.
|
||||
INSTALL_PREFIX=
|
||||
INSTALLTOP=/usr/local/ssl
|
||||
|
||||
# Do not edit this manually. Use Configure --openssldir=DIR do change this!
|
||||
OPENSSLDIR=/usr/local/ssl
|
||||
|
||||
# NO_IDEA - Define to build without the IDEA algorithm
|
||||
# NO_RC4 - Define to build without the RC4 algorithm
|
||||
# NO_RC2 - Define to build without the RC2 algorithm
|
||||
# THREADS - Define when building with threads, you will probably also need any
|
||||
# system defines as well, i.e. _REENTERANT for Solaris 2.[34]
|
||||
# TERMIO - Define the termio terminal subsystem, needed if sgtty is missing.
|
||||
# TERMIOS - Define the termios terminal subsystem, Silicon Graphics.
|
||||
# LONGCRYPT - Define to use HPUX 10.x's long password modification to crypt(3).
|
||||
# DEVRANDOM - Give this the value of the 'random device' if your OS supports
|
||||
# one. 32 bytes will be read from this when the random
|
||||
# number generator is initalised.
|
||||
# SSL_FORBID_ENULL - define if you want the server to be not able to use the
|
||||
# NULL encryption ciphers.
|
||||
#
|
||||
# LOCK_DEBUG - turns on lots of lock debug output :-)
|
||||
# REF_CHECK - turn on some xyz_free() assertions.
|
||||
# REF_PRINT - prints some stuff on structure free.
|
||||
# CRYPTO_MDEBUG - turns on my 'memory leak' detecting stuff
|
||||
# MFUNC - Make all Malloc/Free/Realloc calls call
|
||||
# CRYPTO_malloc/CRYPTO_free/CRYPTO_realloc which can be setup to
|
||||
# call application defined callbacks via CRYPTO_set_mem_functions()
|
||||
# MD5_ASM needs to be defined to use the x86 assembler for MD5
|
||||
# SHA1_ASM needs to be defined to use the x86 assembler for SHA1
|
||||
# RMD160_ASM needs to be defined to use the x86 assembler for RIPEMD160
|
||||
# Do not define B_ENDIAN or L_ENDIAN if 'unsigned long' == 8. It must
|
||||
# equal 4.
|
||||
# PKCS1_CHECK - pkcs1 tests.
|
||||
|
||||
CC= cc
|
||||
CFLAG= -O
|
||||
DEPFLAG= -DOPENSSL_NO_EC_NISTP_64_GCC_128 -DOPENSSL_NO_GMP -DOPENSSL_NO_JPAKE -DOPENSSL_NO_LIBUNBOUND -DOPENSSL_NO_MD2 -DOPENSSL_NO_RC5 -DOPENSSL_NO_RFC3779 -DOPENSSL_NO_SCTP -DOPENSSL_NO_SSL_TRACE -DOPENSSL_NO_SSL2 -DOPENSSL_NO_STORE -DOPENSSL_NO_UNIT_TEST -DOPENSSL_NO_WEAK_SSL_CIPHERS
|
||||
PEX_LIBS=
|
||||
EX_LIBS=
|
||||
EXE_EXT=
|
||||
ARFLAGS=
|
||||
AR= ar $(ARFLAGS) r
|
||||
RANLIB= /usr/bin/ranlib
|
||||
RC= windres
|
||||
NM= nm
|
||||
PERL= /usr/bin/perl
|
||||
TAR= tar
|
||||
TARFLAGS= --no-recursion
|
||||
MAKEDEPPROG= cc
|
||||
LIBDIR=lib
|
||||
|
||||
# We let the C compiler driver to take care of .s files. This is done in
|
||||
# order to be excused from maintaining a separate set of architecture
|
||||
# dependent assembler flags. E.g. if you throw -mcpu=ultrasparc at SPARC
|
||||
# gcc, then the driver will automatically translate it to -xarch=v8plus
|
||||
# and pass it down to assembler.
|
||||
AS=$(CC) -c
|
||||
ASFLAG=$(CFLAG)
|
||||
|
||||
# For x86 assembler: Set PROCESSOR to 386 if you want to support
|
||||
# the 80386.
|
||||
PROCESSOR=
|
||||
|
||||
# CPUID module collects small commonly used assembler snippets
|
||||
CPUID_OBJ= mem_clr.o
|
||||
BN_ASM= bn_asm.o
|
||||
EC_ASM=
|
||||
DES_ENC= des_enc.o fcrypt_b.o
|
||||
AES_ENC= aes_core.o aes_cbc.o
|
||||
BF_ENC= bf_enc.o
|
||||
CAST_ENC= c_enc.o
|
||||
RC4_ENC= rc4_enc.o rc4_skey.o
|
||||
RC5_ENC= rc5_enc.o
|
||||
MD5_ASM_OBJ=
|
||||
SHA1_ASM_OBJ=
|
||||
RMD160_ASM_OBJ=
|
||||
WP_ASM_OBJ= wp_block.o
|
||||
CMLL_ENC= camellia.o cmll_misc.o cmll_cbc.o
|
||||
MODES_ASM_OBJ=
|
||||
ENGINES_ASM_OBJ=
|
||||
PERLASM_SCHEME=
|
||||
|
||||
# KRB5 stuff
|
||||
KRB5_INCLUDES=
|
||||
LIBKRB5=
|
||||
|
||||
# Zlib stuff
|
||||
ZLIB_INCLUDE=
|
||||
LIBZLIB=
|
||||
|
||||
# TOP level FIPS install directory.
|
||||
FIPSDIR=/usr/local/ssl/fips-2.0
|
||||
|
||||
# This is the location of fipscanister.o and friends.
|
||||
# The FIPS module build will place it $(INSTALLTOP)/lib
|
||||
# but since $(INSTALLTOP) can only take the default value
|
||||
# when the module is built it will be in /usr/local/ssl/lib
|
||||
# $(INSTALLTOP) for this build may be different so hard
|
||||
# code the path.
|
||||
|
||||
FIPSLIBDIR=
|
||||
|
||||
# The location of the library which contains fipscanister.o
|
||||
# normally it will be libcrypto unless fipsdso is set in which
|
||||
# case it will be libfips. If not compiling in FIPS mode at all
|
||||
# this is empty making it a useful test for a FIPS compile.
|
||||
|
||||
FIPSCANLIB=
|
||||
|
||||
# Shared library base address. Currently only used on Windows.
|
||||
#
|
||||
|
||||
BASEADDR=0xFB00000
|
||||
|
||||
DIRS= crypto ssl engines apps test tools
|
||||
ENGDIRS= ccgost
|
||||
SHLIBDIRS= crypto ssl
|
||||
|
||||
# dirs in crypto to build
|
||||
SDIRS= \
|
||||
objects \
|
||||
md4 md5 sha mdc2 hmac ripemd whrlpool \
|
||||
des aes rc2 rc4 idea bf cast camellia seed modes \
|
||||
bn ec rsa dsa ecdsa dh ecdh dso engine \
|
||||
buffer bio stack lhash rand err \
|
||||
evp asn1 pem x509 x509v3 conf txt_db pkcs7 pkcs12 comp ocsp ui krb5 \
|
||||
cms pqueue ts srp cmac
|
||||
# keep in mind that the above list is adjusted by ./Configure
|
||||
# according to no-xxx arguments...
|
||||
|
||||
# tests to perform. "alltests" is a special word indicating that all tests
|
||||
# should be performed.
|
||||
TESTS = alltests
|
||||
|
||||
MAKEFILE= Makefile
|
||||
|
||||
MANDIR=$(OPENSSLDIR)/man
|
||||
MAN1=1
|
||||
MAN3=3
|
||||
MANSUFFIX=
|
||||
HTMLSUFFIX=html
|
||||
HTMLDIR=$(OPENSSLDIR)/html
|
||||
SHELL=/bin/sh
|
||||
|
||||
TOP= .
|
||||
ONEDIRS=out tmp
|
||||
EDIRS= times doc bugs util include certs ms shlib mt demos perl sf dep VMS
|
||||
WDIRS= windows
|
||||
LIBS= libcrypto.a libssl.a
|
||||
SHARED_CRYPTO=libcrypto$(SHLIB_EXT)
|
||||
SHARED_SSL=libssl$(SHLIB_EXT)
|
||||
SHARED_LIBS=
|
||||
SHARED_LIBS_LINK_EXTS=
|
||||
SHARED_LDFLAGS=
|
||||
|
||||
GENERAL= Makefile
|
||||
BASENAME= openssl
|
||||
NAME= $(BASENAME)-$(VERSION)
|
||||
TARFILE= ../$(NAME).tar
|
||||
EXHEADER= e_os2.h
|
||||
HEADER= e_os.h
|
||||
|
||||
all: Makefile build_all
|
||||
|
||||
# as we stick to -e, CLEARENV ensures that local variables in lower
|
||||
# Makefiles remain local and variable. $${VAR+VAR} is tribute to Korn
|
||||
# shell, which [annoyingly enough] terminates unset with error if VAR
|
||||
# is not present:-( TOP= && unset TOP is tribute to HP-UX /bin/sh,
|
||||
# which terminates unset with error if no variable was present:-(
|
||||
CLEARENV= TOP= && unset TOP $${LIB+LIB} $${LIBS+LIBS} \
|
||||
$${INCLUDE+INCLUDE} $${INCLUDES+INCLUDES} \
|
||||
$${DIR+DIR} $${DIRS+DIRS} $${SRC+SRC} \
|
||||
$${LIBSRC+LIBSRC} $${LIBOBJ+LIBOBJ} $${ALL+ALL} \
|
||||
$${EXHEADER+EXHEADER} $${HEADER+HEADER} \
|
||||
$${GENERAL+GENERAL} $${CFLAGS+CFLAGS} \
|
||||
$${ASFLAGS+ASFLAGS} $${AFLAGS+AFLAGS} \
|
||||
$${LDCMD+LDCMD} $${LDFLAGS+LDFLAGS} $${SCRIPTS+SCRIPTS} \
|
||||
$${SHAREDCMD+SHAREDCMD} $${SHAREDFLAGS+SHAREDFLAGS} \
|
||||
$${SHARED_LIB+SHARED_LIB} $${LIBEXTRAS+LIBEXTRAS} \
|
||||
$${APPS+APPS}
|
||||
|
||||
# LC_ALL=C ensures that error [and other] messages are delivered in
|
||||
# same language for uniform treatment.
|
||||
BUILDENV= LC_ALL=C PLATFORM='$(PLATFORM)' PROCESSOR='$(PROCESSOR)'\
|
||||
CC='$(CC)' CFLAG='$(CFLAG)' \
|
||||
AS='$(CC)' ASFLAG='$(CFLAG) -c' \
|
||||
AR='$(AR)' NM='$(NM)' RANLIB='$(RANLIB)' \
|
||||
RC='$(RC)' \
|
||||
CROSS_COMPILE='$(CROSS_COMPILE)' \
|
||||
PERL='$(PERL)' ENGDIRS='$(ENGDIRS)' \
|
||||
SDIRS='$(SDIRS)' LIBRPATH='$(INSTALLTOP)/$(LIBDIR)' \
|
||||
INSTALL_PREFIX='$(INSTALL_PREFIX)' \
|
||||
INSTALLTOP='$(INSTALLTOP)' OPENSSLDIR='$(OPENSSLDIR)' \
|
||||
LIBDIR='$(LIBDIR)' \
|
||||
MAKEDEPEND='$$$${TOP}/util/domd $$$${TOP} -MD $(MAKEDEPPROG)' \
|
||||
DEPFLAG='-DOPENSSL_NO_DEPRECATED $(DEPFLAG)' \
|
||||
MAKEDEPPROG='$(MAKEDEPPROG)' \
|
||||
SHARED_LDFLAGS='$(SHARED_LDFLAGS)' \
|
||||
KRB5_INCLUDES='$(KRB5_INCLUDES)' LIBKRB5='$(LIBKRB5)' \
|
||||
ZLIB_INCLUDE='$(ZLIB_INCLUDE)' LIBZLIB='$(LIBZLIB)' \
|
||||
EXE_EXT='$(EXE_EXT)' SHARED_LIBS='$(SHARED_LIBS)' \
|
||||
SHLIB_EXT='$(SHLIB_EXT)' SHLIB_TARGET='$(SHLIB_TARGET)' \
|
||||
PEX_LIBS='$(PEX_LIBS)' EX_LIBS='$(EX_LIBS)' \
|
||||
CPUID_OBJ='$(CPUID_OBJ)' BN_ASM='$(BN_ASM)' \
|
||||
EC_ASM='$(EC_ASM)' DES_ENC='$(DES_ENC)' \
|
||||
AES_ENC='$(AES_ENC)' CMLL_ENC='$(CMLL_ENC)' \
|
||||
BF_ENC='$(BF_ENC)' CAST_ENC='$(CAST_ENC)' \
|
||||
RC4_ENC='$(RC4_ENC)' RC5_ENC='$(RC5_ENC)' \
|
||||
SHA1_ASM_OBJ='$(SHA1_ASM_OBJ)' \
|
||||
MD5_ASM_OBJ='$(MD5_ASM_OBJ)' \
|
||||
RMD160_ASM_OBJ='$(RMD160_ASM_OBJ)' \
|
||||
WP_ASM_OBJ='$(WP_ASM_OBJ)' \
|
||||
MODES_ASM_OBJ='$(MODES_ASM_OBJ)' \
|
||||
ENGINES_ASM_OBJ='$(ENGINES_ASM_OBJ)' \
|
||||
PERLASM_SCHEME='$(PERLASM_SCHEME)' \
|
||||
FIPSLIBDIR='${FIPSLIBDIR}' \
|
||||
FIPSDIR='${FIPSDIR}' \
|
||||
FIPSCANLIB="$${FIPSCANLIB:-$(FIPSCANLIB)}" \
|
||||
THIS=$${THIS:-$@} MAKEFILE=Makefile MAKEOVERRIDES=
|
||||
# MAKEOVERRIDES= effectively "equalizes" GNU-ish and SysV-ish make flavors,
|
||||
# which in turn eliminates ambiguities in variable treatment with -e.
|
||||
|
||||
# BUILD_CMD is a generic macro to build a given target in a given
|
||||
# subdirectory. The target must be given through the shell variable
|
||||
# `target' and the subdirectory to build in must be given through `dir'.
|
||||
# This macro shouldn't be used directly, use RECURSIVE_BUILD_CMD or
|
||||
# BUILD_ONE_CMD instead.
|
||||
#
|
||||
# BUILD_ONE_CMD is a macro to build a given target in a given
|
||||
# subdirectory if that subdirectory is part of $(DIRS). It requires
|
||||
# exactly the same shell variables as BUILD_CMD.
|
||||
#
|
||||
# RECURSIVE_BUILD_CMD is a macro to build a given target in all
|
||||
# subdirectories defined in $(DIRS). It requires that the target
|
||||
# is given through the shell variable `target'.
|
||||
BUILD_CMD= if [ -d "$$dir" ]; then \
|
||||
( cd $$dir && echo "making $$target in $$dir..." && \
|
||||
$(CLEARENV) && $(MAKE) -e $(BUILDENV) TOP=.. DIR=$$dir $$target \
|
||||
) || exit 1; \
|
||||
fi
|
||||
RECURSIVE_BUILD_CMD=for dir in $(DIRS); do $(BUILD_CMD); done
|
||||
BUILD_ONE_CMD=\
|
||||
if expr " $(DIRS) " : ".* $$dir " >/dev/null 2>&1; then \
|
||||
$(BUILD_CMD); \
|
||||
fi
|
||||
|
||||
reflect:
|
||||
@[ -n "$(THIS)" ] && $(CLEARENV) && $(MAKE) $(THIS) -e $(BUILDENV)
|
||||
|
||||
sub_all: build_all
|
||||
|
||||
build_all: build_libs build_apps build_tests build_tools
|
||||
|
||||
build_libs: build_libcrypto build_libssl openssl.pc
|
||||
|
||||
build_libcrypto: build_crypto build_engines libcrypto.pc
|
||||
build_libssl: build_ssl libssl.pc
|
||||
|
||||
build_crypto:
|
||||
@dir=crypto; target=all; $(BUILD_ONE_CMD)
|
||||
build_ssl: build_crypto
|
||||
@dir=ssl; target=all; $(BUILD_ONE_CMD)
|
||||
build_engines: build_crypto
|
||||
@dir=engines; target=all; $(BUILD_ONE_CMD)
|
||||
build_apps: build_libs
|
||||
@dir=apps; target=all; $(BUILD_ONE_CMD)
|
||||
build_tests: build_libs
|
||||
@dir=test; target=all; $(BUILD_ONE_CMD)
|
||||
build_tools: build_libs
|
||||
@dir=tools; target=all; $(BUILD_ONE_CMD)
|
||||
|
||||
all_testapps: build_libs build_testapps
|
||||
build_testapps:
|
||||
@dir=crypto; target=testapps; $(BUILD_ONE_CMD)
|
||||
|
||||
fips_premain_dso$(EXE_EXT): libcrypto.a
|
||||
[ -z "$(FIPSCANLIB)" ] || $(CC) $(CFLAG) -Iinclude \
|
||||
-DFINGERPRINT_PREMAIN_DSO_LOAD -o $@ \
|
||||
$(FIPSLIBDIR)fips_premain.c $(FIPSLIBDIR)fipscanister.o \
|
||||
libcrypto.a $(EX_LIBS)
|
||||
|
||||
libcrypto$(SHLIB_EXT): libcrypto.a fips_premain_dso$(EXE_EXT)
|
||||
@if [ "$(SHLIB_TARGET)" != "" ]; then \
|
||||
if [ "$(FIPSCANLIB)" = "libcrypto" ]; then \
|
||||
FIPSLD_LIBCRYPTO=libcrypto.a ; \
|
||||
FIPSLD_CC="$(CC)"; CC=$(FIPSDIR)/bin/fipsld; \
|
||||
export CC FIPSLD_CC FIPSLD_LIBCRYPTO; \
|
||||
fi; \
|
||||
$(MAKE) -e SHLIBDIRS=crypto CC="$${CC:-$(CC)}" build-shared && \
|
||||
(touch -c fips_premain_dso$(EXE_EXT) || :); \
|
||||
else \
|
||||
echo "There's no support for shared libraries on this platform" >&2; \
|
||||
exit 1; \
|
||||
fi
|
||||
|
||||
libssl$(SHLIB_EXT): libcrypto$(SHLIB_EXT) libssl.a
|
||||
@if [ "$(SHLIB_TARGET)" != "" ]; then \
|
||||
$(MAKE) SHLIBDIRS=ssl SHLIBDEPS='-lcrypto' build-shared; \
|
||||
else \
|
||||
echo "There's no support for shared libraries on this platform" >&2; \
|
||||
exit 1; \
|
||||
fi
|
||||
|
||||
clean-shared:
|
||||
@set -e; for i in $(SHLIBDIRS); do \
|
||||
if [ -n "$(SHARED_LIBS_LINK_EXTS)" ]; then \
|
||||
tmp="$(SHARED_LIBS_LINK_EXTS)"; \
|
||||
for j in $${tmp:-x}; do \
|
||||
( set -x; rm -f lib$$i$$j ); \
|
||||
done; \
|
||||
fi; \
|
||||
( set -x; rm -f lib$$i$(SHLIB_EXT) ); \
|
||||
if expr "$(PLATFORM)" : "Cygwin" >/dev/null; then \
|
||||
( set -x; rm -f cyg$$i$(SHLIB_EXT) lib$$i$(SHLIB_EXT).a ); \
|
||||
fi; \
|
||||
done
|
||||
|
||||
link-shared:
|
||||
@ set -e; for i in $(SHLIBDIRS); do \
|
||||
$(MAKE) -f $(HERE)/Makefile.shared -e $(BUILDENV) \
|
||||
LIBNAME=$$i LIBVERSION=$(SHLIB_MAJOR).$(SHLIB_MINOR) \
|
||||
LIBCOMPATVERSIONS=";$(SHLIB_VERSION_HISTORY)" \
|
||||
symlink.$(SHLIB_TARGET); \
|
||||
libs="$$libs -l$$i"; \
|
||||
done
|
||||
|
||||
build-shared: do_$(SHLIB_TARGET) link-shared
|
||||
|
||||
do_$(SHLIB_TARGET):
|
||||
@ set -e; libs='-L. $(SHLIBDEPS)'; for i in $(SHLIBDIRS); do \
|
||||
if [ "$$i" = "ssl" -a -n "$(LIBKRB5)" ]; then \
|
||||
libs="$(LIBKRB5) $$libs"; \
|
||||
fi; \
|
||||
$(CLEARENV) && $(MAKE) -f Makefile.shared -e $(BUILDENV) \
|
||||
LIBNAME=$$i LIBVERSION=$(SHLIB_MAJOR).$(SHLIB_MINOR) \
|
||||
LIBCOMPATVERSIONS=";$(SHLIB_VERSION_HISTORY)" \
|
||||
LIBDEPS="$$libs $(EX_LIBS)" \
|
||||
link_a.$(SHLIB_TARGET); \
|
||||
libs="-l$$i $$libs"; \
|
||||
done
|
||||
|
||||
libcrypto.pc: Makefile
|
||||
@ ( echo 'prefix=$(INSTALLTOP)'; \
|
||||
echo 'exec_prefix=$${prefix}'; \
|
||||
echo 'libdir=$${exec_prefix}/$(LIBDIR)'; \
|
||||
echo 'includedir=$${prefix}/include'; \
|
||||
echo 'enginesdir=$${libdir}/engines'; \
|
||||
echo ''; \
|
||||
echo 'Name: OpenSSL-libcrypto'; \
|
||||
echo 'Description: OpenSSL cryptography library'; \
|
||||
echo 'Version: '$(VERSION); \
|
||||
echo 'Requires: '; \
|
||||
echo 'Libs: -L$${libdir} -lcrypto'; \
|
||||
echo 'Libs.private: $(EX_LIBS)'; \
|
||||
echo 'Cflags: -I$${includedir} $(KRB5_INCLUDES)' ) > libcrypto.pc
|
||||
|
||||
libssl.pc: Makefile
|
||||
@ ( echo 'prefix=$(INSTALLTOP)'; \
|
||||
echo 'exec_prefix=$${prefix}'; \
|
||||
echo 'libdir=$${exec_prefix}/$(LIBDIR)'; \
|
||||
echo 'includedir=$${prefix}/include'; \
|
||||
echo ''; \
|
||||
echo 'Name: OpenSSL-libssl'; \
|
||||
echo 'Description: Secure Sockets Layer and cryptography libraries'; \
|
||||
echo 'Version: '$(VERSION); \
|
||||
echo 'Requires.private: libcrypto'; \
|
||||
echo 'Libs: -L$${libdir} -lssl'; \
|
||||
echo 'Libs.private: $(EX_LIBS)'; \
|
||||
echo 'Cflags: -I$${includedir} $(KRB5_INCLUDES)' ) > libssl.pc
|
||||
|
||||
openssl.pc: Makefile
|
||||
@ ( echo 'prefix=$(INSTALLTOP)'; \
|
||||
echo 'exec_prefix=$${prefix}'; \
|
||||
echo 'libdir=$${exec_prefix}/$(LIBDIR)'; \
|
||||
echo 'includedir=$${prefix}/include'; \
|
||||
echo ''; \
|
||||
echo 'Name: OpenSSL'; \
|
||||
echo 'Description: Secure Sockets Layer and cryptography libraries and tools'; \
|
||||
echo 'Version: '$(VERSION); \
|
||||
echo 'Requires: libssl libcrypto' ) > openssl.pc
|
||||
|
||||
Makefile: Makefile.org Configure config
|
||||
@echo "Makefile is older than Makefile.org, Configure or config."
|
||||
@echo "Reconfigure the source tree (via './config' or 'perl Configure'), please."
|
||||
@false
|
||||
|
||||
libclean:
|
||||
rm -f *.map *.so *.so.* *.dylib *.dll engines/*.so engines/*.dll engines/*.dylib *.a engines/*.a */lib */*/lib
|
||||
|
||||
clean: libclean
|
||||
rm -f shlib/*.o *.o core a.out fluff rehash.time testlog make.log cctest cctest.c
|
||||
@set -e; target=clean; $(RECURSIVE_BUILD_CMD)
|
||||
rm -f $(LIBS)
|
||||
rm -f openssl.pc libssl.pc libcrypto.pc
|
||||
rm -f speed.* .pure
|
||||
rm -f $(TARFILE)
|
||||
@set -e; for i in $(ONEDIRS) ;\
|
||||
do \
|
||||
rm -fr $$i/*; \
|
||||
done
|
||||
|
||||
distclean: clean
|
||||
-$(RM) `find . -name .git -prune -o -type l -print`
|
||||
$(RM) apps/CA.pl
|
||||
$(RM) test/evptests.txt test/newkey.pem test/testkey.pem test/testreq.pem
|
||||
$(RM) tools/c_rehash
|
||||
$(RM) crypto/opensslconf.h
|
||||
$(RM) Makefile Makefile.bak
|
||||
|
||||
makefile.one: files
|
||||
$(PERL) util/mk1mf.pl >makefile.one; \
|
||||
sh util/do_ms.sh
|
||||
|
||||
files:
|
||||
$(PERL) $(TOP)/util/files.pl Makefile > $(TOP)/MINFO
|
||||
@set -e; target=files; $(RECURSIVE_BUILD_CMD)
|
||||
|
||||
links:
|
||||
@$(PERL) $(TOP)/util/mkdir-p.pl include/openssl
|
||||
@$(PERL) $(TOP)/util/mklink.pl include/openssl $(EXHEADER)
|
||||
@set -e; target=links; $(RECURSIVE_BUILD_CMD)
|
||||
|
||||
gentests:
|
||||
@(cd test && echo "generating dummy tests (if needed)..." && \
|
||||
$(CLEARENV) && $(MAKE) -e $(BUILDENV) TESTS='$(TESTS)' OPENSSL_DEBUG_MEMORY=on generate );
|
||||
|
||||
dclean:
|
||||
rm -rf *.bak include/openssl certs/.0
|
||||
@set -e; target=dclean; $(RECURSIVE_BUILD_CMD)
|
||||
|
||||
rehash: rehash.time
|
||||
rehash.time: certs apps
|
||||
@if [ -z "$(CROSS_COMPILE)" ]; then \
|
||||
(OPENSSL="`pwd`/util/opensslwrap.sh"; \
|
||||
[ -x "apps/openssl.exe" ] && OPENSSL="apps/openssl.exe" || :; \
|
||||
OPENSSL_DEBUG_MEMORY=on; \
|
||||
export OPENSSL OPENSSL_DEBUG_MEMORY; \
|
||||
$(PERL) tools/c_rehash certs/demo) && \
|
||||
touch rehash.time; \
|
||||
else :; fi
|
||||
|
||||
test: tests
|
||||
|
||||
tests: rehash
|
||||
@(cd test && echo "testing..." && \
|
||||
$(CLEARENV) && $(MAKE) -e $(BUILDENV) TOP=.. TESTS='$(TESTS)' OPENSSL_DEBUG_MEMORY=on OPENSSL_CONF=../apps/openssl.cnf tests );
|
||||
OPENSSL_CONF=apps/openssl.cnf util/opensslwrap.sh version -a
|
||||
|
||||
report:
|
||||
@$(PERL) util/selftest.pl
|
||||
|
||||
update: errors stacks util/libeay.num util/ssleay.num TABLE
|
||||
@set -e; target=update; $(RECURSIVE_BUILD_CMD)
|
||||
|
||||
depend:
|
||||
@set -e; target=depend; $(RECURSIVE_BUILD_CMD)
|
||||
|
||||
lint:
|
||||
@set -e; target=lint; $(RECURSIVE_BUILD_CMD)
|
||||
|
||||
tags:
|
||||
rm -f TAGS
|
||||
find . -name '[^.]*.[ch]' | xargs etags -a
|
||||
|
||||
errors:
|
||||
$(PERL) util/ck_errf.pl -strict */*.c */*/*.c
|
||||
$(PERL) util/mkerr.pl -recurse -write
|
||||
(cd engines; $(MAKE) PERL=$(PERL) errors)
|
||||
|
||||
stacks:
|
||||
$(PERL) util/mkstack.pl -write
|
||||
|
||||
util/libeay.num::
|
||||
$(PERL) util/mkdef.pl crypto update
|
||||
|
||||
util/ssleay.num::
|
||||
$(PERL) util/mkdef.pl ssl update
|
||||
|
||||
TABLE: Configure
|
||||
(echo 'Output of `Configure TABLE'"':"; \
|
||||
$(PERL) Configure TABLE) > TABLE
|
||||
|
||||
# Build distribution tar-file. As the list of files returned by "find" is
|
||||
# pretty long, on several platforms a "too many arguments" error or similar
|
||||
# would occur. Therefore the list of files is temporarily stored into a file
|
||||
# and read directly, requiring GNU-Tar. Call "make TAR=gtar dist" if the normal
|
||||
# tar does not support the --files-from option.
|
||||
TAR_COMMAND=$(TAR) $(TARFLAGS) --files-from $(TARFILE).list \
|
||||
--owner 0 --group 0 \
|
||||
--transform 's|^|$(NAME)/|' \
|
||||
-cvf -
|
||||
|
||||
$(TARFILE).list:
|
||||
find * \! -name STATUS \! -name TABLE \! -name '*.o' \! -name '*.a' \
|
||||
\! -name '*.so' \! -name '*.so.*' \! -name 'openssl' \
|
||||
\( \! -name '*test' -o -name bctest -o -name pod2mantest \) \
|
||||
\! -name '.#*' \! -name '*~' \! -type l \
|
||||
| sort > $(TARFILE).list
|
||||
|
||||
tar: $(TARFILE).list
|
||||
find . -type d -print | xargs chmod 755
|
||||
find . -type f -print | xargs chmod a+r
|
||||
find . -type f -perm -0100 -print | xargs chmod a+x
|
||||
$(TAR_COMMAND) | gzip --best > $(TARFILE).gz
|
||||
rm -f $(TARFILE).list
|
||||
ls -l $(TARFILE).gz
|
||||
|
||||
tar-snap: $(TARFILE).list
|
||||
$(TAR_COMMAND) > $(TARFILE)
|
||||
rm -f $(TARFILE).list
|
||||
ls -l $(TARFILE)
|
||||
|
||||
dist:
|
||||
$(PERL) Configure dist
|
||||
@$(MAKE) SDIRS='$(SDIRS)' clean
|
||||
@$(MAKE) TAR='$(TAR)' TARFLAGS='$(TARFLAGS)' $(DISTTARVARS) tar
|
||||
|
||||
install: all install_docs install_sw
|
||||
|
||||
install_sw:
|
||||
@$(PERL) $(TOP)/util/mkdir-p.pl $(INSTALL_PREFIX)$(INSTALLTOP)/bin \
|
||||
$(INSTALL_PREFIX)$(INSTALLTOP)/$(LIBDIR) \
|
||||
$(INSTALL_PREFIX)$(INSTALLTOP)/$(LIBDIR)/engines \
|
||||
$(INSTALL_PREFIX)$(INSTALLTOP)/$(LIBDIR)/pkgconfig \
|
||||
$(INSTALL_PREFIX)$(INSTALLTOP)/include/openssl \
|
||||
$(INSTALL_PREFIX)$(OPENSSLDIR)/misc \
|
||||
$(INSTALL_PREFIX)$(OPENSSLDIR)/certs \
|
||||
$(INSTALL_PREFIX)$(OPENSSLDIR)/private
|
||||
@set -e; headerlist="$(EXHEADER)"; for i in $$headerlist;\
|
||||
do \
|
||||
(cp $$i $(INSTALL_PREFIX)$(INSTALLTOP)/include/openssl/$$i; \
|
||||
chmod 644 $(INSTALL_PREFIX)$(INSTALLTOP)/include/openssl/$$i ); \
|
||||
done;
|
||||
@set -e; target=install; $(RECURSIVE_BUILD_CMD)
|
||||
@set -e; liblist="$(LIBS)"; for i in $$liblist ;\
|
||||
do \
|
||||
if [ -f "$$i" ]; then \
|
||||
( echo installing $$i; \
|
||||
cp $$i $(INSTALL_PREFIX)$(INSTALLTOP)/$(LIBDIR)/$$i.new; \
|
||||
$(RANLIB) $(INSTALL_PREFIX)$(INSTALLTOP)/$(LIBDIR)/$$i.new; \
|
||||
chmod 644 $(INSTALL_PREFIX)$(INSTALLTOP)/$(LIBDIR)/$$i.new; \
|
||||
mv -f $(INSTALL_PREFIX)$(INSTALLTOP)/$(LIBDIR)/$$i.new $(INSTALL_PREFIX)$(INSTALLTOP)/$(LIBDIR)/$$i ); \
|
||||
fi; \
|
||||
done;
|
||||
@set -e; if [ -n "$(SHARED_LIBS)" ]; then \
|
||||
tmp="$(SHARED_LIBS)"; \
|
||||
for i in $${tmp:-x}; \
|
||||
do \
|
||||
if [ -f "$$i" -o -f "$$i.a" ]; then \
|
||||
( echo installing $$i; \
|
||||
if expr "$(PLATFORM)" : "Cygwin" >/dev/null; then \
|
||||
c=`echo $$i | sed 's/^lib\(.*\)\.dll\.a/cyg\1-$(SHLIB_VERSION_NUMBER).dll/'`; \
|
||||
cp $$c $(INSTALL_PREFIX)$(INSTALLTOP)/bin/$$c.new; \
|
||||
chmod 755 $(INSTALL_PREFIX)$(INSTALLTOP)/bin/$$c.new; \
|
||||
mv -f $(INSTALL_PREFIX)$(INSTALLTOP)/bin/$$c.new $(INSTALL_PREFIX)$(INSTALLTOP)/bin/$$c; \
|
||||
cp $$i $(INSTALL_PREFIX)$(INSTALLTOP)/$(LIBDIR)/$$i.new; \
|
||||
chmod 644 $(INSTALL_PREFIX)$(INSTALLTOP)/$(LIBDIR)/$$i.new; \
|
||||
mv -f $(INSTALL_PREFIX)$(INSTALLTOP)/$(LIBDIR)/$$i.new $(INSTALL_PREFIX)$(INSTALLTOP)/$(LIBDIR)/$$i; \
|
||||
else \
|
||||
cp $$i $(INSTALL_PREFIX)$(INSTALLTOP)/$(LIBDIR)/$$i.new; \
|
||||
chmod 555 $(INSTALL_PREFIX)$(INSTALLTOP)/$(LIBDIR)/$$i.new; \
|
||||
mv -f $(INSTALL_PREFIX)$(INSTALLTOP)/$(LIBDIR)/$$i.new $(INSTALL_PREFIX)$(INSTALLTOP)/$(LIBDIR)/$$i; \
|
||||
fi ); \
|
||||
if expr $(PLATFORM) : 'mingw' > /dev/null; then \
|
||||
( case $$i in \
|
||||
*crypto*) i=libeay32.dll;; \
|
||||
*ssl*) i=ssleay32.dll;; \
|
||||
esac; \
|
||||
echo installing $$i; \
|
||||
cp $$i $(INSTALL_PREFIX)$(INSTALLTOP)/bin/$$i.new; \
|
||||
chmod 755 $(INSTALL_PREFIX)$(INSTALLTOP)/bin/$$i.new; \
|
||||
mv -f $(INSTALL_PREFIX)$(INSTALLTOP)/bin/$$i.new $(INSTALL_PREFIX)$(INSTALLTOP)/bin/$$i ); \
|
||||
fi; \
|
||||
fi; \
|
||||
done; \
|
||||
( here="`pwd`"; \
|
||||
cd $(INSTALL_PREFIX)$(INSTALLTOP)/$(LIBDIR); \
|
||||
$(MAKE) -f $$here/Makefile HERE="$$here" link-shared ); \
|
||||
if [ "$(INSTALLTOP)" != "/usr" ]; then \
|
||||
echo 'OpenSSL shared libraries have been installed in:'; \
|
||||
echo ' $(INSTALLTOP)'; \
|
||||
echo ''; \
|
||||
sed -e '1,/^$$/d' doc/openssl-shared.txt; \
|
||||
fi; \
|
||||
fi
|
||||
cp libcrypto.pc $(INSTALL_PREFIX)$(INSTALLTOP)/$(LIBDIR)/pkgconfig
|
||||
chmod 644 $(INSTALL_PREFIX)$(INSTALLTOP)/$(LIBDIR)/pkgconfig/libcrypto.pc
|
||||
cp libssl.pc $(INSTALL_PREFIX)$(INSTALLTOP)/$(LIBDIR)/pkgconfig
|
||||
chmod 644 $(INSTALL_PREFIX)$(INSTALLTOP)/$(LIBDIR)/pkgconfig/libssl.pc
|
||||
cp openssl.pc $(INSTALL_PREFIX)$(INSTALLTOP)/$(LIBDIR)/pkgconfig
|
||||
chmod 644 $(INSTALL_PREFIX)$(INSTALLTOP)/$(LIBDIR)/pkgconfig/openssl.pc
|
||||
|
||||
install_html_docs:
|
||||
here="`pwd`"; \
|
||||
filecase=; \
|
||||
case "$(PLATFORM)" in DJGPP|Cygwin*|mingw*|darwin*-*-cc) \
|
||||
filecase=-i; \
|
||||
esac; \
|
||||
for subdir in apps crypto ssl; do \
|
||||
mkdir -p $(INSTALL_PREFIX)$(HTMLDIR)/$$subdir; \
|
||||
for i in doc/$$subdir/*.pod; do \
|
||||
fn=`basename $$i .pod`; \
|
||||
echo "installing html/$$fn.$(HTMLSUFFIX)"; \
|
||||
cat $$i \
|
||||
| sed -r 's/L<([^)]*)(\([0-9]\))?\|([^)]*)(\([0-9]\))?>/L<\1|\3>/g' \
|
||||
| pod2html --podroot=doc --htmlroot=.. --podpath=apps:crypto:ssl \
|
||||
| sed -r 's/<!DOCTYPE.*//g' \
|
||||
> $(INSTALL_PREFIX)$(HTMLDIR)/$$subdir/$$fn.$(HTMLSUFFIX); \
|
||||
$(PERL) util/extract-names.pl < $$i | \
|
||||
grep -v $$filecase "^$$fn\$$" | \
|
||||
(cd $(INSTALL_PREFIX)$(HTMLDIR)/$$subdir; \
|
||||
while read n; do \
|
||||
PLATFORM=$(PLATFORM) $$here/util/point.sh $$fn.$(HTMLSUFFIX) "$$n".$(HTMLSUFFIX); \
|
||||
done); \
|
||||
done; \
|
||||
done
|
||||
|
||||
install_docs:
|
||||
@$(PERL) $(TOP)/util/mkdir-p.pl \
|
||||
$(INSTALL_PREFIX)$(MANDIR)/man1 \
|
||||
$(INSTALL_PREFIX)$(MANDIR)/man3 \
|
||||
$(INSTALL_PREFIX)$(MANDIR)/man5 \
|
||||
$(INSTALL_PREFIX)$(MANDIR)/man7
|
||||
@pod2man="`cd ./util; ./pod2mantest $(PERL)`"; \
|
||||
here="`pwd`"; \
|
||||
filecase=; \
|
||||
case "$(PLATFORM)" in DJGPP|Cygwin*|mingw*|darwin*-*-cc) \
|
||||
filecase=-i; \
|
||||
esac; \
|
||||
set -e; for i in doc/apps/*.pod; do \
|
||||
fn=`basename $$i .pod`; \
|
||||
sec=`$(PERL) util/extract-section.pl 1 < $$i`; \
|
||||
echo "installing man$$sec/$$fn.$${sec}$(MANSUFFIX)"; \
|
||||
(cd `$(PERL) util/dirname.pl $$i`; \
|
||||
sh -c "$$pod2man \
|
||||
--section=$$sec --center=OpenSSL \
|
||||
--release=$(VERSION) `basename $$i`") \
|
||||
> $(INSTALL_PREFIX)$(MANDIR)/man$$sec/$$fn.$${sec}$(MANSUFFIX); \
|
||||
$(PERL) util/extract-names.pl < $$i | \
|
||||
(grep -v $$filecase "^$$fn\$$"; true) | \
|
||||
(grep -v "[ ]"; true) | \
|
||||
(cd $(INSTALL_PREFIX)$(MANDIR)/man$$sec/; \
|
||||
while read n; do \
|
||||
PLATFORM=$(PLATFORM) $$here/util/point.sh $$fn.$${sec}$(MANSUFFIX) "$$n".$${sec}$(MANSUFFIX); \
|
||||
done); \
|
||||
done; \
|
||||
set -e; for i in doc/crypto/*.pod doc/ssl/*.pod; do \
|
||||
fn=`basename $$i .pod`; \
|
||||
sec=`$(PERL) util/extract-section.pl 3 < $$i`; \
|
||||
echo "installing man$$sec/$$fn.$${sec}$(MANSUFFIX)"; \
|
||||
(cd `$(PERL) util/dirname.pl $$i`; \
|
||||
sh -c "$$pod2man \
|
||||
--section=$$sec --center=OpenSSL \
|
||||
--release=$(VERSION) `basename $$i`") \
|
||||
> $(INSTALL_PREFIX)$(MANDIR)/man$$sec/$$fn.$${sec}$(MANSUFFIX); \
|
||||
$(PERL) util/extract-names.pl < $$i | \
|
||||
(grep -v $$filecase "^$$fn\$$"; true) | \
|
||||
(grep -v "[ ]"; true) | \
|
||||
(cd $(INSTALL_PREFIX)$(MANDIR)/man$$sec/; \
|
||||
while read n; do \
|
||||
PLATFORM=$(PLATFORM) $$here/util/point.sh $$fn.$${sec}$(MANSUFFIX) "$$n".$${sec}$(MANSUFFIX); \
|
||||
done); \
|
||||
done
|
||||
|
||||
# DO NOT DELETE THIS LINE -- make depend depends on it.
|
@ -1,690 +0,0 @@
|
||||
##
|
||||
## Makefile for OpenSSL
|
||||
##
|
||||
|
||||
VERSION=
|
||||
MAJOR=
|
||||
MINOR=
|
||||
SHLIB_VERSION_NUMBER=
|
||||
SHLIB_VERSION_HISTORY=
|
||||
SHLIB_MAJOR=
|
||||
SHLIB_MINOR=
|
||||
SHLIB_EXT=
|
||||
PLATFORM=dist
|
||||
OPTIONS=
|
||||
CONFIGURE_ARGS=
|
||||
SHLIB_TARGET=
|
||||
|
||||
# HERE indicates where this Makefile lives. This can be used to indicate
|
||||
# where sub-Makefiles are expected to be. Currently has very limited usage,
|
||||
# and should probably not be bothered with at all.
|
||||
HERE=.
|
||||
|
||||
# INSTALL_PREFIX is for package builders so that they can configure
|
||||
# for, say, /usr/ and yet have everything installed to /tmp/somedir/usr/.
|
||||
# Normally it is left empty.
|
||||
INSTALL_PREFIX=
|
||||
INSTALLTOP=/usr/local/ssl
|
||||
|
||||
# Do not edit this manually. Use Configure --openssldir=DIR do change this!
|
||||
OPENSSLDIR=/usr/local/ssl
|
||||
|
||||
# NO_IDEA - Define to build without the IDEA algorithm
|
||||
# NO_RC4 - Define to build without the RC4 algorithm
|
||||
# NO_RC2 - Define to build without the RC2 algorithm
|
||||
# THREADS - Define when building with threads, you will probably also need any
|
||||
# system defines as well, i.e. _REENTERANT for Solaris 2.[34]
|
||||
# TERMIO - Define the termio terminal subsystem, needed if sgtty is missing.
|
||||
# TERMIOS - Define the termios terminal subsystem, Silicon Graphics.
|
||||
# LONGCRYPT - Define to use HPUX 10.x's long password modification to crypt(3).
|
||||
# DEVRANDOM - Give this the value of the 'random device' if your OS supports
|
||||
# one. 32 bytes will be read from this when the random
|
||||
# number generator is initalised.
|
||||
# SSL_FORBID_ENULL - define if you want the server to be not able to use the
|
||||
# NULL encryption ciphers.
|
||||
#
|
||||
# LOCK_DEBUG - turns on lots of lock debug output :-)
|
||||
# REF_CHECK - turn on some xyz_free() assertions.
|
||||
# REF_PRINT - prints some stuff on structure free.
|
||||
# CRYPTO_MDEBUG - turns on my 'memory leak' detecting stuff
|
||||
# MFUNC - Make all Malloc/Free/Realloc calls call
|
||||
# CRYPTO_malloc/CRYPTO_free/CRYPTO_realloc which can be setup to
|
||||
# call application defined callbacks via CRYPTO_set_mem_functions()
|
||||
# MD5_ASM needs to be defined to use the x86 assembler for MD5
|
||||
# SHA1_ASM needs to be defined to use the x86 assembler for SHA1
|
||||
# RMD160_ASM needs to be defined to use the x86 assembler for RIPEMD160
|
||||
# Do not define B_ENDIAN or L_ENDIAN if 'unsigned long' == 8. It must
|
||||
# equal 4.
|
||||
# PKCS1_CHECK - pkcs1 tests.
|
||||
|
||||
CC= cc
|
||||
CFLAG= -O
|
||||
DEPFLAG=
|
||||
PEX_LIBS=
|
||||
EX_LIBS=
|
||||
EXE_EXT=
|
||||
ARFLAGS?= r
|
||||
AR=ar $(ARFLAGS)
|
||||
RANLIB= ranlib
|
||||
RC= windres
|
||||
NM= nm
|
||||
PERL= perl
|
||||
TAR= tar
|
||||
TARFLAGS= --no-recursion
|
||||
MAKEDEPPROG=makedepend
|
||||
LIBDIR=lib
|
||||
|
||||
# We let the C compiler driver to take care of .s files. This is done in
|
||||
# order to be excused from maintaining a separate set of architecture
|
||||
# dependent assembler flags. E.g. if you throw -mcpu=ultrasparc at SPARC
|
||||
# gcc, then the driver will automatically translate it to -xarch=v8plus
|
||||
# and pass it down to assembler.
|
||||
AS=$(CC) -c
|
||||
ASFLAG=$(CFLAG)
|
||||
|
||||
# For x86 assembler: Set PROCESSOR to 386 if you want to support
|
||||
# the 80386.
|
||||
PROCESSOR=
|
||||
|
||||
# CPUID module collects small commonly used assembler snippets
|
||||
CPUID_OBJ=
|
||||
BN_ASM= bn_asm.o
|
||||
EC_ASM=
|
||||
DES_ENC= des_enc.o fcrypt_b.o
|
||||
AES_ENC= aes_core.o aes_cbc.o
|
||||
BF_ENC= bf_enc.o
|
||||
CAST_ENC= c_enc.o
|
||||
RC4_ENC= rc4_enc.o
|
||||
RC5_ENC= rc5_enc.o
|
||||
MD5_ASM_OBJ=
|
||||
SHA1_ASM_OBJ=
|
||||
RMD160_ASM_OBJ=
|
||||
WP_ASM_OBJ=
|
||||
CMLL_ENC=
|
||||
MODES_ASM_OBJ=
|
||||
ENGINES_ASM_OBJ=
|
||||
PERLASM_SCHEME=
|
||||
|
||||
# KRB5 stuff
|
||||
KRB5_INCLUDES=
|
||||
LIBKRB5=
|
||||
|
||||
# Zlib stuff
|
||||
ZLIB_INCLUDE=
|
||||
LIBZLIB=
|
||||
|
||||
# TOP level FIPS install directory.
|
||||
FIPSDIR=
|
||||
|
||||
# This is the location of fipscanister.o and friends.
|
||||
# The FIPS module build will place it $(INSTALLTOP)/lib
|
||||
# but since $(INSTALLTOP) can only take the default value
|
||||
# when the module is built it will be in /usr/local/ssl/lib
|
||||
# $(INSTALLTOP) for this build may be different so hard
|
||||
# code the path.
|
||||
|
||||
FIPSLIBDIR=
|
||||
|
||||
# The location of the library which contains fipscanister.o
|
||||
# normally it will be libcrypto unless fipsdso is set in which
|
||||
# case it will be libfips. If not compiling in FIPS mode at all
|
||||
# this is empty making it a useful test for a FIPS compile.
|
||||
|
||||
FIPSCANLIB=
|
||||
|
||||
# Shared library base address. Currently only used on Windows.
|
||||
#
|
||||
|
||||
BASEADDR=
|
||||
|
||||
DIRS= crypto ssl engines apps test tools
|
||||
ENGDIRS= ccgost
|
||||
SHLIBDIRS= crypto ssl
|
||||
|
||||
# dirs in crypto to build
|
||||
SDIRS= \
|
||||
objects \
|
||||
md2 md4 md5 sha mdc2 hmac ripemd whrlpool \
|
||||
des aes rc2 rc4 rc5 idea bf cast camellia seed modes \
|
||||
bn ec rsa dsa ecdsa dh ecdh dso engine \
|
||||
buffer bio stack lhash rand err \
|
||||
evp asn1 pem x509 x509v3 conf txt_db pkcs7 pkcs12 comp ocsp ui krb5 \
|
||||
cms pqueue ts jpake srp store cmac
|
||||
# keep in mind that the above list is adjusted by ./Configure
|
||||
# according to no-xxx arguments...
|
||||
|
||||
# tests to perform. "alltests" is a special word indicating that all tests
|
||||
# should be performed.
|
||||
TESTS = alltests
|
||||
|
||||
MAKEFILE= Makefile
|
||||
|
||||
MANDIR=$(OPENSSLDIR)/man
|
||||
MAN1=1
|
||||
MAN3=3
|
||||
MANSUFFIX=
|
||||
HTMLSUFFIX=html
|
||||
HTMLDIR=$(OPENSSLDIR)/html
|
||||
SHELL=/bin/sh
|
||||
|
||||
TOP= .
|
||||
ONEDIRS=out tmp
|
||||
EDIRS= times doc bugs util include certs ms shlib mt demos perl sf dep VMS
|
||||
WDIRS= windows
|
||||
LIBS= libcrypto.a libssl.a
|
||||
SHARED_CRYPTO=libcrypto$(SHLIB_EXT)
|
||||
SHARED_SSL=libssl$(SHLIB_EXT)
|
||||
SHARED_LIBS=
|
||||
SHARED_LIBS_LINK_EXTS=
|
||||
SHARED_LDFLAGS=
|
||||
|
||||
GENERAL= Makefile
|
||||
BASENAME= openssl
|
||||
NAME= $(BASENAME)-$(VERSION)
|
||||
TARFILE= ../$(NAME).tar
|
||||
EXHEADER= e_os2.h
|
||||
HEADER= e_os.h
|
||||
|
||||
all: Makefile build_all
|
||||
|
||||
# as we stick to -e, CLEARENV ensures that local variables in lower
|
||||
# Makefiles remain local and variable. $${VAR+VAR} is tribute to Korn
|
||||
# shell, which [annoyingly enough] terminates unset with error if VAR
|
||||
# is not present:-( TOP= && unset TOP is tribute to HP-UX /bin/sh,
|
||||
# which terminates unset with error if no variable was present:-(
|
||||
CLEARENV= TOP= && unset TOP $${LIB+LIB} $${LIBS+LIBS} \
|
||||
$${INCLUDE+INCLUDE} $${INCLUDES+INCLUDES} \
|
||||
$${DIR+DIR} $${DIRS+DIRS} $${SRC+SRC} \
|
||||
$${LIBSRC+LIBSRC} $${LIBOBJ+LIBOBJ} $${ALL+ALL} \
|
||||
$${EXHEADER+EXHEADER} $${HEADER+HEADER} \
|
||||
$${GENERAL+GENERAL} $${CFLAGS+CFLAGS} \
|
||||
$${ASFLAGS+ASFLAGS} $${AFLAGS+AFLAGS} \
|
||||
$${LDCMD+LDCMD} $${LDFLAGS+LDFLAGS} $${SCRIPTS+SCRIPTS} \
|
||||
$${SHAREDCMD+SHAREDCMD} $${SHAREDFLAGS+SHAREDFLAGS} \
|
||||
$${SHARED_LIB+SHARED_LIB} $${LIBEXTRAS+LIBEXTRAS} \
|
||||
$${APPS+APPS}
|
||||
|
||||
# LC_ALL=C ensures that error [and other] messages are delivered in
|
||||
# same language for uniform treatment.
|
||||
BUILDENV= LC_ALL=C PLATFORM='$(PLATFORM)' PROCESSOR='$(PROCESSOR)'\
|
||||
CC='$(CC)' CFLAG='$(CFLAG)' \
|
||||
AS='$(CC)' ASFLAG='$(CFLAG) -c' \
|
||||
AR='$(AR)' NM='$(NM)' RANLIB='$(RANLIB)' \
|
||||
RC='$(RC)' \
|
||||
CROSS_COMPILE='$(CROSS_COMPILE)' \
|
||||
PERL='$(PERL)' ENGDIRS='$(ENGDIRS)' \
|
||||
SDIRS='$(SDIRS)' LIBRPATH='$(INSTALLTOP)/$(LIBDIR)' \
|
||||
INSTALL_PREFIX='$(INSTALL_PREFIX)' \
|
||||
INSTALLTOP='$(INSTALLTOP)' OPENSSLDIR='$(OPENSSLDIR)' \
|
||||
LIBDIR='$(LIBDIR)' \
|
||||
MAKEDEPEND='$$$${TOP}/util/domd $$$${TOP} -MD $(MAKEDEPPROG)' \
|
||||
DEPFLAG='-DOPENSSL_NO_DEPRECATED $(DEPFLAG)' \
|
||||
MAKEDEPPROG='$(MAKEDEPPROG)' \
|
||||
SHARED_LDFLAGS='$(SHARED_LDFLAGS)' \
|
||||
KRB5_INCLUDES='$(KRB5_INCLUDES)' LIBKRB5='$(LIBKRB5)' \
|
||||
ZLIB_INCLUDE='$(ZLIB_INCLUDE)' LIBZLIB='$(LIBZLIB)' \
|
||||
EXE_EXT='$(EXE_EXT)' SHARED_LIBS='$(SHARED_LIBS)' \
|
||||
SHLIB_EXT='$(SHLIB_EXT)' SHLIB_TARGET='$(SHLIB_TARGET)' \
|
||||
PEX_LIBS='$(PEX_LIBS)' EX_LIBS='$(EX_LIBS)' \
|
||||
CPUID_OBJ='$(CPUID_OBJ)' BN_ASM='$(BN_ASM)' \
|
||||
EC_ASM='$(EC_ASM)' DES_ENC='$(DES_ENC)' \
|
||||
AES_ENC='$(AES_ENC)' CMLL_ENC='$(CMLL_ENC)' \
|
||||
BF_ENC='$(BF_ENC)' CAST_ENC='$(CAST_ENC)' \
|
||||
RC4_ENC='$(RC4_ENC)' RC5_ENC='$(RC5_ENC)' \
|
||||
SHA1_ASM_OBJ='$(SHA1_ASM_OBJ)' \
|
||||
MD5_ASM_OBJ='$(MD5_ASM_OBJ)' \
|
||||
RMD160_ASM_OBJ='$(RMD160_ASM_OBJ)' \
|
||||
WP_ASM_OBJ='$(WP_ASM_OBJ)' \
|
||||
MODES_ASM_OBJ='$(MODES_ASM_OBJ)' \
|
||||
ENGINES_ASM_OBJ='$(ENGINES_ASM_OBJ)' \
|
||||
PERLASM_SCHEME='$(PERLASM_SCHEME)' \
|
||||
FIPSLIBDIR='${FIPSLIBDIR}' \
|
||||
FIPSDIR='${FIPSDIR}' \
|
||||
FIPSCANLIB="$${FIPSCANLIB:-$(FIPSCANLIB)}" \
|
||||
THIS=$${THIS:-$@} MAKEFILE=Makefile MAKEOVERRIDES=
|
||||
# MAKEOVERRIDES= effectively "equalizes" GNU-ish and SysV-ish make flavors,
|
||||
# which in turn eliminates ambiguities in variable treatment with -e.
|
||||
|
||||
# BUILD_CMD is a generic macro to build a given target in a given
|
||||
# subdirectory. The target must be given through the shell variable
|
||||
# `target' and the subdirectory to build in must be given through `dir'.
|
||||
# This macro shouldn't be used directly, use RECURSIVE_BUILD_CMD or
|
||||
# BUILD_ONE_CMD instead.
|
||||
#
|
||||
# BUILD_ONE_CMD is a macro to build a given target in a given
|
||||
# subdirectory if that subdirectory is part of $(DIRS). It requires
|
||||
# exactly the same shell variables as BUILD_CMD.
|
||||
#
|
||||
# RECURSIVE_BUILD_CMD is a macro to build a given target in all
|
||||
# subdirectories defined in $(DIRS). It requires that the target
|
||||
# is given through the shell variable `target'.
|
||||
BUILD_CMD= if [ -d "$$dir" ]; then \
|
||||
( cd $$dir && echo "making $$target in $$dir..." && \
|
||||
$(CLEARENV) && $(MAKE) -e $(BUILDENV) TOP=.. DIR=$$dir $$target \
|
||||
) || exit 1; \
|
||||
fi
|
||||
RECURSIVE_BUILD_CMD=for dir in $(DIRS); do $(BUILD_CMD); done
|
||||
BUILD_ONE_CMD=\
|
||||
if expr " $(DIRS) " : ".* $$dir " >/dev/null 2>&1; then \
|
||||
$(BUILD_CMD); \
|
||||
fi
|
||||
|
||||
reflect:
|
||||
@[ -n "$(THIS)" ] && $(CLEARENV) && $(MAKE) $(THIS) -e $(BUILDENV)
|
||||
|
||||
sub_all: build_all
|
||||
|
||||
build_all: build_libs build_apps build_tests build_tools
|
||||
|
||||
build_libs: build_libcrypto build_libssl openssl.pc
|
||||
|
||||
build_libcrypto: build_crypto build_engines libcrypto.pc
|
||||
build_libssl: build_ssl libssl.pc
|
||||
|
||||
build_crypto:
|
||||
@dir=crypto; target=all; $(BUILD_ONE_CMD)
|
||||
build_ssl: build_crypto
|
||||
@dir=ssl; target=all; $(BUILD_ONE_CMD)
|
||||
build_engines: build_crypto
|
||||
@dir=engines; target=all; $(BUILD_ONE_CMD)
|
||||
build_apps: build_libs
|
||||
@dir=apps; target=all; $(BUILD_ONE_CMD)
|
||||
build_tests: build_libs
|
||||
@dir=test; target=all; $(BUILD_ONE_CMD)
|
||||
build_tools: build_libs
|
||||
@dir=tools; target=all; $(BUILD_ONE_CMD)
|
||||
|
||||
all_testapps: build_libs build_testapps
|
||||
build_testapps:
|
||||
@dir=crypto; target=testapps; $(BUILD_ONE_CMD)
|
||||
|
||||
fips_premain_dso$(EXE_EXT): libcrypto.a
|
||||
[ -z "$(FIPSCANLIB)" ] || $(CC) $(CFLAG) -Iinclude \
|
||||
-DFINGERPRINT_PREMAIN_DSO_LOAD -o $@ \
|
||||
$(FIPSLIBDIR)fips_premain.c $(FIPSLIBDIR)fipscanister.o \
|
||||
libcrypto.a $(EX_LIBS)
|
||||
|
||||
libcrypto$(SHLIB_EXT): libcrypto.a fips_premain_dso$(EXE_EXT)
|
||||
@if [ "$(SHLIB_TARGET)" != "" ]; then \
|
||||
if [ "$(FIPSCANLIB)" = "libcrypto" ]; then \
|
||||
FIPSLD_LIBCRYPTO=libcrypto.a ; \
|
||||
FIPSLD_CC="$(CC)"; CC=$(FIPSDIR)/bin/fipsld; \
|
||||
export CC FIPSLD_CC FIPSLD_LIBCRYPTO; \
|
||||
fi; \
|
||||
$(MAKE) -e SHLIBDIRS=crypto CC="$${CC:-$(CC)}" build-shared && \
|
||||
(touch -c fips_premain_dso$(EXE_EXT) || :); \
|
||||
else \
|
||||
echo "There's no support for shared libraries on this platform" >&2; \
|
||||
exit 1; \
|
||||
fi
|
||||
|
||||
libssl$(SHLIB_EXT): libcrypto$(SHLIB_EXT) libssl.a
|
||||
@if [ "$(SHLIB_TARGET)" != "" ]; then \
|
||||
$(MAKE) SHLIBDIRS=ssl SHLIBDEPS='-lcrypto' build-shared; \
|
||||
else \
|
||||
echo "There's no support for shared libraries on this platform" >&2; \
|
||||
exit 1; \
|
||||
fi
|
||||
|
||||
clean-shared:
|
||||
@set -e; for i in $(SHLIBDIRS); do \
|
||||
if [ -n "$(SHARED_LIBS_LINK_EXTS)" ]; then \
|
||||
tmp="$(SHARED_LIBS_LINK_EXTS)"; \
|
||||
for j in $${tmp:-x}; do \
|
||||
( set -x; rm -f lib$$i$$j ); \
|
||||
done; \
|
||||
fi; \
|
||||
( set -x; rm -f lib$$i$(SHLIB_EXT) ); \
|
||||
if expr "$(PLATFORM)" : "Cygwin" >/dev/null; then \
|
||||
( set -x; rm -f cyg$$i$(SHLIB_EXT) lib$$i$(SHLIB_EXT).a ); \
|
||||
fi; \
|
||||
done
|
||||
|
||||
link-shared:
|
||||
@ set -e; for i in $(SHLIBDIRS); do \
|
||||
$(MAKE) -f $(HERE)/Makefile.shared -e $(BUILDENV) \
|
||||
LIBNAME=$$i LIBVERSION=$(SHLIB_MAJOR).$(SHLIB_MINOR) \
|
||||
LIBCOMPATVERSIONS=";$(SHLIB_VERSION_HISTORY)" \
|
||||
symlink.$(SHLIB_TARGET); \
|
||||
libs="$$libs -l$$i"; \
|
||||
done
|
||||
|
||||
build-shared: do_$(SHLIB_TARGET) link-shared
|
||||
|
||||
do_$(SHLIB_TARGET):
|
||||
@ set -e; libs='-L. $(SHLIBDEPS)'; for i in $(SHLIBDIRS); do \
|
||||
if [ "$$i" = "ssl" -a -n "$(LIBKRB5)" ]; then \
|
||||
libs="$(LIBKRB5) $$libs"; \
|
||||
fi; \
|
||||
$(CLEARENV) && $(MAKE) -f Makefile.shared -e $(BUILDENV) \
|
||||
LIBNAME=$$i LIBVERSION=$(SHLIB_MAJOR).$(SHLIB_MINOR) \
|
||||
LIBCOMPATVERSIONS=";$(SHLIB_VERSION_HISTORY)" \
|
||||
LIBDEPS="$$libs $(EX_LIBS)" \
|
||||
link_a.$(SHLIB_TARGET); \
|
||||
libs="-l$$i $$libs"; \
|
||||
done
|
||||
|
||||
libcrypto.pc: Makefile
|
||||
@ ( echo 'prefix=$(INSTALLTOP)'; \
|
||||
echo 'exec_prefix=$${prefix}'; \
|
||||
echo 'libdir=$${exec_prefix}/$(LIBDIR)'; \
|
||||
echo 'includedir=$${prefix}/include'; \
|
||||
echo 'enginesdir=$${libdir}/engines'; \
|
||||
echo ''; \
|
||||
echo 'Name: OpenSSL-libcrypto'; \
|
||||
echo 'Description: OpenSSL cryptography library'; \
|
||||
echo 'Version: '$(VERSION); \
|
||||
echo 'Requires: '; \
|
||||
echo 'Libs: -L$${libdir} -lcrypto'; \
|
||||
echo 'Libs.private: $(EX_LIBS)'; \
|
||||
echo 'Cflags: -I$${includedir} $(KRB5_INCLUDES)' ) > libcrypto.pc
|
||||
|
||||
libssl.pc: Makefile
|
||||
@ ( echo 'prefix=$(INSTALLTOP)'; \
|
||||
echo 'exec_prefix=$${prefix}'; \
|
||||
echo 'libdir=$${exec_prefix}/$(LIBDIR)'; \
|
||||
echo 'includedir=$${prefix}/include'; \
|
||||
echo ''; \
|
||||
echo 'Name: OpenSSL-libssl'; \
|
||||
echo 'Description: Secure Sockets Layer and cryptography libraries'; \
|
||||
echo 'Version: '$(VERSION); \
|
||||
echo 'Requires.private: libcrypto'; \
|
||||
echo 'Libs: -L$${libdir} -lssl'; \
|
||||
echo 'Libs.private: $(EX_LIBS)'; \
|
||||
echo 'Cflags: -I$${includedir} $(KRB5_INCLUDES)' ) > libssl.pc
|
||||
|
||||
openssl.pc: Makefile
|
||||
@ ( echo 'prefix=$(INSTALLTOP)'; \
|
||||
echo 'exec_prefix=$${prefix}'; \
|
||||
echo 'libdir=$${exec_prefix}/$(LIBDIR)'; \
|
||||
echo 'includedir=$${prefix}/include'; \
|
||||
echo ''; \
|
||||
echo 'Name: OpenSSL'; \
|
||||
echo 'Description: Secure Sockets Layer and cryptography libraries and tools'; \
|
||||
echo 'Version: '$(VERSION); \
|
||||
echo 'Requires: libssl libcrypto' ) > openssl.pc
|
||||
|
||||
Makefile: Makefile.org Configure config
|
||||
@echo "Makefile is older than Makefile.org, Configure or config."
|
||||
@echo "Reconfigure the source tree (via './config' or 'perl Configure'), please."
|
||||
@false
|
||||
|
||||
libclean:
|
||||
rm -f *.map *.so *.so.* *.dylib *.dll engines/*.so engines/*.dll engines/*.dylib *.a engines/*.a */lib */*/lib
|
||||
|
||||
clean: libclean
|
||||
rm -f shlib/*.o *.o core a.out fluff rehash.time testlog make.log cctest cctest.c
|
||||
@set -e; target=clean; $(RECURSIVE_BUILD_CMD)
|
||||
rm -f $(LIBS)
|
||||
rm -f openssl.pc libssl.pc libcrypto.pc
|
||||
rm -f speed.* .pure
|
||||
rm -f $(TARFILE)
|
||||
@set -e; for i in $(ONEDIRS) ;\
|
||||
do \
|
||||
rm -fr $$i/*; \
|
||||
done
|
||||
|
||||
distclean: clean
|
||||
-$(RM) `find . -name .git -prune -o -type l -print`
|
||||
$(RM) apps/CA.pl
|
||||
$(RM) test/evptests.txt test/newkey.pem test/testkey.pem test/testreq.pem
|
||||
$(RM) tools/c_rehash
|
||||
$(RM) crypto/opensslconf.h
|
||||
$(RM) Makefile Makefile.bak
|
||||
|
||||
makefile.one: files
|
||||
$(PERL) util/mk1mf.pl >makefile.one; \
|
||||
sh util/do_ms.sh
|
||||
|
||||
files:
|
||||
$(PERL) $(TOP)/util/files.pl Makefile > $(TOP)/MINFO
|
||||
@set -e; target=files; $(RECURSIVE_BUILD_CMD)
|
||||
|
||||
links:
|
||||
@$(PERL) $(TOP)/util/mkdir-p.pl include/openssl
|
||||
@$(PERL) $(TOP)/util/mklink.pl include/openssl $(EXHEADER)
|
||||
@set -e; target=links; $(RECURSIVE_BUILD_CMD)
|
||||
|
||||
gentests:
|
||||
@(cd test && echo "generating dummy tests (if needed)..." && \
|
||||
$(CLEARENV) && $(MAKE) -e $(BUILDENV) TESTS='$(TESTS)' OPENSSL_DEBUG_MEMORY=on generate );
|
||||
|
||||
dclean:
|
||||
rm -rf *.bak include/openssl certs/.0
|
||||
@set -e; target=dclean; $(RECURSIVE_BUILD_CMD)
|
||||
|
||||
rehash: rehash.time
|
||||
rehash.time: certs apps
|
||||
@if [ -z "$(CROSS_COMPILE)" ]; then \
|
||||
(OPENSSL="`pwd`/util/opensslwrap.sh"; \
|
||||
[ -x "apps/openssl.exe" ] && OPENSSL="apps/openssl.exe" || :; \
|
||||
OPENSSL_DEBUG_MEMORY=on; \
|
||||
export OPENSSL OPENSSL_DEBUG_MEMORY; \
|
||||
$(PERL) tools/c_rehash certs/demo) && \
|
||||
touch rehash.time; \
|
||||
else :; fi
|
||||
|
||||
test: tests
|
||||
|
||||
tests: rehash
|
||||
@(cd test && echo "testing..." && \
|
||||
$(CLEARENV) && $(MAKE) -e $(BUILDENV) TOP=.. TESTS='$(TESTS)' OPENSSL_DEBUG_MEMORY=on OPENSSL_CONF=../apps/openssl.cnf tests );
|
||||
OPENSSL_CONF=apps/openssl.cnf util/opensslwrap.sh version -a
|
||||
|
||||
report:
|
||||
@$(PERL) util/selftest.pl
|
||||
|
||||
update: errors stacks util/libeay.num util/ssleay.num TABLE
|
||||
@set -e; target=update; $(RECURSIVE_BUILD_CMD)
|
||||
|
||||
depend:
|
||||
@set -e; target=depend; $(RECURSIVE_BUILD_CMD)
|
||||
|
||||
lint:
|
||||
@set -e; target=lint; $(RECURSIVE_BUILD_CMD)
|
||||
|
||||
tags:
|
||||
rm -f TAGS
|
||||
find . -name '[^.]*.[ch]' | xargs etags -a
|
||||
|
||||
errors:
|
||||
$(PERL) util/ck_errf.pl -strict */*.c */*/*.c
|
||||
$(PERL) util/mkerr.pl -recurse -write
|
||||
(cd engines; $(MAKE) PERL=$(PERL) errors)
|
||||
|
||||
stacks:
|
||||
$(PERL) util/mkstack.pl -write
|
||||
|
||||
util/libeay.num::
|
||||
$(PERL) util/mkdef.pl crypto update
|
||||
|
||||
util/ssleay.num::
|
||||
$(PERL) util/mkdef.pl ssl update
|
||||
|
||||
TABLE: Configure
|
||||
(echo 'Output of `Configure TABLE'"':"; \
|
||||
$(PERL) Configure TABLE) > TABLE
|
||||
|
||||
# Build distribution tar-file. As the list of files returned by "find" is
|
||||
# pretty long, on several platforms a "too many arguments" error or similar
|
||||
# would occur. Therefore the list of files is temporarily stored into a file
|
||||
# and read directly, requiring GNU-Tar. Call "make TAR=gtar dist" if the normal
|
||||
# tar does not support the --files-from option.
|
||||
TAR_COMMAND=$(TAR) $(TARFLAGS) --files-from $(TARFILE).list \
|
||||
--owner 0 --group 0 \
|
||||
--transform 's|^|$(NAME)/|' \
|
||||
-cvf -
|
||||
|
||||
$(TARFILE).list:
|
||||
find * \! -name STATUS \! -name TABLE \! -name '*.o' \! -name '*.a' \
|
||||
\! -name '*.so' \! -name '*.so.*' \! -name 'openssl' \
|
||||
\( \! -name '*test' -o -name bctest -o -name pod2mantest \) \
|
||||
\! -name '.#*' \! -name '*~' \! -type l \
|
||||
| sort > $(TARFILE).list
|
||||
|
||||
tar: $(TARFILE).list
|
||||
find . -type d -print | xargs chmod 755
|
||||
find . -type f -print | xargs chmod a+r
|
||||
find . -type f -perm -0100 -print | xargs chmod a+x
|
||||
$(TAR_COMMAND) | gzip --best > $(TARFILE).gz
|
||||
rm -f $(TARFILE).list
|
||||
ls -l $(TARFILE).gz
|
||||
|
||||
tar-snap: $(TARFILE).list
|
||||
$(TAR_COMMAND) > $(TARFILE)
|
||||
rm -f $(TARFILE).list
|
||||
ls -l $(TARFILE)
|
||||
|
||||
dist:
|
||||
$(PERL) Configure dist
|
||||
@$(MAKE) SDIRS='$(SDIRS)' clean
|
||||
@$(MAKE) TAR='$(TAR)' TARFLAGS='$(TARFLAGS)' $(DISTTARVARS) tar
|
||||
|
||||
install: all install_docs install_sw
|
||||
|
||||
install_sw:
|
||||
@$(PERL) $(TOP)/util/mkdir-p.pl $(INSTALL_PREFIX)$(INSTALLTOP)/bin \
|
||||
$(INSTALL_PREFIX)$(INSTALLTOP)/$(LIBDIR) \
|
||||
$(INSTALL_PREFIX)$(INSTALLTOP)/$(LIBDIR)/engines \
|
||||
$(INSTALL_PREFIX)$(INSTALLTOP)/$(LIBDIR)/pkgconfig \
|
||||
$(INSTALL_PREFIX)$(INSTALLTOP)/include/openssl \
|
||||
$(INSTALL_PREFIX)$(OPENSSLDIR)/misc \
|
||||
$(INSTALL_PREFIX)$(OPENSSLDIR)/certs \
|
||||
$(INSTALL_PREFIX)$(OPENSSLDIR)/private
|
||||
@set -e; headerlist="$(EXHEADER)"; for i in $$headerlist;\
|
||||
do \
|
||||
(cp $$i $(INSTALL_PREFIX)$(INSTALLTOP)/include/openssl/$$i; \
|
||||
chmod 644 $(INSTALL_PREFIX)$(INSTALLTOP)/include/openssl/$$i ); \
|
||||
done;
|
||||
@set -e; target=install; $(RECURSIVE_BUILD_CMD)
|
||||
@set -e; liblist="$(LIBS)"; for i in $$liblist ;\
|
||||
do \
|
||||
if [ -f "$$i" ]; then \
|
||||
( echo installing $$i; \
|
||||
cp $$i $(INSTALL_PREFIX)$(INSTALLTOP)/$(LIBDIR)/$$i.new; \
|
||||
$(RANLIB) $(INSTALL_PREFIX)$(INSTALLTOP)/$(LIBDIR)/$$i.new; \
|
||||
chmod 644 $(INSTALL_PREFIX)$(INSTALLTOP)/$(LIBDIR)/$$i.new; \
|
||||
mv -f $(INSTALL_PREFIX)$(INSTALLTOP)/$(LIBDIR)/$$i.new $(INSTALL_PREFIX)$(INSTALLTOP)/$(LIBDIR)/$$i ); \
|
||||
fi; \
|
||||
done;
|
||||
@set -e; if [ -n "$(SHARED_LIBS)" ]; then \
|
||||
tmp="$(SHARED_LIBS)"; \
|
||||
for i in $${tmp:-x}; \
|
||||
do \
|
||||
if [ -f "$$i" -o -f "$$i.a" ]; then \
|
||||
( echo installing $$i; \
|
||||
if expr "$(PLATFORM)" : "Cygwin" >/dev/null; then \
|
||||
c=`echo $$i | sed 's/^lib\(.*\)\.dll\.a/cyg\1-$(SHLIB_VERSION_NUMBER).dll/'`; \
|
||||
cp $$c $(INSTALL_PREFIX)$(INSTALLTOP)/bin/$$c.new; \
|
||||
chmod 755 $(INSTALL_PREFIX)$(INSTALLTOP)/bin/$$c.new; \
|
||||
mv -f $(INSTALL_PREFIX)$(INSTALLTOP)/bin/$$c.new $(INSTALL_PREFIX)$(INSTALLTOP)/bin/$$c; \
|
||||
cp $$i $(INSTALL_PREFIX)$(INSTALLTOP)/$(LIBDIR)/$$i.new; \
|
||||
chmod 644 $(INSTALL_PREFIX)$(INSTALLTOP)/$(LIBDIR)/$$i.new; \
|
||||
mv -f $(INSTALL_PREFIX)$(INSTALLTOP)/$(LIBDIR)/$$i.new $(INSTALL_PREFIX)$(INSTALLTOP)/$(LIBDIR)/$$i; \
|
||||
else \
|
||||
cp $$i $(INSTALL_PREFIX)$(INSTALLTOP)/$(LIBDIR)/$$i.new; \
|
||||
chmod 555 $(INSTALL_PREFIX)$(INSTALLTOP)/$(LIBDIR)/$$i.new; \
|
||||
mv -f $(INSTALL_PREFIX)$(INSTALLTOP)/$(LIBDIR)/$$i.new $(INSTALL_PREFIX)$(INSTALLTOP)/$(LIBDIR)/$$i; \
|
||||
fi ); \
|
||||
if expr $(PLATFORM) : 'mingw' > /dev/null; then \
|
||||
( case $$i in \
|
||||
*crypto*) i=libeay32.dll;; \
|
||||
*ssl*) i=ssleay32.dll;; \
|
||||
esac; \
|
||||
echo installing $$i; \
|
||||
cp $$i $(INSTALL_PREFIX)$(INSTALLTOP)/bin/$$i.new; \
|
||||
chmod 755 $(INSTALL_PREFIX)$(INSTALLTOP)/bin/$$i.new; \
|
||||
mv -f $(INSTALL_PREFIX)$(INSTALLTOP)/bin/$$i.new $(INSTALL_PREFIX)$(INSTALLTOP)/bin/$$i ); \
|
||||
fi; \
|
||||
fi; \
|
||||
done; \
|
||||
( here="`pwd`"; \
|
||||
cd $(INSTALL_PREFIX)$(INSTALLTOP)/$(LIBDIR); \
|
||||
$(MAKE) -f $$here/Makefile HERE="$$here" link-shared ); \
|
||||
if [ "$(INSTALLTOP)" != "/usr" ]; then \
|
||||
echo 'OpenSSL shared libraries have been installed in:'; \
|
||||
echo ' $(INSTALLTOP)'; \
|
||||
echo ''; \
|
||||
sed -e '1,/^$$/d' doc/openssl-shared.txt; \
|
||||
fi; \
|
||||
fi
|
||||
cp libcrypto.pc $(INSTALL_PREFIX)$(INSTALLTOP)/$(LIBDIR)/pkgconfig
|
||||
chmod 644 $(INSTALL_PREFIX)$(INSTALLTOP)/$(LIBDIR)/pkgconfig/libcrypto.pc
|
||||
cp libssl.pc $(INSTALL_PREFIX)$(INSTALLTOP)/$(LIBDIR)/pkgconfig
|
||||
chmod 644 $(INSTALL_PREFIX)$(INSTALLTOP)/$(LIBDIR)/pkgconfig/libssl.pc
|
||||
cp openssl.pc $(INSTALL_PREFIX)$(INSTALLTOP)/$(LIBDIR)/pkgconfig
|
||||
chmod 644 $(INSTALL_PREFIX)$(INSTALLTOP)/$(LIBDIR)/pkgconfig/openssl.pc
|
||||
|
||||
install_html_docs:
|
||||
here="`pwd`"; \
|
||||
filecase=; \
|
||||
case "$(PLATFORM)" in DJGPP|Cygwin*|mingw*|darwin*-*-cc) \
|
||||
filecase=-i; \
|
||||
esac; \
|
||||
for subdir in apps crypto ssl; do \
|
||||
mkdir -p $(INSTALL_PREFIX)$(HTMLDIR)/$$subdir; \
|
||||
for i in doc/$$subdir/*.pod; do \
|
||||
fn=`basename $$i .pod`; \
|
||||
echo "installing html/$$fn.$(HTMLSUFFIX)"; \
|
||||
cat $$i \
|
||||
| sed -r 's/L<([^)]*)(\([0-9]\))?\|([^)]*)(\([0-9]\))?>/L<\1|\3>/g' \
|
||||
| pod2html --podroot=doc --htmlroot=.. --podpath=apps:crypto:ssl \
|
||||
| sed -r 's/<!DOCTYPE.*//g' \
|
||||
> $(INSTALL_PREFIX)$(HTMLDIR)/$$subdir/$$fn.$(HTMLSUFFIX); \
|
||||
$(PERL) util/extract-names.pl < $$i | \
|
||||
grep -v $$filecase "^$$fn\$$" | \
|
||||
(cd $(INSTALL_PREFIX)$(HTMLDIR)/$$subdir; \
|
||||
while read n; do \
|
||||
PLATFORM=$(PLATFORM) $$here/util/point.sh $$fn.$(HTMLSUFFIX) "$$n".$(HTMLSUFFIX); \
|
||||
done); \
|
||||
done; \
|
||||
done
|
||||
|
||||
install_docs:
|
||||
@$(PERL) $(TOP)/util/mkdir-p.pl \
|
||||
$(INSTALL_PREFIX)$(MANDIR)/man1 \
|
||||
$(INSTALL_PREFIX)$(MANDIR)/man3 \
|
||||
$(INSTALL_PREFIX)$(MANDIR)/man5 \
|
||||
$(INSTALL_PREFIX)$(MANDIR)/man7
|
||||
@pod2man="`cd ./util; ./pod2mantest $(PERL)`"; \
|
||||
here="`pwd`"; \
|
||||
filecase=; \
|
||||
case "$(PLATFORM)" in DJGPP|Cygwin*|mingw*|darwin*-*-cc) \
|
||||
filecase=-i; \
|
||||
esac; \
|
||||
set -e; for i in doc/apps/*.pod; do \
|
||||
fn=`basename $$i .pod`; \
|
||||
sec=`$(PERL) util/extract-section.pl 1 < $$i`; \
|
||||
echo "installing man$$sec/$$fn.$${sec}$(MANSUFFIX)"; \
|
||||
(cd `$(PERL) util/dirname.pl $$i`; \
|
||||
sh -c "$$pod2man \
|
||||
--section=$$sec --center=OpenSSL \
|
||||
--release=$(VERSION) `basename $$i`") \
|
||||
> $(INSTALL_PREFIX)$(MANDIR)/man$$sec/$$fn.$${sec}$(MANSUFFIX); \
|
||||
$(PERL) util/extract-names.pl < $$i | \
|
||||
(grep -v $$filecase "^$$fn\$$"; true) | \
|
||||
(grep -v "[ ]"; true) | \
|
||||
(cd $(INSTALL_PREFIX)$(MANDIR)/man$$sec/; \
|
||||
while read n; do \
|
||||
PLATFORM=$(PLATFORM) $$here/util/point.sh $$fn.$${sec}$(MANSUFFIX) "$$n".$${sec}$(MANSUFFIX); \
|
||||
done); \
|
||||
done; \
|
||||
set -e; for i in doc/crypto/*.pod doc/ssl/*.pod; do \
|
||||
fn=`basename $$i .pod`; \
|
||||
sec=`$(PERL) util/extract-section.pl 3 < $$i`; \
|
||||
echo "installing man$$sec/$$fn.$${sec}$(MANSUFFIX)"; \
|
||||
(cd `$(PERL) util/dirname.pl $$i`; \
|
||||
sh -c "$$pod2man \
|
||||
--section=$$sec --center=OpenSSL \
|
||||
--release=$(VERSION) `basename $$i`") \
|
||||
> $(INSTALL_PREFIX)$(MANDIR)/man$$sec/$$fn.$${sec}$(MANSUFFIX); \
|
||||
$(PERL) util/extract-names.pl < $$i | \
|
||||
(grep -v $$filecase "^$$fn\$$"; true) | \
|
||||
(grep -v "[ ]"; true) | \
|
||||
(cd $(INSTALL_PREFIX)$(MANDIR)/man$$sec/; \
|
||||
while read n; do \
|
||||
PLATFORM=$(PLATFORM) $$here/util/point.sh $$fn.$${sec}$(MANSUFFIX) "$$n".$${sec}$(MANSUFFIX); \
|
||||
done); \
|
||||
done
|
||||
|
||||
# DO NOT DELETE THIS LINE -- make depend depends on it.
|
@ -1,655 +0,0 @@
|
||||
#
|
||||
# Helper makefile to link shared libraries in a portable way.
|
||||
# This is much simpler than libtool, and hopefully not too error-prone.
|
||||
#
|
||||
# The following variables need to be set on the command line to build
|
||||
# properly
|
||||
|
||||
# CC contains the current compiler. This one MUST be defined
|
||||
CC=cc
|
||||
CFLAGS=$(CFLAG)
|
||||
# LDFLAGS contains flags to be used when temporary object files (when building
|
||||
# shared libraries) are created, or when an application is linked.
|
||||
# SHARED_LDFLAGS contains flags to be used when the shared library is created.
|
||||
LDFLAGS=
|
||||
SHARED_LDFLAGS=
|
||||
|
||||
NM=nm
|
||||
|
||||
# LIBNAME contains just the name of the library, without prefix ("lib"
|
||||
# on Unix, "cyg" for certain forms under Cygwin...) or suffix (.a, .so,
|
||||
# .dll, ...). This one MUST have a value when using this makefile to
|
||||
# build shared libraries.
|
||||
# For example, to build libfoo.so, you need to do the following:
|
||||
#LIBNAME=foo
|
||||
LIBNAME=
|
||||
|
||||
# APPNAME contains just the name of the application, without suffix (""
|
||||
# on Unix, ".exe" on Windows, ...). This one MUST have a value when using
|
||||
# this makefile to build applications.
|
||||
# For example, to build foo, you need to do the following:
|
||||
#APPNAME=foo
|
||||
APPNAME=
|
||||
|
||||
# OBJECTS contains all the object files to link together into the application.
|
||||
# This must contain at least one object file.
|
||||
#OBJECTS=foo.o
|
||||
OBJECTS=
|
||||
|
||||
# LIBEXTRAS contains extra modules to link together with the library.
|
||||
# For example, if a second library, say libbar.a needs to be linked into
|
||||
# libfoo.so, you need to do the following:
|
||||
#LIBEXTRAS=libbar.a
|
||||
# Note that this MUST be used when using the link_o targets, to hold the
|
||||
# names of all object files that go into the target library.
|
||||
LIBEXTRAS=
|
||||
|
||||
# LIBVERSION contains the current version of the library.
|
||||
# For example, to build libfoo.so.1.2, you need to do the following:
|
||||
#LIBVERSION=1.2
|
||||
LIBVERSION=
|
||||
|
||||
# LIBCOMPATVERSIONS contains the compatibility versions (a list) of
|
||||
# the library. They MUST be in decreasing order.
|
||||
# For example, if libfoo.so.1.2.1 is backward compatible with libfoo.so.1.2
|
||||
# and libfoo.so.1, you need to do the following:
|
||||
#LIBCOMPATVERSIONS=1.2 1
|
||||
# Note that on systems that use sonames, the last number will appear as
|
||||
# part of it.
|
||||
# It's also possible, for systems that support it (Tru64, for example),
|
||||
# to add extra compatibility info with more precision, by adding a second
|
||||
# list of versions, separated from the first with a semicolon, like this:
|
||||
#LIBCOMPATVERSIONS=1.2 1;1.2.0 1.1.2 1.1.1 1.1.0 1.0.0
|
||||
LIBCOMPATVERSIONS=
|
||||
|
||||
# LIBDEPS contains all the flags necessary to cover all necessary
|
||||
# dependencies to other libraries.
|
||||
LIBDEPS=
|
||||
|
||||
#------------------------------------------------------------------------------
|
||||
# The rest is private to this makefile.
|
||||
|
||||
SET_X=:
|
||||
#SET_X=set -x
|
||||
|
||||
top:
|
||||
echo "Trying to use this makefile interactively? Don't."
|
||||
|
||||
CALC_VERSIONS= \
|
||||
SHLIB_COMPAT=; SHLIB_SOVER=; \
|
||||
if [ -n "$(LIBVERSION)$(LIBCOMPATVERSIONS)" ]; then \
|
||||
prev=""; \
|
||||
for v in `echo "$(LIBVERSION) $(LIBCOMPATVERSIONS)" | cut -d';' -f1`; do \
|
||||
SHLIB_SOVER_NODOT=$$v; \
|
||||
SHLIB_SOVER=.$$v; \
|
||||
if [ -n "$$prev" ]; then \
|
||||
SHLIB_COMPAT="$$SHLIB_COMPAT .$$prev"; \
|
||||
fi; \
|
||||
prev=$$v; \
|
||||
done; \
|
||||
fi
|
||||
|
||||
LINK_APP= \
|
||||
( $(SET_X); \
|
||||
LIBDEPS="$${LIBDEPS:-$(LIBDEPS)}"; \
|
||||
LDCMD="$${LDCMD:-$(CC)}"; LDFLAGS="$${LDFLAGS:-$(CFLAGS)}"; \
|
||||
LIBPATH=`for x in $$LIBDEPS; do echo $$x; done | sed -e 's/^ *-L//;t' -e d | uniq`; \
|
||||
LIBPATH=`echo $$LIBPATH | sed -e 's/ /:/g'`; \
|
||||
LD_LIBRARY_PATH=$$LIBPATH:$$LD_LIBRARY_PATH \
|
||||
$${LDCMD} $${LDFLAGS} -o $${APPNAME:=$(APPNAME)} $(OBJECTS) $${LIBDEPS} )
|
||||
|
||||
LINK_SO= \
|
||||
( $(SET_X); \
|
||||
LIBDEPS="$${LIBDEPS:-$(LIBDEPS)}"; \
|
||||
SHAREDCMD="$${SHAREDCMD:-$(CC)}"; \
|
||||
SHAREDFLAGS="$${SHAREDFLAGS:-$(CFLAGS) $(SHARED_LDFLAGS)}"; \
|
||||
LIBPATH=`for x in $$LIBDEPS; do echo $$x; done | sed -e 's/^ *-L//;t' -e d | uniq`; \
|
||||
LIBPATH=`echo $$LIBPATH | sed -e 's/ /:/g'`; \
|
||||
LD_LIBRARY_PATH=$$LIBPATH:$$LD_LIBRARY_PATH \
|
||||
$${SHAREDCMD} $${SHAREDFLAGS} \
|
||||
-o $$SHLIB$$SHLIB_SOVER$$SHLIB_SUFFIX \
|
||||
$$ALLSYMSFLAGS $$SHOBJECTS $$NOALLSYMSFLAGS $$LIBDEPS \
|
||||
) && $(SYMLINK_SO)
|
||||
|
||||
SYMLINK_SO= \
|
||||
if [ -n "$$INHIBIT_SYMLINKS" ]; then :; else \
|
||||
prev=$$SHLIB$$SHLIB_SOVER$$SHLIB_SUFFIX; \
|
||||
if [ -n "$$SHLIB_COMPAT" ]; then \
|
||||
for x in $$SHLIB_COMPAT; do \
|
||||
( $(SET_X); rm -f $$SHLIB$$x$$SHLIB_SUFFIX; \
|
||||
ln -s $$prev $$SHLIB$$x$$SHLIB_SUFFIX ); \
|
||||
prev=$$SHLIB$$x$$SHLIB_SUFFIX; \
|
||||
done; \
|
||||
fi; \
|
||||
if [ -n "$$SHLIB_SOVER" ]; then \
|
||||
( $(SET_X); rm -f $$SHLIB$$SHLIB_SUFFIX; \
|
||||
ln -s $$prev $$SHLIB$$SHLIB_SUFFIX ); \
|
||||
fi; \
|
||||
fi
|
||||
|
||||
LINK_SO_A= SHOBJECTS="lib$(LIBNAME).a $(LIBEXTRAS)"; $(LINK_SO)
|
||||
LINK_SO_O= SHOBJECTS="$(LIBEXTRAS)"; $(LINK_SO)
|
||||
|
||||
LINK_SO_A_VIA_O= \
|
||||
SHOBJECTS=lib$(LIBNAME).o; \
|
||||
ALL=$$ALLSYMSFLAGS; ALLSYMSFLAGS=; NOALLSYMSFLAGS=; \
|
||||
( $(SET_X); \
|
||||
ld $(LDFLAGS) -r -o lib$(LIBNAME).o $$ALL lib$(LIBNAME).a $(LIBEXTRAS) ); \
|
||||
$(LINK_SO) && rm -f lib$(LIBNAME).o
|
||||
|
||||
LINK_SO_A_UNPACKED= \
|
||||
UNPACKDIR=link_tmp.$$$$; rm -rf $$UNPACKDIR; mkdir $$UNPACKDIR; \
|
||||
(cd $$UNPACKDIR; ar x ../lib$(LIBNAME).a) && \
|
||||
([ -z "$(LIBEXTRAS)" ] || cp $(LIBEXTRAS) $$UNPACKDIR) && \
|
||||
SHOBJECTS=$$UNPACKDIR/*.o; \
|
||||
$(LINK_SO) && rm -rf $$UNPACKDIR
|
||||
|
||||
DETECT_GNU_LD=($(CC) -Wl,-V /dev/null 2>&1 | grep '^GNU ld' )>/dev/null
|
||||
|
||||
DO_GNU_SO=$(CALC_VERSIONS); \
|
||||
SHLIB=lib$(LIBNAME).so; \
|
||||
SHLIB_SUFFIX=; \
|
||||
ALLSYMSFLAGS='-Wl,--whole-archive'; \
|
||||
NOALLSYMSFLAGS='-Wl,--no-whole-archive'; \
|
||||
SHAREDFLAGS="$(CFLAGS) $(SHARED_LDFLAGS) -shared -Wl,-Bsymbolic -Wl,-soname=$$SHLIB$$SHLIB_SOVER$$SHLIB_SUFFIX"
|
||||
|
||||
DO_GNU_APP=LDFLAGS="$(CFLAGS) -Wl,-rpath,$(LIBRPATH)"
|
||||
|
||||
#This is rather special. It's a special target with which one can link
|
||||
#applications without bothering with any features that have anything to
|
||||
#do with shared libraries, for example when linking against static
|
||||
#libraries. It's mostly here to avoid a lot of conditionals everywhere
|
||||
#else...
|
||||
link_app.:
|
||||
$(LINK_APP)
|
||||
|
||||
link_o.gnu:
|
||||
@ $(DO_GNU_SO); $(LINK_SO_O)
|
||||
link_a.gnu:
|
||||
@ $(DO_GNU_SO); $(LINK_SO_A)
|
||||
link_app.gnu:
|
||||
@ $(DO_GNU_APP); $(LINK_APP)
|
||||
|
||||
DO_BEOS_SO= SHLIB=lib$(LIBNAME).so; \
|
||||
SHLIB_SUFFIX=; \
|
||||
ALLSYMSFLAGS='-Wl,--whole-archive'; \
|
||||
NOALLSYMSFLAGS='-Wl,--no-whole-archive'; \
|
||||
SHAREDFLAGS="$(CFLAGS) $(SHARED_LDFLAGS) -shared -Wl,-Bsymbolic -Wl,-soname=$$SHLIB$$SHLIB_SUFFIX"
|
||||
|
||||
link_o.beos:
|
||||
@ $(DO_BEOS_SO); $(LINK_SO_O)
|
||||
link_a.beos:
|
||||
@ $(DO_BEOS_SO); $(LINK_SO_A)
|
||||
|
||||
link_o.bsd:
|
||||
@if $(DETECT_GNU_LD); then $(DO_GNU_SO); else \
|
||||
$(CALC_VERSIONS); \
|
||||
SHLIB=lib$(LIBNAME).so; \
|
||||
SHLIB_SUFFIX=; \
|
||||
LIBDEPS=" "; \
|
||||
ALLSYMSFLAGS="-Wl,-Bforcearchive"; \
|
||||
NOALLSYMSFLAGS=; \
|
||||
SHAREDFLAGS="$(CFLAGS) $(SHARED_LDFLAGS) -shared -nostdlib"; \
|
||||
fi; $(LINK_SO_O)
|
||||
link_a.bsd:
|
||||
@if $(DETECT_GNU_LD); then $(DO_GNU_SO); else \
|
||||
$(CALC_VERSIONS); \
|
||||
SHLIB=lib$(LIBNAME).so; \
|
||||
SHLIB_SUFFIX=; \
|
||||
LIBDEPS=" "; \
|
||||
ALLSYMSFLAGS="-Wl,-Bforcearchive"; \
|
||||
NOALLSYMSFLAGS=; \
|
||||
SHAREDFLAGS="$(CFLAGS) $(SHARED_LDFLAGS) -shared -nostdlib"; \
|
||||
fi; $(LINK_SO_A)
|
||||
link_app.bsd:
|
||||
@if $(DETECT_GNU_LD); then $(DO_GNU_APP); else \
|
||||
LDFLAGS="$(CFLAGS) -Wl,-rpath,$(LIBPATH)"; \
|
||||
fi; $(LINK_APP)
|
||||
|
||||
# For Darwin AKA Mac OS/X (dyld)
|
||||
# Originally link_o.darwin produced .so, because it was hard-coded
|
||||
# in dso_dlfcn module. At later point dso_dlfcn switched to .dylib
|
||||
# extension in order to allow for run-time linking with vendor-
|
||||
# supplied shared libraries such as libz, so that link_o.darwin had
|
||||
# to be harmonized with it. This caused minor controversy, because
|
||||
# it was believed that dlopen can't be used to dynamically load
|
||||
# .dylib-s, only so called bundle modules (ones linked with -bundle
|
||||
# flag). The belief seems to be originating from pre-10.4 release,
|
||||
# where dlfcn functionality was emulated by dlcompat add-on. In
|
||||
# 10.4 dlopen was rewritten as native part of dyld and is documented
|
||||
# to be capable of loading both dynamic libraries and bundles. In
|
||||
# order to provide compatibility with pre-10.4 dlopen, modules are
|
||||
# linked with -bundle flag, which makes .dylib extension misleading.
|
||||
# It works, because dlopen is [and always was] extension-agnostic.
|
||||
# Alternative to this heuristic approach is to develop specific
|
||||
# MacOS X dso module relying on whichever "native" dyld interface.
|
||||
link_o.darwin:
|
||||
@ $(CALC_VERSIONS); \
|
||||
SHLIB=lib$(LIBNAME); \
|
||||
SHLIB_SUFFIX=.dylib; \
|
||||
ALLSYMSFLAGS='-all_load'; \
|
||||
NOALLSYMSFLAGS=''; \
|
||||
SHAREDFLAGS="$(CFLAGS) `echo $(SHARED_LDFLAGS) | sed s/dynamiclib/bundle/`"; \
|
||||
if [ -n "$(LIBVERSION)" ]; then \
|
||||
SHAREDFLAGS="$$SHAREDFLAGS -current_version $(LIBVERSION)"; \
|
||||
fi; \
|
||||
if [ -n "$$SHLIB_SOVER_NODOT" ]; then \
|
||||
SHAREDFLAGS="$$SHAREDFLAGS -compatibility_version $$SHLIB_SOVER_NODOT"; \
|
||||
fi; \
|
||||
$(LINK_SO_O)
|
||||
link_a.darwin:
|
||||
@ $(CALC_VERSIONS); \
|
||||
SHLIB=lib$(LIBNAME); \
|
||||
SHLIB_SUFFIX=.dylib; \
|
||||
ALLSYMSFLAGS='-all_load'; \
|
||||
NOALLSYMSFLAGS=''; \
|
||||
SHAREDFLAGS="$(CFLAGS) $(SHARED_LDFLAGS)"; \
|
||||
if [ -n "$(LIBVERSION)" ]; then \
|
||||
SHAREDFLAGS="$$SHAREDFLAGS -current_version $(LIBVERSION)"; \
|
||||
fi; \
|
||||
if [ -n "$$SHLIB_SOVER_NODOT" ]; then \
|
||||
SHAREDFLAGS="$$SHAREDFLAGS -compatibility_version $$SHLIB_SOVER_NODOT"; \
|
||||
fi; \
|
||||
SHAREDFLAGS="$$SHAREDFLAGS -install_name $(INSTALLTOP)/$(LIBDIR)/$$SHLIB$(SHLIB_EXT)"; \
|
||||
$(LINK_SO_A)
|
||||
link_app.darwin: # is there run-path on darwin?
|
||||
$(LINK_APP)
|
||||
|
||||
link_o.cygwin:
|
||||
@ $(CALC_VERSIONS); \
|
||||
INHIBIT_SYMLINKS=yes; \
|
||||
SHLIB=cyg$(LIBNAME); \
|
||||
base=-Wl,--enable-auto-image-base; \
|
||||
deffile=; \
|
||||
if expr $(PLATFORM) : 'mingw' > /dev/null; then \
|
||||
SHLIB=$(LIBNAME)eay32; base=; \
|
||||
if test -f $(LIBNAME)eay32.def; then \
|
||||
deffile=$(LIBNAME)eay32.def; \
|
||||
fi; \
|
||||
fi; \
|
||||
SHLIB_SUFFIX=.dll; \
|
||||
LIBVERSION="$(LIBVERSION)"; \
|
||||
SHLIB_SOVER=${LIBVERSION:+"-$(LIBVERSION)"}; \
|
||||
ALLSYMSFLAGS='-Wl,--whole-archive'; \
|
||||
NOALLSYMSFLAGS='-Wl,--no-whole-archive'; \
|
||||
SHAREDFLAGS="$(CFLAGS) $(SHARED_LDFLAGS) -shared $$base $$deffile -Wl,-Bsymbolic"; \
|
||||
$(LINK_SO_O)
|
||||
#for mingw target if def-file is in use dll-name should match library-name
|
||||
link_a.cygwin:
|
||||
@ $(CALC_VERSIONS); \
|
||||
INHIBIT_SYMLINKS=yes; \
|
||||
SHLIB=cyg$(LIBNAME); SHLIB_SOVER=-$(LIBVERSION); SHLIB_SUFFIX=.dll; \
|
||||
dll_name=$$SHLIB$$SHLIB_SOVER$$SHLIB_SUFFIX; extras=; \
|
||||
base=-Wl,--enable-auto-image-base; \
|
||||
if expr $(PLATFORM) : 'mingw' > /dev/null; then \
|
||||
case $(LIBNAME) in \
|
||||
crypto) SHLIB=libeay;; \
|
||||
ssl) SHLIB=ssleay;; \
|
||||
esac; \
|
||||
SHLIB_SOVER=32; \
|
||||
extras="$(LIBNAME).def"; \
|
||||
$(PERL) util/mkdef.pl 32 $$SHLIB > $$extras; \
|
||||
base=; [ $(LIBNAME) = "crypto" -a -n "$(FIPSCANLIB)" ] && base=-Wl,--image-base,0x63000000; \
|
||||
fi; \
|
||||
dll_name=$$SHLIB$$SHLIB_SOVER$$SHLIB_SUFFIX; \
|
||||
$(PERL) util/mkrc.pl $$dll_name | \
|
||||
$(RC) -o rc.o; \
|
||||
extras="$$extras rc.o"; \
|
||||
ALLSYMSFLAGS='-Wl,--whole-archive'; \
|
||||
NOALLSYMSFLAGS='-Wl,--no-whole-archive'; \
|
||||
SHAREDFLAGS="$(CFLAGS) $(SHARED_LDFLAGS) -shared $$base -Wl,-Bsymbolic -Wl,--out-implib,lib$(LIBNAME).dll.a $$extras"; \
|
||||
[ -f apps/$$dll_name ] && rm apps/$$dll_name; \
|
||||
[ -f test/$$dll_name ] && rm test/$$dll_name; \
|
||||
$(LINK_SO_A) || exit 1; \
|
||||
rm $$extras; \
|
||||
cp -p $$dll_name apps/; \
|
||||
cp -p $$dll_name test/
|
||||
link_app.cygwin:
|
||||
@if expr "$(CFLAGS)" : '.*OPENSSL_USE_APPLINK' > /dev/null; then \
|
||||
LIBDEPS="$(TOP)/crypto/applink.o $${LIBDEPS:-$(LIBDEPS)}"; \
|
||||
export LIBDEPS; \
|
||||
fi; \
|
||||
$(LINK_APP)
|
||||
|
||||
link_o.alpha-osf1:
|
||||
@ if $(DETECT_GNU_LD); then \
|
||||
$(DO_GNU_SO); \
|
||||
else \
|
||||
SHLIB=lib$(LIBNAME).so; \
|
||||
SHLIB_SUFFIX=; \
|
||||
SHLIB_HIST=`echo "$(LIBCOMPATVERSIONS)" | cut -d';' -f2 | sed -e 's/ */:/'`; \
|
||||
if [ -n "$$SHLIB_HIST" ]; then \
|
||||
SHLIB_HIST="$${SHLIB_HIST}:$(LIBVERSION)"; \
|
||||
else \
|
||||
SHLIB_HIST="$(LIBVERSION)"; \
|
||||
fi; \
|
||||
SHLIB_SOVER=; \
|
||||
ALLSYMSFLAGS='-all'; \
|
||||
NOALLSYMSFLAGS='-none'; \
|
||||
SHAREDFLAGS="$(CFLAGS) $(SHARED_LDFLAGS) -shared -Wl,-B,symbolic"; \
|
||||
if [ -n "$$SHLIB_HIST" ]; then \
|
||||
SHAREDFLAGS="$$SHAREDFLAGS -set_version $$SHLIB_HIST"; \
|
||||
fi; \
|
||||
fi; \
|
||||
$(LINK_SO_O)
|
||||
link_a.alpha-osf1:
|
||||
@ if $(DETECT_GNU_LD); then \
|
||||
$(DO_GNU_SO); \
|
||||
else \
|
||||
SHLIB=lib$(LIBNAME).so; \
|
||||
SHLIB_SUFFIX=; \
|
||||
SHLIB_HIST=`echo "$(LIBCOMPATVERSIONS)" | cut -d';' -f2 | sed -e 's/ */:/'`; \
|
||||
if [ -n "$$SHLIB_HIST" ]; then \
|
||||
SHLIB_HIST="$${SHLIB_HIST}:$(LIBVERSION)"; \
|
||||
else \
|
||||
SHLIB_HIST="$(LIBVERSION)"; \
|
||||
fi; \
|
||||
SHLIB_SOVER=; \
|
||||
ALLSYMSFLAGS='-all'; \
|
||||
NOALLSYMSFLAGS='-none'; \
|
||||
SHAREDFLAGS="$(CFLAGS) $(SHARED_LDFLAGS) -shared -Wl,-B,symbolic"; \
|
||||
if [ -n "$$SHLIB_HIST" ]; then \
|
||||
SHAREDFLAGS="$$SHAREDFLAGS -set_version $$SHLIB_HIST"; \
|
||||
fi; \
|
||||
fi; \
|
||||
$(LINK_SO_A)
|
||||
link_app.alpha-osf1:
|
||||
@if $(DETECT_GNU_LD); then \
|
||||
$(DO_GNU_APP); \
|
||||
else \
|
||||
LDFLAGS="$(CFLAGS) -rpath $(LIBRPATH)"; \
|
||||
fi; \
|
||||
$(LINK_APP)
|
||||
|
||||
link_o.solaris:
|
||||
@ if $(DETECT_GNU_LD); then \
|
||||
$(DO_GNU_SO); \
|
||||
else \
|
||||
$(CALC_VERSIONS); \
|
||||
MINUSZ='-z '; \
|
||||
($(CC) -v 2>&1 | grep gcc) > /dev/null && MINUSZ='-Wl,-z,'; \
|
||||
SHLIB=lib$(LIBNAME).so; \
|
||||
SHLIB_SUFFIX=; \
|
||||
ALLSYMSFLAGS="$${MINUSZ}allextract"; \
|
||||
NOALLSYMSFLAGS="$${MINUSZ}defaultextract"; \
|
||||
SHAREDFLAGS="$(CFLAGS) $(SHARED_LDFLAGS) -h $$SHLIB$$SHLIB_SOVER$$SHLIB_SUFFIX -Wl,-Bsymbolic"; \
|
||||
fi; \
|
||||
$(LINK_SO_O)
|
||||
link_a.solaris:
|
||||
@ if $(DETECT_GNU_LD); then \
|
||||
$(DO_GNU_SO); \
|
||||
else \
|
||||
$(CALC_VERSIONS); \
|
||||
MINUSZ='-z '; \
|
||||
($(CC) -v 2>&1 | grep gcc) > /dev/null && MINUSZ='-Wl,-z,'; \
|
||||
SHLIB=lib$(LIBNAME).so; \
|
||||
SHLIB_SUFFIX=;\
|
||||
ALLSYMSFLAGS="$${MINUSZ}allextract"; \
|
||||
NOALLSYMSFLAGS="$${MINUSZ}defaultextract"; \
|
||||
SHAREDFLAGS="$(CFLAGS) $(SHARED_LDFLAGS) -h $$SHLIB$$SHLIB_SOVER$$SHLIB_SUFFIX -Wl,-Bsymbolic"; \
|
||||
fi; \
|
||||
$(LINK_SO_A)
|
||||
link_app.solaris:
|
||||
@ if $(DETECT_GNU_LD); then \
|
||||
$(DO_GNU_APP); \
|
||||
else \
|
||||
LDFLAGS="$(CFLAGS) -R $(LIBRPATH)"; \
|
||||
fi; \
|
||||
$(LINK_APP)
|
||||
|
||||
# OpenServer 5 native compilers used
|
||||
link_o.svr3:
|
||||
@ if $(DETECT_GNU_LD); then \
|
||||
$(DO_GNU_SO); \
|
||||
else \
|
||||
$(CALC_VERSIONS); \
|
||||
SHLIB=lib$(LIBNAME).so; \
|
||||
SHLIB_SUFFIX=; \
|
||||
ALLSYMSFLAGS=''; \
|
||||
NOALLSYMSFLAGS=''; \
|
||||
SHAREDFLAGS="$(CFLAGS) -G -h $$SHLIB$$SHLIB_SOVER$$SHLIB_SUFFIX"; \
|
||||
fi; \
|
||||
$(LINK_SO_O)
|
||||
link_a.svr3:
|
||||
@ if $(DETECT_GNU_LD); then \
|
||||
$(DO_GNU_SO); \
|
||||
else \
|
||||
$(CALC_VERSIONS); \
|
||||
SHLIB=lib$(LIBNAME).so; \
|
||||
SHLIB_SUFFIX=; \
|
||||
ALLSYMSFLAGS=''; \
|
||||
NOALLSYMSFLAGS=''; \
|
||||
SHAREDFLAGS="$(CFLAGS) -G -h $$SHLIB$$SHLIB_SOVER$$SHLIB_SUFFIX"; \
|
||||
fi; \
|
||||
$(LINK_SO_A_UNPACKED)
|
||||
link_app.svr3:
|
||||
@$(DETECT_GNU_LD) && $(DO_GNU_APP); \
|
||||
$(LINK_APP)
|
||||
|
||||
# UnixWare 7 and OpenUNIX 8 native compilers used
|
||||
link_o.svr5:
|
||||
@ if $(DETECT_GNU_LD); then \
|
||||
$(DO_GNU_SO); \
|
||||
else \
|
||||
$(CALC_VERSIONS); \
|
||||
SHARE_FLAG='-G'; \
|
||||
($(CC) -v 2>&1 | grep gcc) > /dev/null && SHARE_FLAG='-shared'; \
|
||||
SHLIB=lib$(LIBNAME).so; \
|
||||
SHLIB_SUFFIX=; \
|
||||
ALLSYMSFLAGS=''; \
|
||||
NOALLSYMSFLAGS=''; \
|
||||
SHAREDFLAGS="$(CFLAGS) $${SHARE_FLAG} -h $$SHLIB$$SHLIB_SOVER$$SHLIB_SUFFIX"; \
|
||||
fi; \
|
||||
$(LINK_SO_O)
|
||||
link_a.svr5:
|
||||
@ if $(DETECT_GNU_LD); then \
|
||||
$(DO_GNU_SO); \
|
||||
else \
|
||||
$(CALC_VERSIONS); \
|
||||
SHARE_FLAG='-G'; \
|
||||
($(CC) -v 2>&1 | grep gcc) > /dev/null && SHARE_FLAG='-shared'; \
|
||||
SHLIB=lib$(LIBNAME).so; \
|
||||
SHLIB_SUFFIX=; \
|
||||
ALLSYMSFLAGS=''; \
|
||||
NOALLSYMSFLAGS=''; \
|
||||
SHAREDFLAGS="$(CFLAGS) $${SHARE_FLAG} -h $$SHLIB$$SHLIB_SOVER$$SHLIB_SUFFIX"; \
|
||||
fi; \
|
||||
$(LINK_SO_A_UNPACKED)
|
||||
link_app.svr5:
|
||||
@$(DETECT_GNU_LD) && $(DO_GNU_APP); \
|
||||
$(LINK_APP)
|
||||
|
||||
link_o.irix:
|
||||
@ if $(DETECT_GNU_LD); then \
|
||||
$(DO_GNU_SO); \
|
||||
else \
|
||||
$(CALC_VERSIONS); \
|
||||
SHLIB=lib$(LIBNAME).so; \
|
||||
SHLIB_SUFFIX=; \
|
||||
MINUSWL=""; \
|
||||
($(CC) -v 2>&1 | grep gcc) > /dev/null && MINUSWL="-Wl,"; \
|
||||
ALLSYMSFLAGS="$${MINUSWL}-all"; \
|
||||
NOALLSYMSFLAGS="$${MINUSWL}-none"; \
|
||||
SHAREDFLAGS="$(CFLAGS) $(SHARED_LDFLAGS) -shared -Wl,-soname,$$SHLIB$$SHLIB_SOVER$$SHLIB_SUFFIX,-B,symbolic"; \
|
||||
fi; \
|
||||
$(LINK_SO_O)
|
||||
link_a.irix:
|
||||
@ if $(DETECT_GNU_LD); then \
|
||||
$(DO_GNU_SO); \
|
||||
else \
|
||||
$(CALC_VERSIONS); \
|
||||
SHLIB=lib$(LIBNAME).so; \
|
||||
SHLIB_SUFFIX=; \
|
||||
MINUSWL=""; \
|
||||
($(CC) -v 2>&1 | grep gcc) > /dev/null && MINUSWL="-Wl,"; \
|
||||
ALLSYMSFLAGS="$${MINUSWL}-all"; \
|
||||
NOALLSYMSFLAGS="$${MINUSWL}-none"; \
|
||||
SHAREDFLAGS="$(CFLAGS) $(SHARED_LDFLAGS) -shared -Wl,-soname,$$SHLIB$$SHLIB_SOVER$$SHLIB_SUFFIX,-B,symbolic"; \
|
||||
fi; \
|
||||
$(LINK_SO_A)
|
||||
link_app.irix:
|
||||
@LDFLAGS="$(CFLAGS) -Wl,-rpath,$(LIBRPATH)"; \
|
||||
$(LINK_APP)
|
||||
|
||||
# 32-bit PA-RISC HP-UX embeds the -L pathname of libs we link with, so
|
||||
# we compensate for it with +cdp ../: and +cdp ./:. Yes, these rewrite
|
||||
# rules imply that we can only link one level down in catalog structure,
|
||||
# but that's what takes place for the moment of this writing. +cdp option
|
||||
# was introduced in HP-UX 11.x and applies in 32-bit PA-RISC link
|
||||
# editor context only [it's simply ignored in other cases, which are all
|
||||
# ELFs by the way].
|
||||
#
|
||||
link_o.hpux:
|
||||
@if $(DETECT_GNU_LD); then $(DO_GNU_SO); else \
|
||||
$(CALC_VERSIONS); \
|
||||
SHLIB=lib$(LIBNAME).sl; \
|
||||
expr "$(CFLAGS)" : '.*DSO_DLFCN' > /dev/null && SHLIB=lib$(LIBNAME).so; \
|
||||
SHLIB_SUFFIX=; \
|
||||
ALLSYMSFLAGS='-Wl,-Fl'; \
|
||||
NOALLSYMSFLAGS=''; \
|
||||
expr $(PLATFORM) : 'hpux64' > /dev/null && ALLSYMSFLAGS='-Wl,+forceload'; \
|
||||
SHAREDFLAGS="$(CFLAGS) $(SHARED_LDFLAGS) -Wl,-B,symbolic,+vnocompatwarnings,-z,+s,+h,$$SHLIB$$SHLIB_SOVER$$SHLIB_SUFFIX,+cdp,../:,+cdp,./:"; \
|
||||
fi; \
|
||||
rm -f $$SHLIB$$SHLIB_SOVER$$SHLIB_SUFFIX || :; \
|
||||
$(LINK_SO_O) && chmod a=rx $$SHLIB$$SHLIB_SOVER$$SHLIB_SUFFIX
|
||||
link_a.hpux:
|
||||
@if $(DETECT_GNU_LD); then $(DO_GNU_SO); else \
|
||||
$(CALC_VERSIONS); \
|
||||
SHLIB=lib$(LIBNAME).sl; \
|
||||
expr $(PLATFORM) : '.*ia64' > /dev/null && SHLIB=lib$(LIBNAME).so; \
|
||||
SHLIB_SUFFIX=; \
|
||||
ALLSYMSFLAGS='-Wl,-Fl'; \
|
||||
NOALLSYMSFLAGS=''; \
|
||||
expr $(PLATFORM) : 'hpux64' > /dev/null && ALLSYMSFLAGS='-Wl,+forceload'; \
|
||||
SHAREDFLAGS="$(CFLAGS) $(SHARED_LDFLAGS) -Wl,-B,symbolic,+vnocompatwarnings,-z,+s,+h,$$SHLIB$$SHLIB_SOVER$$SHLIB_SUFFIX,+cdp,../:,+cdp,./:"; \
|
||||
fi; \
|
||||
rm -f $$SHLIB$$SHLIB_SOVER$$SHLIB_SUFFIX || :; \
|
||||
$(LINK_SO_A) && chmod a=rx $$SHLIB$$SHLIB_SOVER$$SHLIB_SUFFIX
|
||||
link_app.hpux:
|
||||
@if $(DETECT_GNU_LD); then $(DO_GNU_APP); else \
|
||||
LDFLAGS="$(CFLAGS) -Wl,+s,+cdp,../:,+cdp,./:,+b,$(LIBRPATH)"; \
|
||||
fi; \
|
||||
$(LINK_APP)
|
||||
|
||||
link_o.aix:
|
||||
@ $(CALC_VERSIONS); \
|
||||
OBJECT_MODE=`expr "x$(SHARED_LDFLAGS)" : 'x\-[a-z]*\(64\)'` || :; \
|
||||
OBJECT_MODE=$${OBJECT_MODE:-32}; export OBJECT_MODE; \
|
||||
SHLIB=lib$(LIBNAME).so; \
|
||||
SHLIB_SUFFIX=; \
|
||||
ALLSYMSFLAGS=''; \
|
||||
NOALLSYMSFLAGS=''; \
|
||||
SHAREDFLAGS='$(CFLAGS) $(SHARED_LDFLAGS) -Wl,-bexpall,-bnolibpath,-bM:SRE'; \
|
||||
$(LINK_SO_O);
|
||||
link_a.aix:
|
||||
@ $(CALC_VERSIONS); \
|
||||
OBJECT_MODE=`expr "x$(SHARED_LDFLAGS)" : 'x\-[a-z]*\(64\)'` || : ; \
|
||||
OBJECT_MODE=$${OBJECT_MODE:-32}; export OBJECT_MODE; \
|
||||
SHLIB=lib$(LIBNAME).so; \
|
||||
SHLIB_SUFFIX=; \
|
||||
ALLSYMSFLAGS='-bnogc'; \
|
||||
NOALLSYMSFLAGS=''; \
|
||||
SHAREDFLAGS='$(CFLAGS) $(SHARED_LDFLAGS) -Wl,-bexpall,-bnolibpath,-bM:SRE'; \
|
||||
$(LINK_SO_A_VIA_O)
|
||||
link_app.aix:
|
||||
LDFLAGS="$(CFLAGS) -Wl,-brtl,-blibpath:$(LIBRPATH):$${LIBPATH:-/usr/lib:/lib}"; \
|
||||
$(LINK_APP)
|
||||
|
||||
link_o.reliantunix:
|
||||
@ $(CALC_VERSIONS); \
|
||||
SHLIB=lib$(LIBNAME).so; \
|
||||
SHLIB_SUFFIX=; \
|
||||
ALLSYMSFLAGS=; \
|
||||
NOALLSYMSFLAGS=''; \
|
||||
SHAREDFLAGS='$(CFLAGS) -G'; \
|
||||
$(LINK_SO_O)
|
||||
link_a.reliantunix:
|
||||
@ $(CALC_VERSIONS); \
|
||||
SHLIB=lib$(LIBNAME).so; \
|
||||
SHLIB_SUFFIX=; \
|
||||
ALLSYMSFLAGS=; \
|
||||
NOALLSYMSFLAGS=''; \
|
||||
SHAREDFLAGS='$(CFLAGS) -G'; \
|
||||
$(LINK_SO_A_UNPACKED)
|
||||
link_app.reliantunix:
|
||||
$(LINK_APP)
|
||||
|
||||
# Targets to build symbolic links when needed
|
||||
symlink.gnu symlink.solaris symlink.svr3 symlink.svr5 symlink.irix \
|
||||
symlink.aix symlink.reliantunix:
|
||||
@ $(CALC_VERSIONS); \
|
||||
SHLIB=lib$(LIBNAME).so; \
|
||||
$(SYMLINK_SO)
|
||||
symlink.darwin:
|
||||
@ $(CALC_VERSIONS); \
|
||||
SHLIB=lib$(LIBNAME); \
|
||||
SHLIB_SUFFIX=.dylib; \
|
||||
$(SYMLINK_SO)
|
||||
symlink.hpux:
|
||||
@ $(CALC_VERSIONS); \
|
||||
SHLIB=lib$(LIBNAME).sl; \
|
||||
expr $(PLATFORM) : '.*ia64' > /dev/null && SHLIB=lib$(LIBNAME).so; \
|
||||
$(SYMLINK_SO)
|
||||
# The following lines means those specific architectures do no symlinks
|
||||
symlink.cygwin symlink.alpha-osf1 symlink.tru64 symlink.tru64-rpath symlink.beos:
|
||||
|
||||
# Compatibility targets
|
||||
link_o.bsd-gcc-shared link_o.linux-shared link_o.gnu-shared: link_o.gnu
|
||||
link_a.bsd-gcc-shared link_a.linux-shared link_a.gnu-shared: link_a.gnu
|
||||
link_app.bsd-gcc-shared link_app.linux-shared link_app.gnu-shared: link_app.gnu
|
||||
symlink.bsd-gcc-shared symlink.bsd-shared symlink.linux-shared symlink.gnu-shared: symlink.gnu
|
||||
link_o.bsd-shared: link_o.bsd
|
||||
link_a.bsd-shared: link_a.bsd
|
||||
link_app.bsd-shared: link_app.bsd
|
||||
link_o.darwin-shared: link_o.darwin
|
||||
link_a.darwin-shared: link_a.darwin
|
||||
link_app.darwin-shared: link_app.darwin
|
||||
symlink.darwin-shared: symlink.darwin
|
||||
link_o.cygwin-shared: link_o.cygwin
|
||||
link_a.cygwin-shared: link_a.cygwin
|
||||
link_app.cygwin-shared: link_app.cygwin
|
||||
symlink.cygwin-shared: symlink.cygwin
|
||||
link_o.alpha-osf1-shared: link_o.alpha-osf1
|
||||
link_a.alpha-osf1-shared: link_a.alpha-osf1
|
||||
link_app.alpha-osf1-shared: link_app.alpha-osf1
|
||||
symlink.alpha-osf1-shared: symlink.alpha-osf1
|
||||
link_o.tru64-shared: link_o.tru64
|
||||
link_a.tru64-shared: link_a.tru64
|
||||
link_app.tru64-shared: link_app.tru64
|
||||
symlink.tru64-shared: symlink.tru64
|
||||
link_o.tru64-shared-rpath: link_o.tru64-rpath
|
||||
link_a.tru64-shared-rpath: link_a.tru64-rpath
|
||||
link_app.tru64-shared-rpath: link_app.tru64-rpath
|
||||
symlink.tru64-shared-rpath: symlink.tru64-rpath
|
||||
link_o.solaris-shared: link_o.solaris
|
||||
link_a.solaris-shared: link_a.solaris
|
||||
link_app.solaris-shared: link_app.solaris
|
||||
symlink.solaris-shared: symlink.solaris
|
||||
link_o.svr3-shared: link_o.svr3
|
||||
link_a.svr3-shared: link_a.svr3
|
||||
link_app.svr3-shared: link_app.svr3
|
||||
symlink.svr3-shared: symlink.svr3
|
||||
link_o.svr5-shared: link_o.svr5
|
||||
link_a.svr5-shared: link_a.svr5
|
||||
link_app.svr5-shared: link_app.svr5
|
||||
symlink.svr5-shared: symlink.svr5
|
||||
link_o.irix-shared: link_o.irix
|
||||
link_a.irix-shared: link_a.irix
|
||||
link_app.irix-shared: link_app.irix
|
||||
symlink.irix-shared: symlink.irix
|
||||
link_o.hpux-shared: link_o.hpux
|
||||
link_a.hpux-shared: link_a.hpux
|
||||
link_app.hpux-shared: link_app.hpux
|
||||
symlink.hpux-shared: symlink.hpux
|
||||
link_o.aix-shared: link_o.aix
|
||||
link_a.aix-shared: link_a.aix
|
||||
link_app.aix-shared: link_app.aix
|
||||
symlink.aix-shared: symlink.aix
|
||||
link_o.reliantunix-shared: link_o.reliantunix
|
||||
link_a.reliantunix-shared: link_a.reliantunix
|
||||
link_app.reliantunix-shared: link_app.reliantunix
|
||||
symlink.reliantunix-shared: symlink.reliantunix
|
||||
link_o.beos-shared: link_o.beos
|
||||
link_a.beos-shared: link_a.beos
|
||||
link_app.beos-shared: link_app.gnu
|
||||
symlink.beos-shared: symlink.beos
|
@ -5,53 +5,151 @@
|
||||
This file gives a brief overview of the major changes between each OpenSSL
|
||||
release. For more details please read the CHANGES file.
|
||||
|
||||
Major changes between OpenSSL 1.0.2o and OpenSSL 1.0.2p [14 Aug 2018]
|
||||
Major changes between OpenSSL 1.1.0i and OpenSSL 1.1.1 [11 Sep 2018]
|
||||
|
||||
o Support for TLSv1.3 added (see https://wiki.openssl.org/index.php/TLS1.3
|
||||
for further important information). The TLSv1.3 implementation includes:
|
||||
o Fully compliant implementation of RFC8446 (TLSv1.3) on by default
|
||||
o Early data (0-RTT)
|
||||
o Post-handshake authentication and key update
|
||||
o Middlebox Compatibility Mode
|
||||
o TLSv1.3 PSKs
|
||||
o Support for all five RFC8446 ciphersuites
|
||||
o RSA-PSS signature algorithms (backported to TLSv1.2)
|
||||
o Configurable session ticket support
|
||||
o Stateless server support
|
||||
o Rewrite of the packet construction code for "safer" packet handling
|
||||
o Rewrite of the extension handling code
|
||||
o Complete rewrite of the OpenSSL random number generator to introduce the
|
||||
following capabilities
|
||||
o The default RAND method now utilizes an AES-CTR DRBG according to
|
||||
NIST standard SP 800-90Ar1.
|
||||
o Support for multiple DRBG instances with seed chaining.
|
||||
o There is a public and private DRBG instance.
|
||||
o The DRBG instances are fork-safe.
|
||||
o Keep all global DRBG instances on the secure heap if it is enabled.
|
||||
o The public and private DRBG instance are per thread for lock free
|
||||
operation
|
||||
o Support for various new cryptographic algorithms including:
|
||||
o SHA3
|
||||
o SHA512/224 and SHA512/256
|
||||
o EdDSA (both Ed25519 and Ed448) including X509 and TLS support
|
||||
o X448 (adding to the existing X25519 support in 1.1.0)
|
||||
o Multi-prime RSA
|
||||
o SM2
|
||||
o SM3
|
||||
o SM4
|
||||
o SipHash
|
||||
o ARIA (including TLS support)
|
||||
o Significant Side-Channel attack security improvements
|
||||
o Add a new ClientHello callback to provide the ability to adjust the SSL
|
||||
object at an early stage.
|
||||
o Add 'Maximum Fragment Length' TLS extension negotiation and support
|
||||
o A new STORE module, which implements a uniform and URI based reader of
|
||||
stores that can contain keys, certificates, CRLs and numerous other
|
||||
objects.
|
||||
o Move the display of configuration data to configdata.pm.
|
||||
o Allow GNU style "make variables" to be used with Configure.
|
||||
o Claim the namespaces OSSL and OPENSSL, represented as symbol prefixes
|
||||
o Rewrite of devcrypto engine
|
||||
|
||||
Major changes between OpenSSL 1.1.0h and OpenSSL 1.1.0i [under development]
|
||||
|
||||
o Client DoS due to large DH parameter (CVE-2018-0732)
|
||||
o Cache timing vulnerability in RSA Key Generation (CVE-2018-0737)
|
||||
|
||||
Major changes between OpenSSL 1.0.2n and OpenSSL 1.0.2o [27 Mar 2018]
|
||||
Major changes between OpenSSL 1.1.0g and OpenSSL 1.1.0h [under development]
|
||||
|
||||
o Constructed ASN.1 types with a recursive definition could exceed the
|
||||
stack (CVE-2018-0739)
|
||||
|
||||
Major changes between OpenSSL 1.0.2m and OpenSSL 1.0.2n [7 Dec 2017]
|
||||
|
||||
o Read/write after SSL object in error state (CVE-2017-3737)
|
||||
o Incorrect CRYPTO_memcmp on HP-UX PA-RISC (CVE-2018-0733)
|
||||
o rsaz_1024_mul_avx2 overflow bug on x86_64 (CVE-2017-3738)
|
||||
|
||||
Major changes between OpenSSL 1.0.2l and OpenSSL 1.0.2m [2 Nov 2017]
|
||||
Major changes between OpenSSL 1.1.0f and OpenSSL 1.1.0g [2 Nov 2017]
|
||||
|
||||
o bn_sqrx8x_internal carry bug on x86_64 (CVE-2017-3736)
|
||||
o Malformed X.509 IPAddressFamily could cause OOB read (CVE-2017-3735)
|
||||
|
||||
Major changes between OpenSSL 1.0.2k and OpenSSL 1.0.2l [25 May 2017]
|
||||
Major changes between OpenSSL 1.1.0e and OpenSSL 1.1.0f [25 May 2017]
|
||||
|
||||
o config now recognises 64-bit mingw and chooses mingw64 instead of mingw
|
||||
|
||||
Major changes between OpenSSL 1.0.2j and OpenSSL 1.0.2k [26 Jan 2017]
|
||||
Major changes between OpenSSL 1.1.0d and OpenSSL 1.1.0e [16 Feb 2017]
|
||||
|
||||
o Encrypt-Then-Mac renegotiation crash (CVE-2017-3733)
|
||||
|
||||
Major changes between OpenSSL 1.1.0c and OpenSSL 1.1.0d [26 Jan 2017]
|
||||
|
||||
o Truncated packet could crash via OOB read (CVE-2017-3731)
|
||||
o Bad (EC)DHE parameters cause a client crash (CVE-2017-3730)
|
||||
o BN_mod_exp may produce incorrect results on x86_64 (CVE-2017-3732)
|
||||
|
||||
Major changes between OpenSSL 1.1.0b and OpenSSL 1.1.0c [10 Nov 2016]
|
||||
|
||||
o ChaCha20/Poly1305 heap-buffer-overflow (CVE-2016-7054)
|
||||
o CMS Null dereference (CVE-2016-7053)
|
||||
o Montgomery multiplication may produce incorrect results (CVE-2016-7055)
|
||||
|
||||
Major changes between OpenSSL 1.0.2i and OpenSSL 1.0.2j [26 Sep 2016]
|
||||
Major changes between OpenSSL 1.1.0a and OpenSSL 1.1.0b [26 Sep 2016]
|
||||
|
||||
o Missing CRL sanity check (CVE-2016-7052)
|
||||
o Fix Use After Free for large message sizes (CVE-2016-6309)
|
||||
|
||||
Major changes between OpenSSL 1.0.2h and OpenSSL 1.0.2i [22 Sep 2016]
|
||||
Major changes between OpenSSL 1.1.0 and OpenSSL 1.1.0a [22 Sep 2016]
|
||||
|
||||
o OCSP Status Request extension unbounded memory growth (CVE-2016-6304)
|
||||
o SWEET32 Mitigation (CVE-2016-2183)
|
||||
o OOB write in MDC2_Update() (CVE-2016-6303)
|
||||
o Malformed SHA512 ticket DoS (CVE-2016-6302)
|
||||
o OOB write in BN_bn2dec() (CVE-2016-2182)
|
||||
o OOB read in TS_OBJ_print_bio() (CVE-2016-2180)
|
||||
o Pointer arithmetic undefined behaviour (CVE-2016-2177)
|
||||
o Constant time flag not preserved in DSA signing (CVE-2016-2178)
|
||||
o DTLS buffered message DoS (CVE-2016-2179)
|
||||
o DTLS replay protection DoS (CVE-2016-2181)
|
||||
o Certificate message OOB reads (CVE-2016-6306)
|
||||
o SSL_peek() hang on empty record (CVE-2016-6305)
|
||||
o Excessive allocation of memory in tls_get_message_header()
|
||||
(CVE-2016-6307)
|
||||
o Excessive allocation of memory in dtls1_preprocess_fragment()
|
||||
(CVE-2016-6308)
|
||||
|
||||
Major changes between OpenSSL 1.0.2h and OpenSSL 1.1.0 [25 Aug 2016]
|
||||
|
||||
o Copyright text was shrunk to a boilerplate that points to the license
|
||||
o "shared" builds are now the default when possible
|
||||
o Added support for "pipelining"
|
||||
o Added the AFALG engine
|
||||
o New threading API implemented
|
||||
o Support for ChaCha20 and Poly1305 added to libcrypto and libssl
|
||||
o Support for extended master secret
|
||||
o CCM ciphersuites
|
||||
o Reworked test suite, now based on perl, Test::Harness and Test::More
|
||||
o *Most* libcrypto and libssl public structures were made opaque,
|
||||
including:
|
||||
BIGNUM and associated types, EC_KEY and EC_KEY_METHOD,
|
||||
DH and DH_METHOD, DSA and DSA_METHOD, RSA and RSA_METHOD,
|
||||
BIO and BIO_METHOD, EVP_MD_CTX, EVP_MD, EVP_CIPHER_CTX,
|
||||
EVP_CIPHER, EVP_PKEY and associated types, HMAC_CTX,
|
||||
X509, X509_CRL, X509_OBJECT, X509_STORE_CTX, X509_STORE,
|
||||
X509_LOOKUP, X509_LOOKUP_METHOD
|
||||
o libssl internal structures made opaque
|
||||
o SSLv2 support removed
|
||||
o Kerberos ciphersuite support removed
|
||||
o RC4 removed from DEFAULT ciphersuites in libssl
|
||||
o 40 and 56 bit cipher support removed from libssl
|
||||
o All public header files moved to include/openssl, no more symlinking
|
||||
o SSL/TLS state machine, version negotiation and record layer rewritten
|
||||
o EC revision: now operations use new EC_KEY_METHOD.
|
||||
o Support for OCB mode added to libcrypto
|
||||
o Support for asynchronous crypto operations added to libcrypto and libssl
|
||||
o Deprecated interfaces can now be disabled at build time either
|
||||
relative to the latest release via the "no-deprecated" Configure
|
||||
argument, or via the "--api=1.1.0|1.0.0|0.9.8" option.
|
||||
o Application software can be compiled with -DOPENSSL_API_COMPAT=version
|
||||
to ensure that features deprecated in that version are not exposed.
|
||||
o Support for RFC6698/RFC7671 DANE TLSA peer authentication
|
||||
o Change of Configure to use --prefix as the main installation
|
||||
directory location rather than --openssldir. The latter becomes
|
||||
the directory for certs, private key and openssl.cnf exclusively.
|
||||
o Reworked BIO networking library, with full support for IPv6.
|
||||
o New "unified" build system
|
||||
o New security levels
|
||||
o Support for scrypt algorithm
|
||||
o Support for X25519
|
||||
o Extended SSL_CONF support using configuration files
|
||||
o KDF algorithm support. Implement TLS PRF as a KDF.
|
||||
o Support for Certificate Transparency
|
||||
o HKDF support.
|
||||
|
||||
Major changes between OpenSSL 1.0.2g and OpenSSL 1.0.2h [3 May 2016]
|
||||
|
||||
@ -322,7 +420,7 @@
|
||||
o Compression memory leak fixed.
|
||||
o Compression session resumption fixed.
|
||||
o Ticket and SNI coexistence fixes.
|
||||
o Many fixes to DTLS handling.
|
||||
o Many fixes to DTLS handling.
|
||||
|
||||
Major changes between OpenSSL 0.9.8k and OpenSSL 0.9.8l [5 Nov 2009]:
|
||||
|
||||
@ -353,9 +451,9 @@
|
||||
Major changes between OpenSSL 0.9.8e and OpenSSL 0.9.8f [11 Oct 2007]:
|
||||
|
||||
o Add gcc 4.2 support.
|
||||
o Add support for AES and SSE2 assembly lanugauge optimization
|
||||
o Add support for AES and SSE2 assembly language optimization
|
||||
for VC++ build.
|
||||
o Support for RFC4507bis and server name extensions if explicitly
|
||||
o Support for RFC4507bis and server name extensions if explicitly
|
||||
selected at compile time.
|
||||
o DTLS improvements.
|
||||
o RFC4507bis support.
|
||||
@ -436,8 +534,8 @@
|
||||
o New STORE structure and library to provide an interface to all
|
||||
sorts of data repositories. Supports storage of public and
|
||||
private keys, certificates, CRLs, numbers and arbitrary blobs.
|
||||
This library is unfortunately unfinished and unused withing
|
||||
OpenSSL.
|
||||
This library is unfortunately unfinished and unused within
|
||||
OpenSSL.
|
||||
o New control functions for the error stack.
|
||||
o Changed the PKCS#7 library to support one-pass S/MIME
|
||||
processing.
|
||||
@ -448,12 +546,12 @@
|
||||
affected functions.
|
||||
o Improved platform support for PowerPC.
|
||||
o New FIPS 180-2 algorithms (SHA-224, -256, -384 and -512).
|
||||
o New X509_VERIFY_PARAM structure to support parametrisation
|
||||
o New X509_VERIFY_PARAM structure to support parameterisation
|
||||
of X.509 path validation.
|
||||
o Major overhaul of RC4 performance on Intel P4, IA-64 and
|
||||
AMD64.
|
||||
o Changed the Configure script to have some algorithms disabled
|
||||
by default. Those can be explicitely enabled with the new
|
||||
by default. Those can be explicitly enabled with the new
|
||||
argument form 'enable-xxx'.
|
||||
o Change the default digest in 'openssl' commands from MD5 to
|
||||
SHA-1.
|
||||
@ -535,7 +633,7 @@
|
||||
Major changes between OpenSSL 0.9.7a and OpenSSL 0.9.7b [10 Apr 2003]:
|
||||
|
||||
o Security: counter the Klima-Pokorny-Rosa extension of
|
||||
Bleichbacher's attack
|
||||
Bleichbacher's attack
|
||||
o Security: make RSA blinding default.
|
||||
o Configuration: Irix fixes, AIX fixes, better mingw support.
|
||||
o Support for new platforms: linux-ia64-ecc.
|
||||
@ -595,7 +693,7 @@
|
||||
o SSL/TLS: allow optional cipher choice according to server's preference.
|
||||
o SSL/TLS: allow server to explicitly set new session ids.
|
||||
o SSL/TLS: support Kerberos cipher suites (RFC2712).
|
||||
Only supports MIT Kerberos for now.
|
||||
Only supports MIT Kerberos for now.
|
||||
o SSL/TLS: allow more precise control of renegotiations and sessions.
|
||||
o SSL/TLS: add callback to retrieve SSL/TLS messages.
|
||||
o SSL/TLS: support AES cipher suites (RFC3268).
|
||||
@ -608,7 +706,7 @@
|
||||
Major changes between OpenSSL 0.9.6i and OpenSSL 0.9.6j [10 Apr 2003]:
|
||||
|
||||
o Security: counter the Klima-Pokorny-Rosa extension of
|
||||
Bleichbacher's attack
|
||||
Bleichbacher's attack
|
||||
o Security: make RSA blinding default.
|
||||
o Build: shared library support fixes.
|
||||
|
||||
@ -720,7 +818,7 @@
|
||||
|
||||
Major changes between OpenSSL 0.9.5 and OpenSSL 0.9.5a [1 Apr 2000]:
|
||||
|
||||
o Bug fixes for Win32, SuSE Linux, NeXTSTEP and FreeBSD 2.2.8
|
||||
o Bug fixes for Win32, SuSE Linux, NeXTSTEP and FreeBSD 2.2.8
|
||||
o Shared library support for HPUX and Solaris-gcc
|
||||
o Support of Linux/IA64
|
||||
o Assembler support for Mingw32
|
||||
@ -734,7 +832,7 @@
|
||||
o Automation of 'req' application
|
||||
o Fixes to make s_client, s_server work under Windows
|
||||
o Support for multiple fieldnames in SPKACs
|
||||
o New SPKAC command line utilty and associated library functions
|
||||
o New SPKAC command line utility and associated library functions
|
||||
o Options to allow passwords to be obtained from various sources
|
||||
o New public key PEM format and options to handle it
|
||||
o Many other fixes and enhancements to command line utilities
|
||||
@ -816,8 +914,7 @@
|
||||
o Added BIO proxy and filtering functionality
|
||||
o Extended Big Number (BN) library
|
||||
o Added RIPE MD160 message digest
|
||||
o Addeed support for RC2/64bit cipher
|
||||
o Added support for RC2/64bit cipher
|
||||
o Extended ASN.1 parser routines
|
||||
o Adjustations of the source tree for CVS
|
||||
o Adjustments of the source tree for CVS
|
||||
o Support for various new platforms
|
||||
|
||||
|
119
crypto/openssl/NOTES.PERL
Normal file
119
crypto/openssl/NOTES.PERL
Normal file
@ -0,0 +1,119 @@
|
||||
TOC
|
||||
===
|
||||
|
||||
- Notes on Perl
|
||||
- Notes on Perl on Windows
|
||||
- Notes on Perl modules we use
|
||||
- Notes on installing a perl module
|
||||
|
||||
Notes on Perl
|
||||
-------------
|
||||
|
||||
For our scripts, we rely quite a bit on Perl, and increasingly on
|
||||
some core Perl modules. These Perl modules are part of the Perl
|
||||
source, so if you build Perl on your own, you should be set.
|
||||
|
||||
However, if you install Perl as binary packages, the outcome might
|
||||
differ, and you may have to check that you do get the core modules
|
||||
installed properly. We do not claim to know them all, but experience
|
||||
has told us the following:
|
||||
|
||||
- on Linux distributions based on Debian, the package 'perl' will
|
||||
install the core Perl modules as well, so you will be fine.
|
||||
- on Linux distributions based on RPMs, you will need to install
|
||||
'perl-core' rather than just 'perl'.
|
||||
|
||||
You MUST have at least Perl version 5.10.0 installed. This minimum
|
||||
requirement is due to our use of regexp backslash sequence \R among
|
||||
other features that didn't exist in core Perl before that version.
|
||||
|
||||
Notes on Perl on Windows
|
||||
------------------------
|
||||
|
||||
There are a number of build targets that can be viewed as "Windows".
|
||||
Indeed, there are VC-* configs targeting VisualStudio C, as well as
|
||||
MinGW and Cygwin. The key recommendation is to use "matching" Perl,
|
||||
one that matches build environment. For example, if you will build
|
||||
on Cygwin be sure to use the Cygwin package manager to install Perl.
|
||||
For MSYS builds use the MSYS provided Perl. For VC-* builds we
|
||||
recommend ActiveState Perl, available from
|
||||
http://www.activestate.com/ActivePerl.
|
||||
|
||||
Notes on Perl on VMS
|
||||
--------------------
|
||||
|
||||
You will need to install Perl separately. One way to do so is to
|
||||
download the source from http://perl.org/, unpacking it, reading
|
||||
README.vms and follow the instructions. Another way is to download a
|
||||
.PCSI file from http://www.vmsperl.com/ and install it using the
|
||||
POLYCENTER install tool.
|
||||
|
||||
Notes on Perl modules we use
|
||||
----------------------------
|
||||
|
||||
We make increasing use of Perl modules, and do our best to limit
|
||||
ourselves to core Perl modules to keep the requirements down. There
|
||||
are just a few exceptions:
|
||||
|
||||
Test::More We require the minimum version to be 0.96, which
|
||||
appeared in Perl 5.13.4, because that version was
|
||||
the first to have all the features we're using.
|
||||
This module is required for testing only! If you
|
||||
don't plan on running the tests, you don't need to
|
||||
bother with this one.
|
||||
|
||||
Text::Template This module is not part of the core Perl modules.
|
||||
As a matter of fact, the core Perl modules do not
|
||||
include any templating module to date.
|
||||
This module is absolutely needed, configuration
|
||||
depends on it.
|
||||
|
||||
To avoid unnecessary initial hurdles, we have bundled a copy of the
|
||||
following modules in our source. They will work as fallbacks if
|
||||
these modules aren't already installed on the system.
|
||||
|
||||
Text::Template
|
||||
|
||||
Notes on installing a perl module
|
||||
---------------------------------
|
||||
|
||||
There are a number of ways to install a perl module. In all
|
||||
descriptions below, Text::Template will server as an example.
|
||||
|
||||
1. for Linux users, the easiest is to install with the use of your
|
||||
favorite package manager. Usually, all you need to do is search
|
||||
for the module name and to install the package that comes up.
|
||||
|
||||
On Debian based Linux distributions, it would go like this:
|
||||
|
||||
$ apt-cache search Text::Template
|
||||
...
|
||||
libtext-template-perl - perl module to process text templates
|
||||
$ sudo apt-get install libtext-template-perl
|
||||
|
||||
Perl modules in Debian based distributions use package names like
|
||||
the name of the module in question, with "lib" prepended and
|
||||
"-perl" appended.
|
||||
|
||||
2. Install using CPAN. This is very easy, but usually requires root
|
||||
access:
|
||||
|
||||
$ cpan -i Text::Template
|
||||
|
||||
Note that this runs all the tests that the module to be installed
|
||||
comes with. This is usually a smooth operation, but there are
|
||||
platforms where a failure is indicated even though the actual tests
|
||||
were successful. Should that happen, you can force an
|
||||
installation regardless (that should be safe since you've already
|
||||
seen the tests succeed!):
|
||||
|
||||
$ cpan -f -i Text::Template
|
||||
|
||||
Note: on VMS, you must quote any argument that contains upper case
|
||||
characters, so the lines above would be:
|
||||
|
||||
$ cpan -i "Text::Template"
|
||||
|
||||
and:
|
||||
|
||||
$ cpan -f -i "Text::Template"
|
117
crypto/openssl/NOTES.UNIX
Normal file
117
crypto/openssl/NOTES.UNIX
Normal file
@ -0,0 +1,117 @@
|
||||
|
||||
NOTES FOR UNIX LIKE PLATFORMS
|
||||
=============================
|
||||
|
||||
For Unix/POSIX runtime systems on Windows, please see NOTES.WIN.
|
||||
|
||||
|
||||
OpenSSL uses the compiler to link programs and shared libraries
|
||||
---------------------------------------------------------------
|
||||
|
||||
OpenSSL's generated Makefile uses the C compiler command line to
|
||||
link programs, shared libraries and dynamically loadable shared
|
||||
objects. Because of this, any linking option that's given to the
|
||||
configuration scripts MUST be in a form that the compiler can accept.
|
||||
This varies between systems, where some have compilers that accept
|
||||
linker flags directly, while others take them in '-Wl,' form. You need
|
||||
to read your compiler documentation to figure out what is acceptable,
|
||||
and ld(1) to figure out what linker options are available.
|
||||
|
||||
|
||||
Shared libraries and installation in non-default locations
|
||||
----------------------------------------------------------
|
||||
|
||||
Every Unix system has its own set of default locations for shared
|
||||
libraries, such as /lib, /usr/lib or possibly /usr/local/lib. If
|
||||
libraries are installed in non-default locations, dynamically linked
|
||||
binaries will not find them and therefore fail to run, unless they get
|
||||
a bit of help from a defined runtime shared library search path.
|
||||
|
||||
For OpenSSL's application (the 'openssl' command), our configuration
|
||||
scripts do NOT generally set the runtime shared library search path for
|
||||
you. It's therefore advisable to set it explicitly when configuring,
|
||||
unless the libraries are to be installed in directories that you know
|
||||
to be in the default list.
|
||||
|
||||
Runtime shared library search paths are specified with different
|
||||
linking options depending on operating system and versions thereof, and
|
||||
are talked about differently in their respective documentation;
|
||||
variations of RPATH are the most usual (note: ELF systems have two such
|
||||
tags, more on that below).
|
||||
|
||||
Possible options to set the runtime shared library search path include
|
||||
the following:
|
||||
|
||||
-Wl,-rpath,/whatever/path # Linux, *BSD, etc.
|
||||
-R /whatever/path # Solaris
|
||||
-Wl,-R,/whatever/path # AIX (-bsvr4 is passed internally)
|
||||
-Wl,+b,/whatever/path # HP-UX
|
||||
-rpath /whatever/path # Tru64, IRIX
|
||||
|
||||
OpenSSL's configuration scripts recognise all these options and pass
|
||||
them to the Makefile that they build. (In fact, all arguments starting
|
||||
with '-Wl,' are recognised as linker options.)
|
||||
|
||||
Please do not use verbatim directories in your runtime shared library
|
||||
search path! Some OpenSSL config targets add an extra directory level
|
||||
for multilib installations. To help with that, the produced Makefile
|
||||
includes the variable LIBRPATH, which is a convenience variable to be
|
||||
used with the runtime shared library search path options, as shown in
|
||||
this example:
|
||||
|
||||
$ ./config --prefix=/usr/local/ssl --openssldir=/usr/local/ssl \
|
||||
'-Wl,-rpath,$(LIBRPATH)'
|
||||
|
||||
On modern ELF based systems, there are two runtime search paths tags to
|
||||
consider, DT_RPATH and DT_RUNPATH. Shared objects are searched for in
|
||||
this order:
|
||||
|
||||
1. Using directories specified in DT_RPATH, unless DT_RUNPATH is
|
||||
also set.
|
||||
2. Using the environment variable LD_LIBRARY_PATH
|
||||
3. Using directories specified in DT_RUNPATH.
|
||||
4. Using system shared object caches and default directories.
|
||||
|
||||
This means that the values in the environment variable LD_LIBRARY_PATH
|
||||
won't matter if the library is found in the paths given by DT_RPATH
|
||||
(and DT_RUNPATH isn't set).
|
||||
|
||||
Exactly which of DT_RPATH or DT_RUNPATH is set by default appears to
|
||||
depend on the system. For example, according to documentation,
|
||||
DT_RPATH appears to be deprecated on Solaris in favor of DT_RUNPATH,
|
||||
while on Debian GNU/Linux, either can be set, and DT_RPATH is the
|
||||
default at the time of writing.
|
||||
|
||||
How to choose which runtime search path tag is to be set depends on
|
||||
your system, please refer to ld(1) for the exact information on your
|
||||
system. As an example, the way to ensure the DT_RUNPATH is set on
|
||||
Debian GNU/Linux systems rather than DT_RPATH is to tell the linker to
|
||||
set new dtags, like this:
|
||||
|
||||
$ ./config --prefix=/usr/local/ssl --openssldir=/usr/local/ssl \
|
||||
'-Wl,--enable-new-dtags,-rpath,$(LIBRPATH)'
|
||||
|
||||
It might be worth noting that some/most ELF systems implement support
|
||||
for runtime search path relative to the directory containing current
|
||||
executable, by interpreting $ORIGIN along with some other internal
|
||||
variables. Consult your system documentation.
|
||||
|
||||
Linking your application
|
||||
------------------------
|
||||
|
||||
Third-party applications dynamically linked with OpenSSL (or any other)
|
||||
shared library face exactly the same problem with non-default locations.
|
||||
The OpenSSL config options mentioned above might or might not have bearing
|
||||
on linking of the target application. "Might" means that under some
|
||||
circumstances it would be sufficient to link with OpenSSL shared library
|
||||
"naturally", i.e. with -L/whatever/path -lssl -lcrypto. But there are
|
||||
also cases when you'd have to explicitly specify runtime search path
|
||||
when linking your application. Consult your system documentation and use
|
||||
above section as inspiration...
|
||||
|
||||
Shared OpenSSL builds also install static libraries. Linking with the
|
||||
latter is likely to require special care, because linkers usually look
|
||||
for shared libraries first and tend to remain "blind" to static OpenSSL
|
||||
libraries. Referring to system documentation would suffice, if not for
|
||||
a corner case. On AIX static libraries (in shared build) are named
|
||||
differently, add _a suffix to link with them, e.g. -lcrypto_a.
|
@ -1,213 +0,0 @@
|
||||
* System libcrypto.dylib and libssl.dylib are used by system ld on MacOS X.
|
||||
|
||||
|
||||
NOTE: The problem described here only applies when OpenSSL isn't built
|
||||
with shared library support (i.e. without the "shared" configuration
|
||||
option). If you build with shared library support, you will have no
|
||||
problems as long as you set up DYLD_LIBRARY_PATH properly at all times.
|
||||
|
||||
|
||||
This is really a misfeature in ld, which seems to look for .dylib libraries
|
||||
along the whole library path before it bothers looking for .a libraries. This
|
||||
means that -L switches won't matter unless OpenSSL is built with shared
|
||||
library support.
|
||||
|
||||
The workaround may be to change the following lines in apps/Makefile and
|
||||
test/Makefile:
|
||||
|
||||
LIBCRYPTO=-L.. -lcrypto
|
||||
LIBSSL=-L.. -lssl
|
||||
|
||||
to:
|
||||
|
||||
LIBCRYPTO=../libcrypto.a
|
||||
LIBSSL=../libssl.a
|
||||
|
||||
It's possible that something similar is needed for shared library support
|
||||
as well. That hasn't been well tested yet.
|
||||
|
||||
|
||||
Another solution that many seem to recommend is to move the libraries
|
||||
/usr/lib/libcrypto.0.9.dylib, /usr/lib/libssl.0.9.dylib to a different
|
||||
directory, build and install OpenSSL and anything that depends on your
|
||||
build, then move libcrypto.0.9.dylib and libssl.0.9.dylib back to their
|
||||
original places. Note that the version numbers on those two libraries
|
||||
may differ on your machine.
|
||||
|
||||
|
||||
As long as Apple doesn't fix the problem with ld, this problem building
|
||||
OpenSSL will remain as is. Well, the problem was addressed in 0.9.8f by
|
||||
passing -Wl,-search_paths_first, but it's unknown if the flag was
|
||||
supported from the initial MacOS X release.
|
||||
|
||||
|
||||
* Parallell make leads to errors
|
||||
|
||||
While running tests, running a parallell make is a bad idea. Many test
|
||||
scripts use the same name for output and input files, which means different
|
||||
will interfere with each other and lead to test failure.
|
||||
|
||||
The solution is simple for now: don't run parallell make when testing.
|
||||
|
||||
|
||||
* Bugs in gcc triggered
|
||||
|
||||
- According to a problem report, there are bugs in gcc 3.0 that are
|
||||
triggered by some of the code in OpenSSL, more specifically in
|
||||
PEM_get_EVP_CIPHER_INFO(). The triggering code is the following:
|
||||
|
||||
header+=11;
|
||||
if (*header != '4') return(0); header++;
|
||||
if (*header != ',') return(0); header++;
|
||||
|
||||
What happens is that gcc might optimize a little too agressively, and
|
||||
you end up with an extra incrementation when *header != '4'.
|
||||
|
||||
We recommend that you upgrade gcc to as high a 3.x version as you can.
|
||||
|
||||
- According to multiple problem reports, some of our message digest
|
||||
implementations trigger bug[s] in code optimizer in gcc 3.3 for sparc64
|
||||
and gcc 2.96 for ppc. Former fails to complete RIPEMD160 test, while
|
||||
latter - SHA one.
|
||||
|
||||
The recomendation is to upgrade your compiler. This naturally applies to
|
||||
other similar cases.
|
||||
|
||||
- There is a subtle Solaris x86-specific gcc run-time environment bug, which
|
||||
"falls between" OpenSSL [0.9.8 and later], Solaris ld and GCC. The bug
|
||||
manifests itself as Segmentation Fault upon early application start-up.
|
||||
The problem can be worked around by patching the environment according to
|
||||
http://www.openssl.org/~appro/values.c.
|
||||
|
||||
* solaris64-sparcv9-cc SHA-1 performance with WorkShop 6 compiler.
|
||||
|
||||
As subject suggests SHA-1 might perform poorly (4 times slower)
|
||||
if compiled with WorkShop 6 compiler and -xarch=v9. The cause for
|
||||
this seems to be the fact that compiler emits multiplication to
|
||||
perform shift operations:-( To work the problem around configure
|
||||
with './Configure solaris64-sparcv9-cc -DMD32_REG_T=int'.
|
||||
|
||||
* Problems with hp-parisc2-cc target when used with "no-asm" flag
|
||||
|
||||
When using the hp-parisc2-cc target, wrong bignum code is generated.
|
||||
This is due to the SIXTY_FOUR_BIT build being compiled with the +O3
|
||||
aggressive optimization.
|
||||
The problem manifests itself by the BN_kronecker test hanging in an
|
||||
endless loop. Reason: the BN_kronecker test calls BN_generate_prime()
|
||||
which itself hangs. The reason could be tracked down to the bn_mul_comba8()
|
||||
function in bn_asm.c. At some occasions the higher 32bit value of r[7]
|
||||
is off by 1 (meaning: calculated=shouldbe+1). Further analysis failed,
|
||||
as no debugger support possible at +O3 and additional fprintf()'s
|
||||
introduced fixed the bug, therefore it is most likely a bug in the
|
||||
optimizer.
|
||||
The bug was found in the BN_kronecker test but may also lead to
|
||||
failures in other parts of the code.
|
||||
(See Ticket #426.)
|
||||
|
||||
Workaround: modify the target to +O2 when building with no-asm.
|
||||
|
||||
* Problems building shared libraries on SCO OpenServer Release 5.0.6
|
||||
with gcc 2.95.3
|
||||
|
||||
The symptoms appear when running the test suite, more specifically
|
||||
test/ectest, with the following result:
|
||||
|
||||
OSSL_LIBPATH="`cd ..; pwd`"; LD_LIBRARY_PATH="$OSSL_LIBPATH:$LD_LIBRARY_PATH"; DYLD_LIBRARY_PATH="$OSSL_LIBPATH:$DYLD_LIBRARY_PATH"; SHLIB_PATH="$OSSL_LIBPATH:$SHLIB_PATH"; LIBPATH="$OSSL_LIBPATH:$LIBPATH"; if [ "debug-sco5-gcc" = "Cygwin" ]; then PATH="${LIBPATH}:$PATH"; fi; export LD_LIBRARY_PATH DYLD_LIBRARY_PATH SHLIB_PATH LIBPATH PATH; ./ectest
|
||||
ectest.c:186: ABORT
|
||||
|
||||
The cause of the problem seems to be that isxdigit(), called from
|
||||
BN_hex2bn(), returns 0 on a perfectly legitimate hex digit. Further
|
||||
investigation shows that any of the isxxx() macros return 0 on any
|
||||
input. A direct look in the information array that the isxxx() use,
|
||||
called __ctype, shows that it contains all zeroes...
|
||||
|
||||
Taking a look at the newly created libcrypto.so with nm, one can see
|
||||
that the variable __ctype is defined in libcrypto's .bss (which
|
||||
explains why it is filled with zeroes):
|
||||
|
||||
$ nm -Pg libcrypto.so | grep __ctype
|
||||
__ctype B 0011659c
|
||||
__ctype2 U
|
||||
|
||||
Curiously, __ctype2 is undefined, in spite of being declared in
|
||||
/usr/include/ctype.h in exactly the same way as __ctype.
|
||||
|
||||
Any information helping to solve this issue would be deeply
|
||||
appreciated.
|
||||
|
||||
NOTE: building non-shared doesn't come with this problem.
|
||||
|
||||
* ULTRIX build fails with shell errors, such as "bad substitution"
|
||||
and "test: argument expected"
|
||||
|
||||
The problem is caused by ULTRIX /bin/sh supporting only original
|
||||
Bourne shell syntax/semantics, and the trouble is that the vast
|
||||
majority is so accustomed to more modern syntax, that very few
|
||||
people [if any] would recognize the ancient syntax even as valid.
|
||||
This inevitably results in non-trivial scripts breaking on ULTRIX,
|
||||
and OpenSSL isn't an exclusion. Fortunately there is workaround,
|
||||
hire /bin/ksh to do the job /bin/sh fails to do.
|
||||
|
||||
1. Trick make(1) to use /bin/ksh by setting up following environ-
|
||||
ment variables *prior* you execute ./Configure and make:
|
||||
|
||||
PROG_ENV=POSIX
|
||||
MAKESHELL=/bin/ksh
|
||||
export PROG_ENV MAKESHELL
|
||||
|
||||
or if your shell is csh-compatible:
|
||||
|
||||
setenv PROG_ENV POSIX
|
||||
setenv MAKESHELL /bin/ksh
|
||||
|
||||
2. Trick /bin/sh to use alternative expression evaluator. Create
|
||||
following 'test' script for example in /tmp:
|
||||
|
||||
#!/bin/ksh
|
||||
${0##*/} "$@"
|
||||
|
||||
Then 'chmod a+x /tmp/test; ln /tmp/test /tmp/[' and *prepend*
|
||||
your $PATH with chosen location, e.g. PATH=/tmp:$PATH. Alter-
|
||||
natively just replace system /bin/test and /bin/[ with the
|
||||
above script.
|
||||
|
||||
* hpux64-ia64-cc fails blowfish test.
|
||||
|
||||
Compiler bug, presumably at particular patch level. It should be noted
|
||||
that same compiler generates correct 32-bit code, a.k.a. hpux-ia64-cc
|
||||
target. Drop optimization level to +O2 when compiling 64-bit bf_skey.o.
|
||||
|
||||
* no-engines generates errors.
|
||||
|
||||
Unfortunately, the 'no-engines' configuration option currently doesn't
|
||||
work properly. Use 'no-hw' and you'll will at least get no hardware
|
||||
support. We'll see how we fix that on OpenSSL versions past 0.9.8.
|
||||
|
||||
* 'make test' fails in BN_sqr [commonly with "error 139" denoting SIGSEGV]
|
||||
if elder GNU binutils were deployed to link shared libcrypto.so.
|
||||
|
||||
As subject suggests the failure is caused by a bug in elder binutils,
|
||||
either as or ld, and was observed on FreeBSD and Linux. There are two
|
||||
options. First is naturally to upgrade binutils, the second one - to
|
||||
reconfigure with additional no-sse2 [or 386] option passed to ./config.
|
||||
|
||||
* If configured with ./config no-dso, toolkit still gets linked with -ldl,
|
||||
which most notably poses a problem when linking with dietlibc.
|
||||
|
||||
We don't have framework to associate -ldl with no-dso, therefore the only
|
||||
way is to edit Makefile right after ./config no-dso and remove -ldl from
|
||||
EX_LIBS line.
|
||||
|
||||
* hpux-parisc2-cc no-asm build fails with SEGV in ECDSA/DH.
|
||||
|
||||
Compiler bug, presumably at particular patch level. Remaining
|
||||
hpux*-parisc*-cc configurations can be affected too. Drop optimization
|
||||
level to +O2 when compiling bn_nist.o.
|
||||
|
||||
* solaris64-sparcv9-cc link failure
|
||||
|
||||
Solaris 8 ar can fail to maintain symbol table in .a, which results in
|
||||
link failures. Apply 109147-09 or later or modify Makefile generated
|
||||
by ./Configure solaris64-sparcv9-cc and replace RANLIB assignment with
|
||||
|
||||
RANLIB= /usr/ccs/bin/ar rs
|
@ -1,5 +1,5 @@
|
||||
|
||||
OpenSSL 1.0.2p 14 Aug 2018
|
||||
OpenSSL 1.1.1 11 Sep 2018
|
||||
|
||||
Copyright (c) 1998-2018 The OpenSSL Project
|
||||
Copyright (c) 1995-1998 Eric A. Young, Tim J. Hudson
|
||||
@ -10,11 +10,8 @@
|
||||
|
||||
The OpenSSL Project is a collaborative effort to develop a robust,
|
||||
commercial-grade, fully featured, and Open Source toolkit implementing the
|
||||
Secure Sockets Layer (SSLv3) and Transport Layer Security (TLS) protocols as
|
||||
well as a full-strength general purpose cryptograpic library. The project is
|
||||
managed by a worldwide community of volunteers that use the Internet to
|
||||
communicate, plan, and develop the OpenSSL toolkit and its related
|
||||
documentation.
|
||||
Transport Layer Security (TLS) protocols (including SSLv3) as well as a
|
||||
full-strength general purpose cryptographic library.
|
||||
|
||||
OpenSSL is descended from the SSLeay library developed by Eric A. Young
|
||||
and Tim J. Hudson. The OpenSSL toolkit is licensed under a dual-license (the
|
||||
@ -27,10 +24,10 @@
|
||||
|
||||
The OpenSSL toolkit includes:
|
||||
|
||||
libssl.a:
|
||||
libssl (with platform specific naming):
|
||||
Provides the client and server-side implementations for SSLv3 and TLS.
|
||||
|
||||
libcrypto.a:
|
||||
libcrypto (with platform specific naming):
|
||||
Provides general cryptographic and X.509 support needed by SSL/TLS but
|
||||
not logically part of it.
|
||||
|
||||
@ -48,20 +45,16 @@
|
||||
------------
|
||||
|
||||
See the appropriate file:
|
||||
INSTALL Linux, Unix, etc.
|
||||
INSTALL.DJGPP DOS platform with DJGPP
|
||||
INSTALL.NW Netware
|
||||
INSTALL.OS2 OS/2
|
||||
INSTALL.VMS VMS
|
||||
INSTALL.W32 Windows (32bit)
|
||||
INSTALL.W64 Windows (64bit)
|
||||
INSTALL.WCE Windows CE
|
||||
INSTALL Linux, Unix, Windows, OpenVMS, ...
|
||||
NOTES.* INSTALL addendums for different platforms
|
||||
|
||||
SUPPORT
|
||||
-------
|
||||
|
||||
See the OpenSSL website www.openssl.org for details on how to obtain
|
||||
commercial technical support.
|
||||
commercial technical support. Free community support is available through the
|
||||
openssl-users email list (see
|
||||
https://www.openssl.org/community/mailinglists.html for further details).
|
||||
|
||||
If you have any problems with OpenSSL then please take the following steps
|
||||
first:
|
||||
@ -69,23 +62,22 @@
|
||||
- Download the latest version from the repository
|
||||
to see if the problem has already been addressed
|
||||
- Configure with no-asm
|
||||
- Remove compiler optimisation flags
|
||||
- Remove compiler optimization flags
|
||||
|
||||
If you wish to report a bug then please include the following information
|
||||
and create an issue on GitHub:
|
||||
|
||||
- On Unix systems:
|
||||
Self-test report generated by 'make report'
|
||||
- On other systems:
|
||||
OpenSSL version: output of 'openssl version -a'
|
||||
OS Name, Version, Hardware platform
|
||||
Compiler Details (name, version)
|
||||
- OpenSSL version: output of 'openssl version -a'
|
||||
- Configuration data: output of 'perl configdata.pm --dump'
|
||||
- OS Name, Version, Hardware platform
|
||||
- Compiler Details (name, version)
|
||||
- Application Details (name, version)
|
||||
- Problem Description (steps that will reproduce the problem, if known)
|
||||
- Stack Traceback (if the application dumps core)
|
||||
|
||||
Just because something doesn't work the way you expect does not mean it
|
||||
is necessarily a bug in OpenSSL.
|
||||
is necessarily a bug in OpenSSL. Use the openssl-users email list for this type
|
||||
of query.
|
||||
|
||||
HOW TO CONTRIBUTE TO OpenSSL
|
||||
----------------------------
|
||||
|
@ -1,187 +0,0 @@
|
||||
|
||||
OpenSSL ASN1 Revision
|
||||
=====================
|
||||
|
||||
This document describes some of the issues relating to the new ASN1 code.
|
||||
|
||||
Previous OpenSSL ASN1 problems
|
||||
=============================
|
||||
|
||||
OK why did the OpenSSL ASN1 code need revising in the first place? Well
|
||||
there are lots of reasons some of which are included below...
|
||||
|
||||
1. The code is difficult to read and write. For every single ASN1 structure
|
||||
(e.g. SEQUENCE) four functions need to be written for new, free, encode and
|
||||
decode operations. This is a very painful and error prone operation. Very few
|
||||
people have ever written any OpenSSL ASN1 and those that have usually wish
|
||||
they hadn't.
|
||||
|
||||
2. Partly because of 1. the code is bloated and takes up a disproportionate
|
||||
amount of space. The SEQUENCE encoder is particularly bad: it essentially
|
||||
contains two copies of the same operation, one to compute the SEQUENCE length
|
||||
and the other to encode it.
|
||||
|
||||
3. The code is memory based: that is it expects to be able to read the whole
|
||||
structure from memory. This is fine for small structures but if you have a
|
||||
(say) 1Gb PKCS#7 signedData structure it isn't such a good idea...
|
||||
|
||||
4. The code for the ASN1 IMPLICIT tag is evil. It is handled by temporarily
|
||||
changing the tag to the expected one, attempting to read it, then changing it
|
||||
back again. This means that decode buffers have to be writable even though they
|
||||
are ultimately unchanged. This gets in the way of constification.
|
||||
|
||||
5. The handling of EXPLICIT isn't much better. It adds a chunk of code into
|
||||
the decoder and encoder for every EXPLICIT tag.
|
||||
|
||||
6. APPLICATION and PRIVATE tags aren't even supported at all.
|
||||
|
||||
7. Even IMPLICIT isn't complete: there is no support for implicitly tagged
|
||||
types that are not OPTIONAL.
|
||||
|
||||
8. Much of the code assumes that a tag will fit in a single octet. This is
|
||||
only true if the tag is 30 or less (mercifully tags over 30 are rare).
|
||||
|
||||
9. The ASN1 CHOICE type has to be largely handled manually, there aren't any
|
||||
macros that properly support it.
|
||||
|
||||
10. Encoders have no concept of OPTIONAL and have no error checking. If the
|
||||
passed structure contains a NULL in a mandatory field it will not be encoded,
|
||||
resulting in an invalid structure.
|
||||
|
||||
11. It is tricky to add ASN1 encoders and decoders to external applications.
|
||||
|
||||
Template model
|
||||
==============
|
||||
|
||||
One of the major problems with revision is the sheer volume of the ASN1 code.
|
||||
Attempts to change (for example) the IMPLICIT behaviour would result in a
|
||||
modification of *every* single decode function.
|
||||
|
||||
I decided to adopt a template based approach. I'm using the term 'template'
|
||||
in a manner similar to SNACC templates: it has nothing to do with C++
|
||||
templates.
|
||||
|
||||
A template is a description of an ASN1 module as several constant C structures.
|
||||
It describes in a machine readable way exactly how the ASN1 structure should
|
||||
behave. If this template contains enough detail then it is possible to write
|
||||
versions of new, free, encode, decode (and possibly others operations) that
|
||||
operate on templates.
|
||||
|
||||
Instead of having to write code to handle each operation only a single
|
||||
template needs to be written. If new operations are needed (such as a 'print'
|
||||
operation) only a single new template based function needs to be written
|
||||
which will then automatically handle all existing templates.
|
||||
|
||||
Plans for revision
|
||||
==================
|
||||
|
||||
The revision will consist of the following steps. Other than the first two
|
||||
these can be handled in any order.
|
||||
|
||||
o Design and write template new, free, encode and decode operations, initially
|
||||
memory based. *DONE*
|
||||
|
||||
o Convert existing ASN1 code to template form. *IN PROGRESS*
|
||||
|
||||
o Convert an existing ASN1 compiler (probably SNACC) to output templates
|
||||
in OpenSSL form.
|
||||
|
||||
o Add support for BIO based ASN1 encoders and decoders to handle large
|
||||
structures, initially blocking I/O.
|
||||
|
||||
o Add support for non blocking I/O: this is quite a bit harder than blocking
|
||||
I/O.
|
||||
|
||||
o Add new ASN1 structures, such as OCSP, CRMF, S/MIME v3 (CMS), attribute
|
||||
certificates etc etc.
|
||||
|
||||
Description of major changes
|
||||
============================
|
||||
|
||||
The BOOLEAN type now takes three values. 0xff is TRUE, 0 is FALSE and -1 is
|
||||
absent. The meaning of absent depends on the context. If for example the
|
||||
boolean type is DEFAULT FALSE (as in the case of the critical flag for
|
||||
certificate extensions) then -1 is FALSE, if DEFAULT TRUE then -1 is TRUE.
|
||||
Usually the value will only ever be read via an API which will hide this from
|
||||
an application.
|
||||
|
||||
There is an evil bug in the old ASN1 code that mishandles OPTIONAL with
|
||||
SEQUENCE OF or SET OF. These are both implemented as a STACK structure. The
|
||||
old code would omit the structure if the STACK was NULL (which is fine) or if
|
||||
it had zero elements (which is NOT OK). This causes problems because an empty
|
||||
SEQUENCE OF or SET OF will result in an empty STACK when it is decoded but when
|
||||
it is encoded it will be omitted resulting in different encodings. The new code
|
||||
only omits the encoding if the STACK is NULL, if it contains zero elements it
|
||||
is encoded and empty. There is an additional problem though: because an empty
|
||||
STACK was omitted, sometimes the corresponding *_new() function would
|
||||
initialize the STACK to empty so an application could immediately use it, if
|
||||
this is done with the new code (i.e. a NULL) it wont work. Therefore a new
|
||||
STACK should be allocated first. One instance of this is the X509_CRL list of
|
||||
revoked certificates: a helper function X509_CRL_add0_revoked() has been added
|
||||
for this purpose.
|
||||
|
||||
The X509_ATTRIBUTE structure used to have an element called 'set' which took
|
||||
the value 1 if the attribute value was a SET OF or 0 if it was a single. Due
|
||||
to the behaviour of CHOICE in the new code this has been changed to a field
|
||||
called 'single' which is 0 for a SET OF and 1 for single. The old field has
|
||||
been deleted to deliberately break source compatibility. Since this structure
|
||||
is normally accessed via higher level functions this shouldn't break too much.
|
||||
|
||||
The X509_REQ_INFO certificate request info structure no longer has a field
|
||||
called 'req_kludge'. This used to be set to 1 if the attributes field was
|
||||
(incorrectly) omitted. You can check to see if the field is omitted now by
|
||||
checking if the attributes field is NULL. Similarly if you need to omit
|
||||
the field then free attributes and set it to NULL.
|
||||
|
||||
The top level 'detached' field in the PKCS7 structure is no longer set when
|
||||
a PKCS#7 structure is read in. PKCS7_is_detached() should be called instead.
|
||||
The behaviour of PKCS7_get_detached() is unaffected.
|
||||
|
||||
The values of 'type' in the GENERAL_NAME structure have changed. This is
|
||||
because the old code use the ASN1 initial octet as the selector. The new
|
||||
code uses the index in the ASN1_CHOICE template.
|
||||
|
||||
The DIST_POINT_NAME structure has changed to be a true CHOICE type.
|
||||
|
||||
typedef struct DIST_POINT_NAME_st {
|
||||
int type;
|
||||
union {
|
||||
STACK_OF(GENERAL_NAME) *fullname;
|
||||
STACK_OF(X509_NAME_ENTRY) *relativename;
|
||||
} name;
|
||||
} DIST_POINT_NAME;
|
||||
|
||||
This means that name.fullname or name.relativename should be set
|
||||
and type reflects the option. That is if name.fullname is set then
|
||||
type is 0 and if name.relativename is set type is 1.
|
||||
|
||||
With the old code using the i2d functions would typically involve:
|
||||
|
||||
unsigned char *buf, *p;
|
||||
int len;
|
||||
/* Find length of encoding */
|
||||
len = i2d_SOMETHING(x, NULL);
|
||||
/* Allocate buffer */
|
||||
buf = OPENSSL_malloc(len);
|
||||
if(buf == NULL) {
|
||||
/* Malloc error */
|
||||
}
|
||||
/* Use temp variable because &p gets updated to point to end of
|
||||
* encoding.
|
||||
*/
|
||||
p = buf;
|
||||
i2d_SOMETHING(x, &p);
|
||||
|
||||
|
||||
Using the new i2d you can also do:
|
||||
|
||||
unsigned char *buf = NULL;
|
||||
int len;
|
||||
len = i2d_SOMETHING(x, &buf);
|
||||
if(len < 0) {
|
||||
/* Malloc error */
|
||||
}
|
||||
|
||||
and it will automatically allocate and populate a buffer with the
|
||||
encoding. After this call 'buf' will point to the start of the
|
||||
encoding which is len bytes long.
|
@ -13,11 +13,9 @@
|
||||
There are currently built-in ENGINE implementations for the following
|
||||
crypto devices:
|
||||
|
||||
o CryptoSwift
|
||||
o Compaq Atalla
|
||||
o Microsoft CryptoAPI
|
||||
o VIA Padlock
|
||||
o nCipher CHIL
|
||||
o Nuron
|
||||
o Broadcom uBSec
|
||||
|
||||
In addition, dynamic binding to external ENGINE implementations is now
|
||||
provided by a special ENGINE called "dynamic". See the "DYNAMIC ENGINE"
|
||||
|
1
crypto/openssl/README.FIPS
Normal file
1
crypto/openssl/README.FIPS
Normal file
@ -0,0 +1 @@
|
||||
This release does not support a FIPS 140-2 validated module.
|
@ -1,188 +0,0 @@
|
||||
#!/usr/bin/perl
|
||||
#
|
||||
# CA - wrapper around ca to make it easier to use ... basically ca requires
|
||||
# some setup stuff to be done before you can use it and this makes
|
||||
# things easier between now and when Eric is convinced to fix it :-)
|
||||
#
|
||||
# CA -newca ... will setup the right stuff
|
||||
# CA -newreq[-nodes] ... will generate a certificate request
|
||||
# CA -sign ... will sign the generated request and output
|
||||
#
|
||||
# At the end of that grab newreq.pem and newcert.pem (one has the key
|
||||
# and the other the certificate) and cat them together and that is what
|
||||
# you want/need ... I'll make even this a little cleaner later.
|
||||
#
|
||||
#
|
||||
# 12-Jan-96 tjh Added more things ... including CA -signcert which
|
||||
# converts a certificate to a request and then signs it.
|
||||
# 10-Jan-96 eay Fixed a few more bugs and added the SSLEAY_CONFIG
|
||||
# environment variable so this can be driven from
|
||||
# a script.
|
||||
# 25-Jul-96 eay Cleaned up filenames some more.
|
||||
# 11-Jun-96 eay Fixed a few filename missmatches.
|
||||
# 03-May-96 eay Modified to use 'ssleay cmd' instead of 'cmd'.
|
||||
# 18-Apr-96 tjh Original hacking
|
||||
#
|
||||
# Tim Hudson
|
||||
# tjh@cryptsoft.com
|
||||
#
|
||||
|
||||
# 27-Apr-98 snh Translation into perl, fix existing CA bug.
|
||||
#
|
||||
#
|
||||
# Steve Henson
|
||||
# shenson@bigfoot.com
|
||||
|
||||
# default openssl.cnf file has setup as per the following
|
||||
# demoCA ... where everything is stored
|
||||
|
||||
my $openssl;
|
||||
if(defined $ENV{OPENSSL}) {
|
||||
$openssl = $ENV{OPENSSL};
|
||||
} else {
|
||||
$openssl = "openssl";
|
||||
$ENV{OPENSSL} = $openssl;
|
||||
}
|
||||
|
||||
$SSLEAY_CONFIG=$ENV{"SSLEAY_CONFIG"};
|
||||
$DAYS="-days 365"; # 1 year
|
||||
$CADAYS="-days 1095"; # 3 years
|
||||
$REQ="$openssl req $SSLEAY_CONFIG";
|
||||
$CA="$openssl ca $SSLEAY_CONFIG";
|
||||
$VERIFY="$openssl verify";
|
||||
$X509="$openssl x509";
|
||||
$PKCS12="$openssl pkcs12";
|
||||
|
||||
$CATOP="./demoCA";
|
||||
$CAKEY="cakey.pem";
|
||||
$CAREQ="careq.pem";
|
||||
$CACERT="cacert.pem";
|
||||
|
||||
$DIRMODE = 0777;
|
||||
|
||||
$RET = 0;
|
||||
|
||||
foreach (@ARGV) {
|
||||
if ( /^(-\?|-h|-help)$/ ) {
|
||||
print STDERR "usage: CA -newcert|-newreq|-newreq-nodes|-newca|-sign|-signcert|-verify\n";
|
||||
exit 0;
|
||||
} elsif (/^-newcert$/) {
|
||||
# create a certificate
|
||||
system ("$REQ -new -x509 -keyout newkey.pem -out newcert.pem $DAYS");
|
||||
$RET=$?;
|
||||
print "Certificate is in newcert.pem, private key is in newkey.pem\n"
|
||||
} elsif (/^-newreq$/) {
|
||||
# create a certificate request
|
||||
system ("$REQ -new -keyout newkey.pem -out newreq.pem $DAYS");
|
||||
$RET=$?;
|
||||
print "Request is in newreq.pem, private key is in newkey.pem\n";
|
||||
} elsif (/^-newreq-nodes$/) {
|
||||
# create a certificate request
|
||||
system ("$REQ -new -nodes -keyout newkey.pem -out newreq.pem $DAYS");
|
||||
$RET=$?;
|
||||
print "Request is in newreq.pem, private key is in newkey.pem\n";
|
||||
} elsif (/^-newca$/) {
|
||||
# if explicitly asked for or it doesn't exist then setup the
|
||||
# directory structure that Eric likes to manage things
|
||||
$NEW="1";
|
||||
if ( "$NEW" || ! -f "${CATOP}/serial" ) {
|
||||
# create the directory hierarchy
|
||||
mkdir $CATOP, $DIRMODE;
|
||||
mkdir "${CATOP}/certs", $DIRMODE;
|
||||
mkdir "${CATOP}/crl", $DIRMODE ;
|
||||
mkdir "${CATOP}/newcerts", $DIRMODE;
|
||||
mkdir "${CATOP}/private", $DIRMODE;
|
||||
open OUT, ">${CATOP}/index.txt";
|
||||
close OUT;
|
||||
open OUT, ">${CATOP}/crlnumber";
|
||||
print OUT "01\n";
|
||||
close OUT;
|
||||
}
|
||||
if ( ! -f "${CATOP}/private/$CAKEY" ) {
|
||||
print "CA certificate filename (or enter to create)\n";
|
||||
$FILE = <STDIN>;
|
||||
|
||||
chop $FILE;
|
||||
|
||||
# ask user for existing CA certificate
|
||||
if ($FILE) {
|
||||
cp_pem($FILE,"${CATOP}/private/$CAKEY", "PRIVATE");
|
||||
cp_pem($FILE,"${CATOP}/$CACERT", "CERTIFICATE");
|
||||
$RET=$?;
|
||||
} else {
|
||||
print "Making CA certificate ...\n";
|
||||
system ("$REQ -new -keyout " .
|
||||
"${CATOP}/private/$CAKEY -out ${CATOP}/$CAREQ");
|
||||
system ("$CA -create_serial " .
|
||||
"-out ${CATOP}/$CACERT $CADAYS -batch " .
|
||||
"-keyfile ${CATOP}/private/$CAKEY -selfsign " .
|
||||
"-extensions v3_ca " .
|
||||
"-infiles ${CATOP}/$CAREQ ");
|
||||
$RET=$?;
|
||||
}
|
||||
}
|
||||
} elsif (/^-pkcs12$/) {
|
||||
my $cname = $ARGV[1];
|
||||
$cname = "My Certificate" unless defined $cname;
|
||||
system ("$PKCS12 -in newcert.pem -inkey newkey.pem " .
|
||||
"-certfile ${CATOP}/$CACERT -out newcert.p12 " .
|
||||
"-export -name \"$cname\"");
|
||||
$RET=$?;
|
||||
print "PKCS #12 file is in newcert.p12\n";
|
||||
exit $RET;
|
||||
} elsif (/^-xsign$/) {
|
||||
system ("$CA -policy policy_anything -infiles newreq.pem");
|
||||
$RET=$?;
|
||||
} elsif (/^(-sign|-signreq)$/) {
|
||||
system ("$CA -policy policy_anything -out newcert.pem " .
|
||||
"-infiles newreq.pem");
|
||||
$RET=$?;
|
||||
print "Signed certificate is in newcert.pem\n";
|
||||
} elsif (/^(-signCA)$/) {
|
||||
system ("$CA -policy policy_anything -out newcert.pem " .
|
||||
"-extensions v3_ca -infiles newreq.pem");
|
||||
$RET=$?;
|
||||
print "Signed CA certificate is in newcert.pem\n";
|
||||
} elsif (/^-signcert$/) {
|
||||
system ("$X509 -x509toreq -in newreq.pem -signkey newreq.pem " .
|
||||
"-out tmp.pem");
|
||||
system ("$CA -policy policy_anything -out newcert.pem " .
|
||||
"-infiles tmp.pem");
|
||||
$RET = $?;
|
||||
print "Signed certificate is in newcert.pem\n";
|
||||
} elsif (/^-verify$/) {
|
||||
if (shift) {
|
||||
foreach $j (@ARGV) {
|
||||
system ("$VERIFY -CAfile $CATOP/$CACERT $j");
|
||||
$RET=$? if ($? != 0);
|
||||
}
|
||||
exit $RET;
|
||||
} else {
|
||||
system ("$VERIFY -CAfile $CATOP/$CACERT newcert.pem");
|
||||
$RET=$?;
|
||||
exit 0;
|
||||
}
|
||||
} else {
|
||||
print STDERR "Unknown arg $_\n";
|
||||
print STDERR "usage: CA -newcert|-newreq|-newreq-nodes|-newca|-sign|-verify\n";
|
||||
exit 1;
|
||||
}
|
||||
}
|
||||
|
||||
exit $RET;
|
||||
|
||||
sub cp_pem {
|
||||
my ($infile, $outfile, $bound) = @_;
|
||||
open IN, $infile;
|
||||
open OUT, ">$outfile";
|
||||
my $flag = 0;
|
||||
while (<IN>) {
|
||||
$flag = 1 if (/^-----BEGIN.*$bound/) ;
|
||||
print OUT $_ if ($flag);
|
||||
if (/^-----END.*$bound/) {
|
||||
close IN;
|
||||
close OUT;
|
||||
return;
|
||||
}
|
||||
}
|
||||
}
|
@ -1,188 +1,214 @@
|
||||
#!/usr/local/bin/perl
|
||||
#
|
||||
# CA - wrapper around ca to make it easier to use ... basically ca requires
|
||||
# some setup stuff to be done before you can use it and this makes
|
||||
# things easier between now and when Eric is convinced to fix it :-)
|
||||
#
|
||||
# CA -newca ... will setup the right stuff
|
||||
# CA -newreq[-nodes] ... will generate a certificate request
|
||||
# CA -sign ... will sign the generated request and output
|
||||
#
|
||||
# At the end of that grab newreq.pem and newcert.pem (one has the key
|
||||
# and the other the certificate) and cat them together and that is what
|
||||
# you want/need ... I'll make even this a little cleaner later.
|
||||
#
|
||||
#
|
||||
# 12-Jan-96 tjh Added more things ... including CA -signcert which
|
||||
# converts a certificate to a request and then signs it.
|
||||
# 10-Jan-96 eay Fixed a few more bugs and added the SSLEAY_CONFIG
|
||||
# environment variable so this can be driven from
|
||||
# a script.
|
||||
# 25-Jul-96 eay Cleaned up filenames some more.
|
||||
# 11-Jun-96 eay Fixed a few filename missmatches.
|
||||
# 03-May-96 eay Modified to use 'ssleay cmd' instead of 'cmd'.
|
||||
# 18-Apr-96 tjh Original hacking
|
||||
#
|
||||
# Tim Hudson
|
||||
# tjh@cryptsoft.com
|
||||
#!{- $config{HASHBANGPERL} -}
|
||||
# Copyright 2000-2018 The OpenSSL Project Authors. All Rights Reserved.
|
||||
#
|
||||
# Licensed under the OpenSSL license (the "License"). You may not use
|
||||
# this file except in compliance with the License. You can obtain a copy
|
||||
# in the file LICENSE in the source distribution or at
|
||||
# https://www.openssl.org/source/license.html
|
||||
|
||||
# 27-Apr-98 snh Translation into perl, fix existing CA bug.
|
||||
#
|
||||
# Wrapper around the ca to make it easier to use
|
||||
#
|
||||
# Steve Henson
|
||||
# shenson@bigfoot.com
|
||||
# {- join("\n# ", @autowarntext) -}
|
||||
|
||||
# default openssl.cnf file has setup as per the following
|
||||
# demoCA ... where everything is stored
|
||||
use strict;
|
||||
use warnings;
|
||||
|
||||
my $openssl;
|
||||
if(defined $ENV{OPENSSL}) {
|
||||
$openssl = $ENV{OPENSSL};
|
||||
my $openssl = "openssl";
|
||||
if(defined $ENV{'OPENSSL'}) {
|
||||
$openssl = $ENV{'OPENSSL'};
|
||||
} else {
|
||||
$openssl = "openssl";
|
||||
$ENV{OPENSSL} = $openssl;
|
||||
$ENV{'OPENSSL'} = $openssl;
|
||||
}
|
||||
|
||||
$SSLEAY_CONFIG=$ENV{"SSLEAY_CONFIG"};
|
||||
$DAYS="-days 365"; # 1 year
|
||||
$CADAYS="-days 1095"; # 3 years
|
||||
$REQ="$openssl req $SSLEAY_CONFIG";
|
||||
$CA="$openssl ca $SSLEAY_CONFIG";
|
||||
$VERIFY="$openssl verify";
|
||||
$X509="$openssl x509";
|
||||
$PKCS12="$openssl pkcs12";
|
||||
my $verbose = 1;
|
||||
|
||||
$CATOP="./demoCA";
|
||||
$CAKEY="cakey.pem";
|
||||
$CAREQ="careq.pem";
|
||||
$CACERT="cacert.pem";
|
||||
my $OPENSSL_CONFIG = $ENV{"OPENSSL_CONFIG"} || "";
|
||||
my $DAYS = "-days 365";
|
||||
my $CADAYS = "-days 1095"; # 3 years
|
||||
my $REQ = "$openssl req $OPENSSL_CONFIG";
|
||||
my $CA = "$openssl ca $OPENSSL_CONFIG";
|
||||
my $VERIFY = "$openssl verify";
|
||||
my $X509 = "$openssl x509";
|
||||
my $PKCS12 = "$openssl pkcs12";
|
||||
|
||||
$DIRMODE = 0777;
|
||||
# default openssl.cnf file has setup as per the following
|
||||
my $CATOP = "./demoCA";
|
||||
my $CAKEY = "cakey.pem";
|
||||
my $CAREQ = "careq.pem";
|
||||
my $CACERT = "cacert.pem";
|
||||
my $CACRL = "crl.pem";
|
||||
my $DIRMODE = 0777;
|
||||
|
||||
$RET = 0;
|
||||
my $NEWKEY = "newkey.pem";
|
||||
my $NEWREQ = "newreq.pem";
|
||||
my $NEWCERT = "newcert.pem";
|
||||
my $NEWP12 = "newcert.p12";
|
||||
my $RET = 0;
|
||||
my $WHAT = shift @ARGV || "";
|
||||
my @OPENSSL_CMDS = ("req", "ca", "pkcs12", "x509", "verify");
|
||||
my %EXTRA = extra_args(\@ARGV, "-extra-");
|
||||
my $FILE;
|
||||
|
||||
foreach (@ARGV) {
|
||||
if ( /^(-\?|-h|-help)$/ ) {
|
||||
print STDERR "usage: CA -newcert|-newreq|-newreq-nodes|-newca|-sign|-signcert|-verify\n";
|
||||
exit 0;
|
||||
} elsif (/^-newcert$/) {
|
||||
# create a certificate
|
||||
system ("$REQ -new -x509 -keyout newkey.pem -out newcert.pem $DAYS");
|
||||
$RET=$?;
|
||||
print "Certificate is in newcert.pem, private key is in newkey.pem\n"
|
||||
} elsif (/^-newreq$/) {
|
||||
# create a certificate request
|
||||
system ("$REQ -new -keyout newkey.pem -out newreq.pem $DAYS");
|
||||
$RET=$?;
|
||||
print "Request is in newreq.pem, private key is in newkey.pem\n";
|
||||
} elsif (/^-newreq-nodes$/) {
|
||||
# create a certificate request
|
||||
system ("$REQ -new -nodes -keyout newkey.pem -out newreq.pem $DAYS");
|
||||
$RET=$?;
|
||||
print "Request is in newreq.pem, private key is in newkey.pem\n";
|
||||
} elsif (/^-newca$/) {
|
||||
# if explicitly asked for or it doesn't exist then setup the
|
||||
# directory structure that Eric likes to manage things
|
||||
$NEW="1";
|
||||
if ( "$NEW" || ! -f "${CATOP}/serial" ) {
|
||||
# create the directory hierarchy
|
||||
mkdir $CATOP, $DIRMODE;
|
||||
mkdir "${CATOP}/certs", $DIRMODE;
|
||||
mkdir "${CATOP}/crl", $DIRMODE ;
|
||||
mkdir "${CATOP}/newcerts", $DIRMODE;
|
||||
mkdir "${CATOP}/private", $DIRMODE;
|
||||
open OUT, ">${CATOP}/index.txt";
|
||||
close OUT;
|
||||
open OUT, ">${CATOP}/crlnumber";
|
||||
print OUT "01\n";
|
||||
close OUT;
|
||||
}
|
||||
if ( ! -f "${CATOP}/private/$CAKEY" ) {
|
||||
print "CA certificate filename (or enter to create)\n";
|
||||
$FILE = <STDIN>;
|
||||
|
||||
chop $FILE;
|
||||
|
||||
# ask user for existing CA certificate
|
||||
if ($FILE) {
|
||||
cp_pem($FILE,"${CATOP}/private/$CAKEY", "PRIVATE");
|
||||
cp_pem($FILE,"${CATOP}/$CACERT", "CERTIFICATE");
|
||||
$RET=$?;
|
||||
} else {
|
||||
print "Making CA certificate ...\n";
|
||||
system ("$REQ -new -keyout " .
|
||||
"${CATOP}/private/$CAKEY -out ${CATOP}/$CAREQ");
|
||||
system ("$CA -create_serial " .
|
||||
"-out ${CATOP}/$CACERT $CADAYS -batch " .
|
||||
"-keyfile ${CATOP}/private/$CAKEY -selfsign " .
|
||||
"-extensions v3_ca " .
|
||||
"-infiles ${CATOP}/$CAREQ ");
|
||||
$RET=$?;
|
||||
}
|
||||
}
|
||||
} elsif (/^-pkcs12$/) {
|
||||
my $cname = $ARGV[1];
|
||||
$cname = "My Certificate" unless defined $cname;
|
||||
system ("$PKCS12 -in newcert.pem -inkey newkey.pem " .
|
||||
"-certfile ${CATOP}/$CACERT -out newcert.p12 " .
|
||||
"-export -name \"$cname\"");
|
||||
$RET=$?;
|
||||
print "PKCS #12 file is in newcert.p12\n";
|
||||
exit $RET;
|
||||
} elsif (/^-xsign$/) {
|
||||
system ("$CA -policy policy_anything -infiles newreq.pem");
|
||||
$RET=$?;
|
||||
} elsif (/^(-sign|-signreq)$/) {
|
||||
system ("$CA -policy policy_anything -out newcert.pem " .
|
||||
"-infiles newreq.pem");
|
||||
$RET=$?;
|
||||
print "Signed certificate is in newcert.pem\n";
|
||||
} elsif (/^(-signCA)$/) {
|
||||
system ("$CA -policy policy_anything -out newcert.pem " .
|
||||
"-extensions v3_ca -infiles newreq.pem");
|
||||
$RET=$?;
|
||||
print "Signed CA certificate is in newcert.pem\n";
|
||||
} elsif (/^-signcert$/) {
|
||||
system ("$X509 -x509toreq -in newreq.pem -signkey newreq.pem " .
|
||||
"-out tmp.pem");
|
||||
system ("$CA -policy policy_anything -out newcert.pem " .
|
||||
"-infiles tmp.pem");
|
||||
$RET = $?;
|
||||
print "Signed certificate is in newcert.pem\n";
|
||||
} elsif (/^-verify$/) {
|
||||
if (shift) {
|
||||
foreach $j (@ARGV) {
|
||||
system ("$VERIFY -CAfile $CATOP/$CACERT $j");
|
||||
$RET=$? if ($? != 0);
|
||||
}
|
||||
exit $RET;
|
||||
} else {
|
||||
system ("$VERIFY -CAfile $CATOP/$CACERT newcert.pem");
|
||||
$RET=$?;
|
||||
exit 0;
|
||||
}
|
||||
sub extra_args {
|
||||
my ($args_ref, $arg_prefix) = @_;
|
||||
my %eargs = map {
|
||||
if ($_ < $#$args_ref) {
|
||||
my ($arg, $value) = splice(@$args_ref, $_, 2);
|
||||
$arg =~ s/$arg_prefix//;
|
||||
($arg, $value);
|
||||
} else {
|
||||
print STDERR "Unknown arg $_\n";
|
||||
print STDERR "usage: CA -newcert|-newreq|-newreq-nodes|-newca|-sign|-verify\n";
|
||||
exit 1;
|
||||
();
|
||||
}
|
||||
} reverse grep($$args_ref[$_] =~ /$arg_prefix/, 0..$#$args_ref);
|
||||
my %empty = map { ($_, "") } @OPENSSL_CMDS;
|
||||
return (%empty, %eargs);
|
||||
}
|
||||
|
||||
# See if reason for a CRL entry is valid; exit if not.
|
||||
sub crl_reason_ok
|
||||
{
|
||||
my $r = shift;
|
||||
|
||||
if ($r eq 'unspecified' || $r eq 'keyCompromise'
|
||||
|| $r eq 'CACompromise' || $r eq 'affiliationChanged'
|
||||
|| $r eq 'superseded' || $r eq 'cessationOfOperation'
|
||||
|| $r eq 'certificateHold' || $r eq 'removeFromCRL') {
|
||||
return 1;
|
||||
}
|
||||
print STDERR "Invalid CRL reason; must be one of:\n";
|
||||
print STDERR " unspecified, keyCompromise, CACompromise,\n";
|
||||
print STDERR " affiliationChanged, superseded, cessationOfOperation\n";
|
||||
print STDERR " certificateHold, removeFromCRL";
|
||||
exit 1;
|
||||
}
|
||||
|
||||
# Copy a PEM-format file; return like exit status (zero means ok)
|
||||
sub copy_pemfile
|
||||
{
|
||||
my ($infile, $outfile, $bound) = @_;
|
||||
my $found = 0;
|
||||
|
||||
open IN, $infile || die "Cannot open $infile, $!";
|
||||
open OUT, ">$outfile" || die "Cannot write to $outfile, $!";
|
||||
while (<IN>) {
|
||||
$found = 1 if /^-----BEGIN.*$bound/;
|
||||
print OUT $_ if $found;
|
||||
$found = 2, last if /^-----END.*$bound/;
|
||||
}
|
||||
close IN;
|
||||
close OUT;
|
||||
return $found == 2 ? 0 : 1;
|
||||
}
|
||||
|
||||
# Wrapper around system; useful for debugging. Returns just the exit status
|
||||
sub run
|
||||
{
|
||||
my $cmd = shift;
|
||||
print "====\n$cmd\n" if $verbose;
|
||||
my $status = system($cmd);
|
||||
print "==> $status\n====\n" if $verbose;
|
||||
return $status >> 8;
|
||||
}
|
||||
|
||||
|
||||
if ( $WHAT =~ /^(-\?|-h|-help)$/ ) {
|
||||
print STDERR "usage: CA.pl -newcert | -newreq | -newreq-nodes | -xsign | -sign | -signCA | -signcert | -crl | -newca [-extra-cmd extra-params]\n";
|
||||
print STDERR " CA.pl -pkcs12 [-extra-pkcs12 extra-params] [certname]\n";
|
||||
print STDERR " CA.pl -verify [-extra-verify extra-params] certfile ...\n";
|
||||
print STDERR " CA.pl -revoke [-extra-ca extra-params] certfile [reason]\n";
|
||||
exit 0;
|
||||
}
|
||||
if ($WHAT eq '-newcert' ) {
|
||||
# create a certificate
|
||||
$RET = run("$REQ -new -x509 -keyout $NEWKEY -out $NEWCERT $DAYS $EXTRA{req}");
|
||||
print "Cert is in $NEWCERT, private key is in $NEWKEY\n" if $RET == 0;
|
||||
} elsif ($WHAT eq '-precert' ) {
|
||||
# create a pre-certificate
|
||||
$RET = run("$REQ -x509 -precert -keyout $NEWKEY -out $NEWCERT $DAYS");
|
||||
print "Pre-cert is in $NEWCERT, private key is in $NEWKEY\n" if $RET == 0;
|
||||
} elsif ($WHAT =~ /^\-newreq(\-nodes)?$/ ) {
|
||||
# create a certificate request
|
||||
$RET = run("$REQ -new $1 -keyout $NEWKEY -out $NEWREQ $DAYS $EXTRA{req}");
|
||||
print "Request is in $NEWREQ, private key is in $NEWKEY\n" if $RET == 0;
|
||||
} elsif ($WHAT eq '-newca' ) {
|
||||
# create the directory hierarchy
|
||||
mkdir ${CATOP}, $DIRMODE;
|
||||
mkdir "${CATOP}/certs", $DIRMODE;
|
||||
mkdir "${CATOP}/crl", $DIRMODE ;
|
||||
mkdir "${CATOP}/newcerts", $DIRMODE;
|
||||
mkdir "${CATOP}/private", $DIRMODE;
|
||||
open OUT, ">${CATOP}/index.txt";
|
||||
close OUT;
|
||||
open OUT, ">${CATOP}/crlnumber";
|
||||
print OUT "01\n";
|
||||
close OUT;
|
||||
# ask user for existing CA certificate
|
||||
print "CA certificate filename (or enter to create)\n";
|
||||
$FILE = "" unless defined($FILE = <STDIN>);
|
||||
$FILE =~ s{\R$}{};
|
||||
if ($FILE ne "") {
|
||||
copy_pemfile($FILE,"${CATOP}/private/$CAKEY", "PRIVATE");
|
||||
copy_pemfile($FILE,"${CATOP}/$CACERT", "CERTIFICATE");
|
||||
} else {
|
||||
print "Making CA certificate ...\n";
|
||||
$RET = run("$REQ -new -keyout"
|
||||
. " ${CATOP}/private/$CAKEY"
|
||||
. " -out ${CATOP}/$CAREQ $EXTRA{req}");
|
||||
$RET = run("$CA -create_serial"
|
||||
. " -out ${CATOP}/$CACERT $CADAYS -batch"
|
||||
. " -keyfile ${CATOP}/private/$CAKEY -selfsign"
|
||||
. " -extensions v3_ca $EXTRA{ca}"
|
||||
. " -infiles ${CATOP}/$CAREQ") if $RET == 0;
|
||||
print "CA certificate is in ${CATOP}/$CACERT\n" if $RET == 0;
|
||||
}
|
||||
} elsif ($WHAT eq '-pkcs12' ) {
|
||||
my $cname = $ARGV[0];
|
||||
$cname = "My Certificate" unless defined $cname;
|
||||
$RET = run("$PKCS12 -in $NEWCERT -inkey $NEWKEY"
|
||||
. " -certfile ${CATOP}/$CACERT"
|
||||
. " -out $NEWP12"
|
||||
. " -export -name \"$cname\" $EXTRA{pkcs12}");
|
||||
print "PKCS #12 file is in $NEWP12\n" if $RET == 0;
|
||||
} elsif ($WHAT eq '-xsign' ) {
|
||||
$RET = run("$CA -policy policy_anything $EXTRA{ca} -infiles $NEWREQ");
|
||||
} elsif ($WHAT eq '-sign' ) {
|
||||
$RET = run("$CA -policy policy_anything -out $NEWCERT $EXTRA{ca} -infiles $NEWREQ");
|
||||
print "Signed certificate is in $NEWCERT\n" if $RET == 0;
|
||||
} elsif ($WHAT eq '-signCA' ) {
|
||||
$RET = run("$CA -policy policy_anything -out $NEWCERT"
|
||||
. " -extensions v3_ca $EXTRA{ca} -infiles $NEWREQ");
|
||||
print "Signed CA certificate is in $NEWCERT\n" if $RET == 0;
|
||||
} elsif ($WHAT eq '-signcert' ) {
|
||||
$RET = run("$X509 -x509toreq -in $NEWREQ -signkey $NEWREQ"
|
||||
. " -out tmp.pem $EXTRA{x509}");
|
||||
$RET = run("$CA -policy policy_anything -out $NEWCERT"
|
||||
. "$EXTRA{ca} -infiles tmp.pem") if $RET == 0;
|
||||
print "Signed certificate is in $NEWCERT\n" if $RET == 0;
|
||||
} elsif ($WHAT eq '-verify' ) {
|
||||
my @files = @ARGV ? @ARGV : ( $NEWCERT );
|
||||
my $file;
|
||||
foreach $file (@files) {
|
||||
my $status = run("$VERIFY \"-CAfile\" ${CATOP}/$CACERT $file $EXTRA{verify}");
|
||||
$RET = $status if $status != 0;
|
||||
}
|
||||
} elsif ($WHAT eq '-crl' ) {
|
||||
$RET = run("$CA -gencrl -out ${CATOP}/crl/$CACRL $EXTRA{ca}");
|
||||
print "Generated CRL is in ${CATOP}/crl/$CACRL\n" if $RET == 0;
|
||||
} elsif ($WHAT eq '-revoke' ) {
|
||||
my $cname = $ARGV[0];
|
||||
if (!defined $cname) {
|
||||
print "Certificate filename is required; reason optional.\n";
|
||||
exit 1;
|
||||
}
|
||||
my $reason = $ARGV[1];
|
||||
$reason = " -crl_reason $reason"
|
||||
if defined $reason && crl_reason_ok($reason);
|
||||
$RET = run("$CA -revoke \"$cname\"" . $reason . $EXTRA{ca});
|
||||
} else {
|
||||
print STDERR "Unknown arg \"$WHAT\"\n";
|
||||
print STDERR "Use -help for help.\n";
|
||||
exit 1;
|
||||
}
|
||||
|
||||
exit $RET;
|
||||
|
||||
sub cp_pem {
|
||||
my ($infile, $outfile, $bound) = @_;
|
||||
open IN, $infile;
|
||||
open OUT, ">$outfile";
|
||||
my $flag = 0;
|
||||
while (<IN>) {
|
||||
$flag = 1 if (/^-----BEGIN.*$bound/) ;
|
||||
print OUT $_ if ($flag);
|
||||
if (/^-----END.*$bound/) {
|
||||
close IN;
|
||||
close OUT;
|
||||
return;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -1,198 +0,0 @@
|
||||
#!/bin/sh
|
||||
#
|
||||
# CA - wrapper around ca to make it easier to use ... basically ca requires
|
||||
# some setup stuff to be done before you can use it and this makes
|
||||
# things easier between now and when Eric is convinced to fix it :-)
|
||||
#
|
||||
# CA -newca ... will setup the right stuff
|
||||
# CA -newreq ... will generate a certificate request
|
||||
# CA -sign ... will sign the generated request and output
|
||||
#
|
||||
# At the end of that grab newreq.pem and newcert.pem (one has the key
|
||||
# and the other the certificate) and cat them together and that is what
|
||||
# you want/need ... I'll make even this a little cleaner later.
|
||||
#
|
||||
#
|
||||
# 12-Jan-96 tjh Added more things ... including CA -signcert which
|
||||
# converts a certificate to a request and then signs it.
|
||||
# 10-Jan-96 eay Fixed a few more bugs and added the SSLEAY_CONFIG
|
||||
# environment variable so this can be driven from
|
||||
# a script.
|
||||
# 25-Jul-96 eay Cleaned up filenames some more.
|
||||
# 11-Jun-96 eay Fixed a few filename missmatches.
|
||||
# 03-May-96 eay Modified to use 'ssleay cmd' instead of 'cmd'.
|
||||
# 18-Apr-96 tjh Original hacking
|
||||
#
|
||||
# Tim Hudson
|
||||
# tjh@cryptsoft.com
|
||||
#
|
||||
|
||||
# default openssl.cnf file has setup as per the following
|
||||
# demoCA ... where everything is stored
|
||||
cp_pem() {
|
||||
infile=$1
|
||||
outfile=$2
|
||||
bound=$3
|
||||
flag=0
|
||||
exec <$infile;
|
||||
while read line; do
|
||||
if [ $flag -eq 1 ]; then
|
||||
echo $line|grep "^-----END.*$bound" 2>/dev/null 1>/dev/null
|
||||
if [ $? -eq 0 ] ; then
|
||||
echo $line >>$outfile
|
||||
break
|
||||
else
|
||||
echo $line >>$outfile
|
||||
fi
|
||||
fi
|
||||
|
||||
echo $line|grep "^-----BEGIN.*$bound" 2>/dev/null 1>/dev/null
|
||||
if [ $? -eq 0 ]; then
|
||||
echo $line >$outfile
|
||||
flag=1
|
||||
fi
|
||||
done
|
||||
}
|
||||
|
||||
usage() {
|
||||
echo "usage: $0 -newcert|-newreq|-newreq-nodes|-newca|-sign|-verify" >&2
|
||||
}
|
||||
|
||||
if [ -z "$OPENSSL" ]; then OPENSSL=openssl; fi
|
||||
|
||||
if [ -z "$DAYS" ] ; then DAYS="-days 365" ; fi # 1 year
|
||||
CADAYS="-days 1095" # 3 years
|
||||
REQ="$OPENSSL req $SSLEAY_CONFIG"
|
||||
CA="$OPENSSL ca $SSLEAY_CONFIG"
|
||||
VERIFY="$OPENSSL verify"
|
||||
X509="$OPENSSL x509"
|
||||
PKCS12="openssl pkcs12"
|
||||
|
||||
if [ -z "$CATOP" ] ; then CATOP=./demoCA ; fi
|
||||
CAKEY=./cakey.pem
|
||||
CAREQ=./careq.pem
|
||||
CACERT=./cacert.pem
|
||||
|
||||
RET=0
|
||||
|
||||
while [ "$1" != "" ] ; do
|
||||
case $1 in
|
||||
-\?|-h|-help)
|
||||
usage
|
||||
exit 0
|
||||
;;
|
||||
-newcert)
|
||||
# create a certificate
|
||||
$REQ -new -x509 -keyout newkey.pem -out newcert.pem $DAYS
|
||||
RET=$?
|
||||
echo "Certificate is in newcert.pem, private key is in newkey.pem"
|
||||
;;
|
||||
-newreq)
|
||||
# create a certificate request
|
||||
$REQ -new -keyout newkey.pem -out newreq.pem $DAYS
|
||||
RET=$?
|
||||
echo "Request is in newreq.pem, private key is in newkey.pem"
|
||||
;;
|
||||
-newreq-nodes)
|
||||
# create a certificate request
|
||||
$REQ -new -nodes -keyout newreq.pem -out newreq.pem $DAYS
|
||||
RET=$?
|
||||
echo "Request (and private key) is in newreq.pem"
|
||||
;;
|
||||
-newca)
|
||||
# if explicitly asked for or it doesn't exist then setup the directory
|
||||
# structure that Eric likes to manage things
|
||||
NEW="1"
|
||||
if [ "$NEW" -o ! -f ${CATOP}/serial ]; then
|
||||
# create the directory hierarchy
|
||||
mkdir -p ${CATOP}
|
||||
mkdir -p ${CATOP}/certs
|
||||
mkdir -p ${CATOP}/crl
|
||||
mkdir -p ${CATOP}/newcerts
|
||||
mkdir -p ${CATOP}/private
|
||||
touch ${CATOP}/index.txt
|
||||
fi
|
||||
if [ ! -f ${CATOP}/private/$CAKEY ]; then
|
||||
echo "CA certificate filename (or enter to create)"
|
||||
read FILE
|
||||
|
||||
# ask user for existing CA certificate
|
||||
if [ "$FILE" ]; then
|
||||
cp_pem $FILE ${CATOP}/private/$CAKEY PRIVATE
|
||||
cp_pem $FILE ${CATOP}/$CACERT CERTIFICATE
|
||||
RET=$?
|
||||
if [ ! -f "${CATOP}/serial" ]; then
|
||||
$X509 -in ${CATOP}/$CACERT -noout -next_serial \
|
||||
-out ${CATOP}/serial
|
||||
fi
|
||||
else
|
||||
echo "Making CA certificate ..."
|
||||
$REQ -new -keyout ${CATOP}/private/$CAKEY \
|
||||
-out ${CATOP}/$CAREQ
|
||||
$CA -create_serial -out ${CATOP}/$CACERT $CADAYS -batch \
|
||||
-keyfile ${CATOP}/private/$CAKEY -selfsign \
|
||||
-extensions v3_ca \
|
||||
-infiles ${CATOP}/$CAREQ
|
||||
RET=$?
|
||||
fi
|
||||
fi
|
||||
;;
|
||||
-xsign)
|
||||
$CA -policy policy_anything -infiles newreq.pem
|
||||
RET=$?
|
||||
;;
|
||||
-pkcs12)
|
||||
if [ -z "$2" ] ; then
|
||||
CNAME="My Certificate"
|
||||
else
|
||||
CNAME="$2"
|
||||
fi
|
||||
$PKCS12 -in newcert.pem -inkey newreq.pem -certfile ${CATOP}/$CACERT \
|
||||
-out newcert.p12 -export -name "$CNAME"
|
||||
RET=$?
|
||||
exit $RET
|
||||
;;
|
||||
-sign|-signreq)
|
||||
$CA -policy policy_anything -out newcert.pem -infiles newreq.pem
|
||||
RET=$?
|
||||
cat newcert.pem
|
||||
echo "Signed certificate is in newcert.pem"
|
||||
;;
|
||||
-signCA)
|
||||
$CA -policy policy_anything -out newcert.pem -extensions v3_ca -infiles newreq.pem
|
||||
RET=$?
|
||||
echo "Signed CA certificate is in newcert.pem"
|
||||
;;
|
||||
-signcert)
|
||||
echo "Cert passphrase will be requested twice - bug?"
|
||||
$X509 -x509toreq -in newreq.pem -signkey newreq.pem -out tmp.pem
|
||||
$CA -policy policy_anything -out newcert.pem -infiles tmp.pem
|
||||
RET=$?
|
||||
cat newcert.pem
|
||||
echo "Signed certificate is in newcert.pem"
|
||||
;;
|
||||
-verify)
|
||||
shift
|
||||
if [ -z "$1" ]; then
|
||||
$VERIFY -CAfile $CATOP/$CACERT newcert.pem
|
||||
RET=$?
|
||||
else
|
||||
for j
|
||||
do
|
||||
$VERIFY -CAfile $CATOP/$CACERT $j
|
||||
if [ $? != 0 ]; then
|
||||
RET=$?
|
||||
fi
|
||||
done
|
||||
fi
|
||||
exit $RET
|
||||
;;
|
||||
*)
|
||||
echo "Unknown arg $i" >&2
|
||||
usage
|
||||
exit 1
|
||||
;;
|
||||
esac
|
||||
shift
|
||||
done
|
||||
exit $RET
|
File diff suppressed because it is too large
Load Diff
@ -1,217 +1,94 @@
|
||||
/* apps/app_rand.c */
|
||||
/* Copyright (C) 1995-1998 Eric Young (eay@cryptsoft.com)
|
||||
* All rights reserved.
|
||||
*
|
||||
* This package is an SSL implementation written
|
||||
* by Eric Young (eay@cryptsoft.com).
|
||||
* The implementation was written so as to conform with Netscapes SSL.
|
||||
*
|
||||
* This library is free for commercial and non-commercial use as long as
|
||||
* the following conditions are aheared to. The following conditions
|
||||
* apply to all code found in this distribution, be it the RC4, RSA,
|
||||
* lhash, DES, etc., code; not just the SSL code. The SSL documentation
|
||||
* included with this distribution is covered by the same copyright terms
|
||||
* except that the holder is Tim Hudson (tjh@cryptsoft.com).
|
||||
*
|
||||
* Copyright remains Eric Young's, and as such any Copyright notices in
|
||||
* the code are not to be removed.
|
||||
* If this package is used in a product, Eric Young should be given attribution
|
||||
* as the author of the parts of the library used.
|
||||
* This can be in the form of a textual message at program startup or
|
||||
* in documentation (online or textual) provided with the package.
|
||||
*
|
||||
* Redistribution and use in source and binary forms, with or without
|
||||
* modification, are permitted provided that the following conditions
|
||||
* are met:
|
||||
* 1. Redistributions of source code must retain the copyright
|
||||
* notice, this list of conditions and the following disclaimer.
|
||||
* 2. Redistributions in binary form must reproduce the above copyright
|
||||
* notice, this list of conditions and the following disclaimer in the
|
||||
* documentation and/or other materials provided with the distribution.
|
||||
* 3. All advertising materials mentioning features or use of this software
|
||||
* must display the following acknowledgement:
|
||||
* "This product includes cryptographic software written by
|
||||
* Eric Young (eay@cryptsoft.com)"
|
||||
* The word 'cryptographic' can be left out if the rouines from the library
|
||||
* being used are not cryptographic related :-).
|
||||
* 4. If you include any Windows specific code (or a derivative thereof) from
|
||||
* the apps directory (application code) you must include an acknowledgement:
|
||||
* "This product includes software written by Tim Hudson (tjh@cryptsoft.com)"
|
||||
*
|
||||
* THIS SOFTWARE IS PROVIDED BY ERIC YOUNG ``AS IS'' AND
|
||||
* ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
|
||||
* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
|
||||
* ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE
|
||||
* FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
|
||||
* DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
|
||||
* OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
|
||||
* HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
|
||||
* LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
|
||||
* OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
|
||||
* SUCH DAMAGE.
|
||||
*
|
||||
* The licence and distribution terms for any publically available version or
|
||||
* derivative of this code cannot be changed. i.e. this code cannot simply be
|
||||
* copied and put under another distribution licence
|
||||
* [including the GNU Public Licence.]
|
||||
*/
|
||||
/* ====================================================================
|
||||
* Copyright (c) 1998-2000 The OpenSSL Project. All rights reserved.
|
||||
*
|
||||
* Redistribution and use in source and binary forms, with or without
|
||||
* modification, are permitted provided that the following conditions
|
||||
* are met:
|
||||
*
|
||||
* 1. Redistributions of source code must retain the above copyright
|
||||
* notice, this list of conditions and the following disclaimer.
|
||||
*
|
||||
* 2. Redistributions in binary form must reproduce the above copyright
|
||||
* notice, this list of conditions and the following disclaimer in
|
||||
* the documentation and/or other materials provided with the
|
||||
* distribution.
|
||||
*
|
||||
* 3. All advertising materials mentioning features or use of this
|
||||
* software must display the following acknowledgment:
|
||||
* "This product includes software developed by the OpenSSL Project
|
||||
* for use in the OpenSSL Toolkit. (http://www.openssl.org/)"
|
||||
*
|
||||
* 4. The names "OpenSSL Toolkit" and "OpenSSL Project" must not be used to
|
||||
* endorse or promote products derived from this software without
|
||||
* prior written permission. For written permission, please contact
|
||||
* openssl-core@openssl.org.
|
||||
*
|
||||
* 5. Products derived from this software may not be called "OpenSSL"
|
||||
* nor may "OpenSSL" appear in their names without prior written
|
||||
* permission of the OpenSSL Project.
|
||||
*
|
||||
* 6. Redistributions of any form whatsoever must retain the following
|
||||
* acknowledgment:
|
||||
* "This product includes software developed by the OpenSSL Project
|
||||
* for use in the OpenSSL Toolkit (http://www.openssl.org/)"
|
||||
*
|
||||
* THIS SOFTWARE IS PROVIDED BY THE OpenSSL PROJECT ``AS IS'' AND ANY
|
||||
* EXPRESSED OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
|
||||
* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
|
||||
* PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE OpenSSL PROJECT OR
|
||||
* ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
|
||||
* SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
|
||||
* NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
|
||||
* LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
|
||||
* HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT,
|
||||
* STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
|
||||
* ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED
|
||||
* OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
* ====================================================================
|
||||
*
|
||||
* This product includes cryptographic software written by Eric Young
|
||||
* (eay@cryptsoft.com). This product includes software written by Tim
|
||||
* Hudson (tjh@cryptsoft.com).
|
||||
/*
|
||||
* Copyright 1995-2017 The OpenSSL Project Authors. All Rights Reserved.
|
||||
*
|
||||
* Licensed under the OpenSSL license (the "License"). You may not use
|
||||
* this file except in compliance with the License. You can obtain a copy
|
||||
* in the file LICENSE in the source distribution or at
|
||||
* https://www.openssl.org/source/license.html
|
||||
*/
|
||||
|
||||
#define NON_MAIN
|
||||
#include "apps.h"
|
||||
#undef NON_MAIN
|
||||
#include <openssl/bio.h>
|
||||
#include <openssl/err.h>
|
||||
#include <openssl/rand.h>
|
||||
#include <openssl/conf.h>
|
||||
|
||||
static int seeded = 0;
|
||||
static int egdsocket = 0;
|
||||
static char *save_rand_file;
|
||||
|
||||
int app_RAND_load_file(const char *file, BIO *bio_e, int dont_warn)
|
||||
void app_RAND_load_conf(CONF *c, const char *section)
|
||||
{
|
||||
int consider_randfile = (file == NULL);
|
||||
char buffer[200];
|
||||
const char *randfile = NCONF_get_string(c, section, "RANDFILE");
|
||||
|
||||
#ifdef OPENSSL_SYS_WINDOWS
|
||||
RAND_screen();
|
||||
#endif
|
||||
|
||||
if (file == NULL)
|
||||
file = RAND_file_name(buffer, sizeof(buffer));
|
||||
else if (RAND_egd(file) > 0) {
|
||||
/*
|
||||
* we try if the given filename is an EGD socket. if it is, we don't
|
||||
* write anything back to the file.
|
||||
*/
|
||||
egdsocket = 1;
|
||||
return 1;
|
||||
if (randfile == NULL) {
|
||||
ERR_clear_error();
|
||||
return;
|
||||
}
|
||||
if (file == NULL || !RAND_load_file(file, -1)) {
|
||||
if (RAND_status() == 0) {
|
||||
if (!dont_warn) {
|
||||
BIO_printf(bio_e, "unable to load 'random state'\n");
|
||||
BIO_printf(bio_e,
|
||||
"This means that the random number generator has not been seeded\n");
|
||||
BIO_printf(bio_e, "with much random data.\n");
|
||||
if (consider_randfile) { /* explanation does not apply when a
|
||||
* file is explicitly named */
|
||||
BIO_printf(bio_e,
|
||||
"Consider setting the RANDFILE environment variable to point at a file that\n");
|
||||
BIO_printf(bio_e,
|
||||
"'random' data can be kept in (the file will be overwritten).\n");
|
||||
}
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
if (RAND_load_file(randfile, -1) < 0) {
|
||||
BIO_printf(bio_err, "Can't load %s into RNG\n", randfile);
|
||||
ERR_print_errors(bio_err);
|
||||
return;
|
||||
}
|
||||
seeded = 1;
|
||||
return 1;
|
||||
if (save_rand_file == NULL)
|
||||
save_rand_file = OPENSSL_strdup(randfile);
|
||||
}
|
||||
|
||||
long app_RAND_load_files(char *name)
|
||||
static int loadfiles(char *name)
|
||||
{
|
||||
char *p, *n;
|
||||
int last;
|
||||
long tot = 0;
|
||||
int egd;
|
||||
char *p;
|
||||
int last, ret = 1;
|
||||
|
||||
for (;;) {
|
||||
for ( ; ; ) {
|
||||
last = 0;
|
||||
for (p = name; ((*p != '\0') && (*p != LIST_SEPARATOR_CHAR)); p++) ;
|
||||
for (p = name; *p != '\0' && *p != LIST_SEPARATOR_CHAR; p++)
|
||||
continue;
|
||||
if (*p == '\0')
|
||||
last = 1;
|
||||
*p = '\0';
|
||||
n = name;
|
||||
name = p + 1;
|
||||
if (*n == '\0')
|
||||
break;
|
||||
|
||||
egd = RAND_egd(n);
|
||||
if (egd > 0)
|
||||
tot += egd;
|
||||
else
|
||||
tot += RAND_load_file(n, -1);
|
||||
if (RAND_load_file(name, -1) < 0) {
|
||||
BIO_printf(bio_err, "Can't load %s into RNG\n", name);
|
||||
ERR_print_errors(bio_err);
|
||||
ret = 0;
|
||||
}
|
||||
if (last)
|
||||
break;
|
||||
name = p + 1;
|
||||
if (*name == '\0')
|
||||
break;
|
||||
}
|
||||
if (tot > 512)
|
||||
app_RAND_allow_write_file();
|
||||
return (tot);
|
||||
return ret;
|
||||
}
|
||||
|
||||
int app_RAND_write_file(const char *file, BIO *bio_e)
|
||||
void app_RAND_write(void)
|
||||
{
|
||||
char buffer[200];
|
||||
if (save_rand_file == NULL)
|
||||
return;
|
||||
if (RAND_write_file(save_rand_file) == -1) {
|
||||
BIO_printf(bio_err, "Cannot write random bytes:\n");
|
||||
ERR_print_errors(bio_err);
|
||||
}
|
||||
OPENSSL_free(save_rand_file);
|
||||
save_rand_file = NULL;
|
||||
}
|
||||
|
||||
if (egdsocket || !seeded)
|
||||
/*
|
||||
* If we did not manage to read the seed file, we should not write a
|
||||
* low-entropy seed file back -- it would suppress a crucial warning
|
||||
* the next time we want to use it.
|
||||
*/
|
||||
return 0;
|
||||
|
||||
if (file == NULL)
|
||||
file = RAND_file_name(buffer, sizeof(buffer));
|
||||
if (file == NULL || !RAND_write_file(file)) {
|
||||
BIO_printf(bio_e, "unable to write 'random state'\n");
|
||||
return 0;
|
||||
/*
|
||||
* See comments in opt_verify for explanation of this.
|
||||
*/
|
||||
enum r_range { OPT_R_ENUM };
|
||||
|
||||
int opt_rand(int opt)
|
||||
{
|
||||
switch ((enum r_range)opt) {
|
||||
case OPT_R__FIRST:
|
||||
case OPT_R__LAST:
|
||||
break;
|
||||
case OPT_R_RAND:
|
||||
return loadfiles(opt_arg());
|
||||
break;
|
||||
case OPT_R_WRITERAND:
|
||||
OPENSSL_free(save_rand_file);
|
||||
save_rand_file = OPENSSL_strdup(opt_arg());
|
||||
break;
|
||||
}
|
||||
return 1;
|
||||
}
|
||||
|
||||
void app_RAND_allow_write_file(void)
|
||||
{
|
||||
seeded = 1;
|
||||
}
|
||||
|
File diff suppressed because it is too large
Load Diff
@ -1,221 +1,436 @@
|
||||
/* apps/apps.h */
|
||||
/* Copyright (C) 1995-1998 Eric Young (eay@cryptsoft.com)
|
||||
* All rights reserved.
|
||||
*
|
||||
* This package is an SSL implementation written
|
||||
* by Eric Young (eay@cryptsoft.com).
|
||||
* The implementation was written so as to conform with Netscapes SSL.
|
||||
*
|
||||
* This library is free for commercial and non-commercial use as long as
|
||||
* the following conditions are aheared to. The following conditions
|
||||
* apply to all code found in this distribution, be it the RC4, RSA,
|
||||
* lhash, DES, etc., code; not just the SSL code. The SSL documentation
|
||||
* included with this distribution is covered by the same copyright terms
|
||||
* except that the holder is Tim Hudson (tjh@cryptsoft.com).
|
||||
*
|
||||
* Copyright remains Eric Young's, and as such any Copyright notices in
|
||||
* the code are not to be removed.
|
||||
* If this package is used in a product, Eric Young should be given attribution
|
||||
* as the author of the parts of the library used.
|
||||
* This can be in the form of a textual message at program startup or
|
||||
* in documentation (online or textual) provided with the package.
|
||||
*
|
||||
* Redistribution and use in source and binary forms, with or without
|
||||
* modification, are permitted provided that the following conditions
|
||||
* are met:
|
||||
* 1. Redistributions of source code must retain the copyright
|
||||
* notice, this list of conditions and the following disclaimer.
|
||||
* 2. Redistributions in binary form must reproduce the above copyright
|
||||
* notice, this list of conditions and the following disclaimer in the
|
||||
* documentation and/or other materials provided with the distribution.
|
||||
* 3. All advertising materials mentioning features or use of this software
|
||||
* must display the following acknowledgement:
|
||||
* "This product includes cryptographic software written by
|
||||
* Eric Young (eay@cryptsoft.com)"
|
||||
* The word 'cryptographic' can be left out if the rouines from the library
|
||||
* being used are not cryptographic related :-).
|
||||
* 4. If you include any Windows specific code (or a derivative thereof) from
|
||||
* the apps directory (application code) you must include an acknowledgement:
|
||||
* "This product includes software written by Tim Hudson (tjh@cryptsoft.com)"
|
||||
*
|
||||
* THIS SOFTWARE IS PROVIDED BY ERIC YOUNG ``AS IS'' AND
|
||||
* ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
|
||||
* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
|
||||
* ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE
|
||||
* FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
|
||||
* DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
|
||||
* OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
|
||||
* HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
|
||||
* LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
|
||||
* OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
|
||||
* SUCH DAMAGE.
|
||||
*
|
||||
* The licence and distribution terms for any publically available version or
|
||||
* derivative of this code cannot be changed. i.e. this code cannot simply be
|
||||
* copied and put under another distribution licence
|
||||
* [including the GNU Public Licence.]
|
||||
*/
|
||||
/* ====================================================================
|
||||
* Copyright (c) 1998-2001 The OpenSSL Project. All rights reserved.
|
||||
*
|
||||
* Redistribution and use in source and binary forms, with or without
|
||||
* modification, are permitted provided that the following conditions
|
||||
* are met:
|
||||
*
|
||||
* 1. Redistributions of source code must retain the above copyright
|
||||
* notice, this list of conditions and the following disclaimer.
|
||||
*
|
||||
* 2. Redistributions in binary form must reproduce the above copyright
|
||||
* notice, this list of conditions and the following disclaimer in
|
||||
* the documentation and/or other materials provided with the
|
||||
* distribution.
|
||||
*
|
||||
* 3. All advertising materials mentioning features or use of this
|
||||
* software must display the following acknowledgment:
|
||||
* "This product includes software developed by the OpenSSL Project
|
||||
* for use in the OpenSSL Toolkit. (http://www.openssl.org/)"
|
||||
*
|
||||
* 4. The names "OpenSSL Toolkit" and "OpenSSL Project" must not be used to
|
||||
* endorse or promote products derived from this software without
|
||||
* prior written permission. For written permission, please contact
|
||||
* openssl-core@openssl.org.
|
||||
*
|
||||
* 5. Products derived from this software may not be called "OpenSSL"
|
||||
* nor may "OpenSSL" appear in their names without prior written
|
||||
* permission of the OpenSSL Project.
|
||||
*
|
||||
* 6. Redistributions of any form whatsoever must retain the following
|
||||
* acknowledgment:
|
||||
* "This product includes software developed by the OpenSSL Project
|
||||
* for use in the OpenSSL Toolkit (http://www.openssl.org/)"
|
||||
*
|
||||
* THIS SOFTWARE IS PROVIDED BY THE OpenSSL PROJECT ``AS IS'' AND ANY
|
||||
* EXPRESSED OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
|
||||
* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
|
||||
* PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE OpenSSL PROJECT OR
|
||||
* ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
|
||||
* SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
|
||||
* NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
|
||||
* LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
|
||||
* HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT,
|
||||
* STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
|
||||
* ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED
|
||||
* OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
* ====================================================================
|
||||
*
|
||||
* This product includes cryptographic software written by Eric Young
|
||||
* (eay@cryptsoft.com). This product includes software written by Tim
|
||||
* Hudson (tjh@cryptsoft.com).
|
||||
/*
|
||||
* Copyright 1995-2018 The OpenSSL Project Authors. All Rights Reserved.
|
||||
*
|
||||
* Licensed under the OpenSSL license (the "License"). You may not use
|
||||
* this file except in compliance with the License. You can obtain a copy
|
||||
* in the file LICENSE in the source distribution or at
|
||||
* https://www.openssl.org/source/license.html
|
||||
*/
|
||||
|
||||
#ifndef HEADER_APPS_H
|
||||
# define HEADER_APPS_H
|
||||
|
||||
# include "e_os.h"
|
||||
# include "e_os.h" /* struct timeval for DTLS */
|
||||
# include "internal/nelem.h"
|
||||
# include <assert.h>
|
||||
|
||||
# include <sys/types.h>
|
||||
# ifndef OPENSSL_NO_POSIX_IO
|
||||
# include <sys/stat.h>
|
||||
# include <fcntl.h>
|
||||
# endif
|
||||
|
||||
# include <openssl/e_os2.h>
|
||||
# include <openssl/ossl_typ.h>
|
||||
# include <openssl/bio.h>
|
||||
# include <openssl/x509.h>
|
||||
# include <openssl/lhash.h>
|
||||
# include <openssl/conf.h>
|
||||
# include <openssl/txt_db.h>
|
||||
# ifndef OPENSSL_NO_ENGINE
|
||||
# include <openssl/engine.h>
|
||||
# endif
|
||||
# ifndef OPENSSL_NO_OCSP
|
||||
# include <openssl/ocsp.h>
|
||||
# endif
|
||||
# include <openssl/ossl_typ.h>
|
||||
# include <openssl/engine.h>
|
||||
# include <openssl/ocsp.h>
|
||||
# include <signal.h>
|
||||
|
||||
int app_RAND_load_file(const char *file, BIO *bio_e, int dont_warn);
|
||||
int app_RAND_write_file(const char *file, BIO *bio_e);
|
||||
/*
|
||||
* When `file' is NULL, use defaults. `bio_e' is for error messages.
|
||||
*/
|
||||
void app_RAND_allow_write_file(void);
|
||||
long app_RAND_load_files(char *file); /* `file' is a list of files to read,
|
||||
* separated by LIST_SEPARATOR_CHAR
|
||||
* (see e_os.h). The string is
|
||||
* destroyed! */
|
||||
|
||||
# ifndef MONOLITH
|
||||
|
||||
# define MAIN(a,v) main(a,v)
|
||||
|
||||
# ifndef NON_MAIN
|
||||
CONF *config = NULL;
|
||||
BIO *bio_err = NULL;
|
||||
# else
|
||||
extern CONF *config;
|
||||
extern BIO *bio_err;
|
||||
# endif
|
||||
|
||||
# else
|
||||
|
||||
# define MAIN(a,v) PROG(a,v)
|
||||
extern CONF *config;
|
||||
extern char *default_config_file;
|
||||
extern BIO *bio_err;
|
||||
|
||||
# endif
|
||||
|
||||
# ifndef OPENSSL_SYS_NETWARE
|
||||
# include <signal.h>
|
||||
# endif
|
||||
|
||||
# ifdef SIGPIPE
|
||||
# define do_pipe_sig() signal(SIGPIPE,SIG_IGN)
|
||||
# else
|
||||
# define do_pipe_sig()
|
||||
# endif
|
||||
|
||||
# ifdef OPENSSL_NO_COMP
|
||||
# define zlib_cleanup()
|
||||
# else
|
||||
# define zlib_cleanup() COMP_zlib_cleanup()
|
||||
# endif
|
||||
|
||||
# if defined(MONOLITH) && !defined(OPENSSL_C)
|
||||
# define apps_startup() \
|
||||
do_pipe_sig()
|
||||
# define apps_shutdown()
|
||||
# else
|
||||
# ifndef OPENSSL_NO_ENGINE
|
||||
# define apps_startup() \
|
||||
do { do_pipe_sig(); CRYPTO_malloc_init(); \
|
||||
ERR_load_crypto_strings(); OpenSSL_add_all_algorithms(); \
|
||||
ENGINE_load_builtin_engines(); setup_ui_method(); } while(0)
|
||||
# define apps_shutdown() \
|
||||
do { CONF_modules_unload(1); destroy_ui_method(); \
|
||||
OBJ_cleanup(); EVP_cleanup(); ENGINE_cleanup(); \
|
||||
CRYPTO_cleanup_all_ex_data(); ERR_remove_thread_state(NULL); \
|
||||
RAND_cleanup(); \
|
||||
ERR_free_strings(); zlib_cleanup();} while(0)
|
||||
# else
|
||||
# define apps_startup() \
|
||||
do { do_pipe_sig(); CRYPTO_malloc_init(); \
|
||||
ERR_load_crypto_strings(); OpenSSL_add_all_algorithms(); \
|
||||
setup_ui_method(); } while(0)
|
||||
# define apps_shutdown() \
|
||||
do { CONF_modules_unload(1); destroy_ui_method(); \
|
||||
OBJ_cleanup(); EVP_cleanup(); \
|
||||
CRYPTO_cleanup_all_ex_data(); ERR_remove_thread_state(NULL); \
|
||||
RAND_cleanup(); \
|
||||
ERR_free_strings(); zlib_cleanup(); } while(0)
|
||||
# endif
|
||||
# endif
|
||||
|
||||
# if defined(OPENSSL_SYSNAME_WIN32) || defined(OPENSSL_SYSNAME_WINCE)
|
||||
# if defined(OPENSSL_SYS_WIN32) || defined(OPENSSL_SYS_WINCE)
|
||||
# define openssl_fdset(a,b) FD_SET((unsigned int)a, b)
|
||||
# else
|
||||
# define openssl_fdset(a,b) FD_SET(a, b)
|
||||
# endif
|
||||
|
||||
/*
|
||||
* quick macro when you need to pass an unsigned char instead of a char.
|
||||
* this is true for some implementations of the is*() functions, for
|
||||
* example.
|
||||
*/
|
||||
#define _UC(c) ((unsigned char)(c))
|
||||
|
||||
void app_RAND_load_conf(CONF *c, const char *section);
|
||||
void app_RAND_write(void);
|
||||
|
||||
extern char *default_config_file;
|
||||
extern BIO *bio_in;
|
||||
extern BIO *bio_out;
|
||||
extern BIO *bio_err;
|
||||
extern const unsigned char tls13_aes128gcmsha256_id[];
|
||||
extern const unsigned char tls13_aes256gcmsha384_id[];
|
||||
extern BIO_ADDR *ourpeer;
|
||||
|
||||
BIO_METHOD *apps_bf_prefix(void);
|
||||
/*
|
||||
* The control used to set the prefix with BIO_ctrl()
|
||||
* We make it high enough so the chance of ever clashing with the BIO library
|
||||
* remains unlikely for the foreseeable future and beyond.
|
||||
*/
|
||||
#define PREFIX_CTRL_SET_PREFIX (1 << 15)
|
||||
/*
|
||||
* apps_bf_prefix() returns a dynamically created BIO_METHOD, which we
|
||||
* need to destroy at some point. When created internally, it's stored
|
||||
* in an internal pointer which can be freed with the following function
|
||||
*/
|
||||
void destroy_prefix_method(void);
|
||||
|
||||
BIO *dup_bio_in(int format);
|
||||
BIO *dup_bio_out(int format);
|
||||
BIO *dup_bio_err(int format);
|
||||
BIO *bio_open_owner(const char *filename, int format, int private);
|
||||
BIO *bio_open_default(const char *filename, char mode, int format);
|
||||
BIO *bio_open_default_quiet(const char *filename, char mode, int format);
|
||||
CONF *app_load_config_bio(BIO *in, const char *filename);
|
||||
CONF *app_load_config(const char *filename);
|
||||
CONF *app_load_config_quiet(const char *filename);
|
||||
int app_load_modules(const CONF *config);
|
||||
void unbuffer(FILE *fp);
|
||||
void wait_for_async(SSL *s);
|
||||
# if defined(OPENSSL_SYS_MSDOS)
|
||||
int has_stdin_waiting(void);
|
||||
# endif
|
||||
|
||||
void corrupt_signature(const ASN1_STRING *signature);
|
||||
int set_cert_times(X509 *x, const char *startdate, const char *enddate,
|
||||
int days);
|
||||
|
||||
/*
|
||||
* Common verification options.
|
||||
*/
|
||||
# define OPT_V_ENUM \
|
||||
OPT_V__FIRST=2000, \
|
||||
OPT_V_POLICY, OPT_V_PURPOSE, OPT_V_VERIFY_NAME, OPT_V_VERIFY_DEPTH, \
|
||||
OPT_V_ATTIME, OPT_V_VERIFY_HOSTNAME, OPT_V_VERIFY_EMAIL, \
|
||||
OPT_V_VERIFY_IP, OPT_V_IGNORE_CRITICAL, OPT_V_ISSUER_CHECKS, \
|
||||
OPT_V_CRL_CHECK, OPT_V_CRL_CHECK_ALL, OPT_V_POLICY_CHECK, \
|
||||
OPT_V_EXPLICIT_POLICY, OPT_V_INHIBIT_ANY, OPT_V_INHIBIT_MAP, \
|
||||
OPT_V_X509_STRICT, OPT_V_EXTENDED_CRL, OPT_V_USE_DELTAS, \
|
||||
OPT_V_POLICY_PRINT, OPT_V_CHECK_SS_SIG, OPT_V_TRUSTED_FIRST, \
|
||||
OPT_V_SUITEB_128_ONLY, OPT_V_SUITEB_128, OPT_V_SUITEB_192, \
|
||||
OPT_V_PARTIAL_CHAIN, OPT_V_NO_ALT_CHAINS, OPT_V_NO_CHECK_TIME, \
|
||||
OPT_V_VERIFY_AUTH_LEVEL, OPT_V_ALLOW_PROXY_CERTS, \
|
||||
OPT_V__LAST
|
||||
|
||||
# define OPT_V_OPTIONS \
|
||||
{ "policy", OPT_V_POLICY, 's', "adds policy to the acceptable policy set"}, \
|
||||
{ "purpose", OPT_V_PURPOSE, 's', \
|
||||
"certificate chain purpose"}, \
|
||||
{ "verify_name", OPT_V_VERIFY_NAME, 's', "verification policy name"}, \
|
||||
{ "verify_depth", OPT_V_VERIFY_DEPTH, 'n', \
|
||||
"chain depth limit" }, \
|
||||
{ "auth_level", OPT_V_VERIFY_AUTH_LEVEL, 'n', \
|
||||
"chain authentication security level" }, \
|
||||
{ "attime", OPT_V_ATTIME, 'M', "verification epoch time" }, \
|
||||
{ "verify_hostname", OPT_V_VERIFY_HOSTNAME, 's', \
|
||||
"expected peer hostname" }, \
|
||||
{ "verify_email", OPT_V_VERIFY_EMAIL, 's', \
|
||||
"expected peer email" }, \
|
||||
{ "verify_ip", OPT_V_VERIFY_IP, 's', \
|
||||
"expected peer IP address" }, \
|
||||
{ "ignore_critical", OPT_V_IGNORE_CRITICAL, '-', \
|
||||
"permit unhandled critical extensions"}, \
|
||||
{ "issuer_checks", OPT_V_ISSUER_CHECKS, '-', "(deprecated)"}, \
|
||||
{ "crl_check", OPT_V_CRL_CHECK, '-', "check leaf certificate revocation" }, \
|
||||
{ "crl_check_all", OPT_V_CRL_CHECK_ALL, '-', "check full chain revocation" }, \
|
||||
{ "policy_check", OPT_V_POLICY_CHECK, '-', "perform rfc5280 policy checks"}, \
|
||||
{ "explicit_policy", OPT_V_EXPLICIT_POLICY, '-', \
|
||||
"set policy variable require-explicit-policy"}, \
|
||||
{ "inhibit_any", OPT_V_INHIBIT_ANY, '-', \
|
||||
"set policy variable inhibit-any-policy"}, \
|
||||
{ "inhibit_map", OPT_V_INHIBIT_MAP, '-', \
|
||||
"set policy variable inhibit-policy-mapping"}, \
|
||||
{ "x509_strict", OPT_V_X509_STRICT, '-', \
|
||||
"disable certificate compatibility work-arounds"}, \
|
||||
{ "extended_crl", OPT_V_EXTENDED_CRL, '-', \
|
||||
"enable extended CRL features"}, \
|
||||
{ "use_deltas", OPT_V_USE_DELTAS, '-', \
|
||||
"use delta CRLs"}, \
|
||||
{ "policy_print", OPT_V_POLICY_PRINT, '-', \
|
||||
"print policy processing diagnostics"}, \
|
||||
{ "check_ss_sig", OPT_V_CHECK_SS_SIG, '-', \
|
||||
"check root CA self-signatures"}, \
|
||||
{ "trusted_first", OPT_V_TRUSTED_FIRST, '-', \
|
||||
"search trust store first (default)" }, \
|
||||
{ "suiteB_128_only", OPT_V_SUITEB_128_ONLY, '-', "Suite B 128-bit-only mode"}, \
|
||||
{ "suiteB_128", OPT_V_SUITEB_128, '-', \
|
||||
"Suite B 128-bit mode allowing 192-bit algorithms"}, \
|
||||
{ "suiteB_192", OPT_V_SUITEB_192, '-', "Suite B 192-bit-only mode" }, \
|
||||
{ "partial_chain", OPT_V_PARTIAL_CHAIN, '-', \
|
||||
"accept chains anchored by intermediate trust-store CAs"}, \
|
||||
{ "no_alt_chains", OPT_V_NO_ALT_CHAINS, '-', "(deprecated)" }, \
|
||||
{ "no_check_time", OPT_V_NO_CHECK_TIME, '-', "ignore certificate validity time" }, \
|
||||
{ "allow_proxy_certs", OPT_V_ALLOW_PROXY_CERTS, '-', "allow the use of proxy certificates" }
|
||||
|
||||
# define OPT_V_CASES \
|
||||
OPT_V__FIRST: case OPT_V__LAST: break; \
|
||||
case OPT_V_POLICY: \
|
||||
case OPT_V_PURPOSE: \
|
||||
case OPT_V_VERIFY_NAME: \
|
||||
case OPT_V_VERIFY_DEPTH: \
|
||||
case OPT_V_VERIFY_AUTH_LEVEL: \
|
||||
case OPT_V_ATTIME: \
|
||||
case OPT_V_VERIFY_HOSTNAME: \
|
||||
case OPT_V_VERIFY_EMAIL: \
|
||||
case OPT_V_VERIFY_IP: \
|
||||
case OPT_V_IGNORE_CRITICAL: \
|
||||
case OPT_V_ISSUER_CHECKS: \
|
||||
case OPT_V_CRL_CHECK: \
|
||||
case OPT_V_CRL_CHECK_ALL: \
|
||||
case OPT_V_POLICY_CHECK: \
|
||||
case OPT_V_EXPLICIT_POLICY: \
|
||||
case OPT_V_INHIBIT_ANY: \
|
||||
case OPT_V_INHIBIT_MAP: \
|
||||
case OPT_V_X509_STRICT: \
|
||||
case OPT_V_EXTENDED_CRL: \
|
||||
case OPT_V_USE_DELTAS: \
|
||||
case OPT_V_POLICY_PRINT: \
|
||||
case OPT_V_CHECK_SS_SIG: \
|
||||
case OPT_V_TRUSTED_FIRST: \
|
||||
case OPT_V_SUITEB_128_ONLY: \
|
||||
case OPT_V_SUITEB_128: \
|
||||
case OPT_V_SUITEB_192: \
|
||||
case OPT_V_PARTIAL_CHAIN: \
|
||||
case OPT_V_NO_ALT_CHAINS: \
|
||||
case OPT_V_NO_CHECK_TIME: \
|
||||
case OPT_V_ALLOW_PROXY_CERTS
|
||||
|
||||
/*
|
||||
* Common "extended validation" options.
|
||||
*/
|
||||
# define OPT_X_ENUM \
|
||||
OPT_X__FIRST=1000, \
|
||||
OPT_X_KEY, OPT_X_CERT, OPT_X_CHAIN, OPT_X_CHAIN_BUILD, \
|
||||
OPT_X_CERTFORM, OPT_X_KEYFORM, \
|
||||
OPT_X__LAST
|
||||
|
||||
# define OPT_X_OPTIONS \
|
||||
{ "xkey", OPT_X_KEY, '<', "key for Extended certificates"}, \
|
||||
{ "xcert", OPT_X_CERT, '<', "cert for Extended certificates"}, \
|
||||
{ "xchain", OPT_X_CHAIN, '<', "chain for Extended certificates"}, \
|
||||
{ "xchain_build", OPT_X_CHAIN_BUILD, '-', \
|
||||
"build certificate chain for the extended certificates"}, \
|
||||
{ "xcertform", OPT_X_CERTFORM, 'F', \
|
||||
"format of Extended certificate (PEM or DER) PEM default " }, \
|
||||
{ "xkeyform", OPT_X_KEYFORM, 'F', \
|
||||
"format of Extended certificate's key (PEM or DER) PEM default"}
|
||||
|
||||
# define OPT_X_CASES \
|
||||
OPT_X__FIRST: case OPT_X__LAST: break; \
|
||||
case OPT_X_KEY: \
|
||||
case OPT_X_CERT: \
|
||||
case OPT_X_CHAIN: \
|
||||
case OPT_X_CHAIN_BUILD: \
|
||||
case OPT_X_CERTFORM: \
|
||||
case OPT_X_KEYFORM
|
||||
|
||||
/*
|
||||
* Common SSL options.
|
||||
* Any changes here must be coordinated with ../ssl/ssl_conf.c
|
||||
*/
|
||||
# define OPT_S_ENUM \
|
||||
OPT_S__FIRST=3000, \
|
||||
OPT_S_NOSSL3, OPT_S_NOTLS1, OPT_S_NOTLS1_1, OPT_S_NOTLS1_2, \
|
||||
OPT_S_NOTLS1_3, OPT_S_BUGS, OPT_S_NO_COMP, OPT_S_NOTICKET, \
|
||||
OPT_S_SERVERPREF, OPT_S_LEGACYRENEG, OPT_S_LEGACYCONN, \
|
||||
OPT_S_ONRESUMP, OPT_S_NOLEGACYCONN, OPT_S_ALLOW_NO_DHE_KEX, \
|
||||
OPT_S_PRIORITIZE_CHACHA, \
|
||||
OPT_S_STRICT, OPT_S_SIGALGS, OPT_S_CLIENTSIGALGS, OPT_S_GROUPS, \
|
||||
OPT_S_CURVES, OPT_S_NAMEDCURVE, OPT_S_CIPHER, OPT_S_CIPHERSUITES, \
|
||||
OPT_S_RECORD_PADDING, OPT_S_DEBUGBROKE, OPT_S_COMP, \
|
||||
OPT_S_MINPROTO, OPT_S_MAXPROTO, \
|
||||
OPT_S_NO_RENEGOTIATION, OPT_S_NO_MIDDLEBOX, OPT_S__LAST
|
||||
|
||||
# define OPT_S_OPTIONS \
|
||||
{"no_ssl3", OPT_S_NOSSL3, '-',"Just disable SSLv3" }, \
|
||||
{"no_tls1", OPT_S_NOTLS1, '-', "Just disable TLSv1"}, \
|
||||
{"no_tls1_1", OPT_S_NOTLS1_1, '-', "Just disable TLSv1.1" }, \
|
||||
{"no_tls1_2", OPT_S_NOTLS1_2, '-', "Just disable TLSv1.2"}, \
|
||||
{"no_tls1_3", OPT_S_NOTLS1_3, '-', "Just disable TLSv1.3"}, \
|
||||
{"bugs", OPT_S_BUGS, '-', "Turn on SSL bug compatibility"}, \
|
||||
{"no_comp", OPT_S_NO_COMP, '-', "Disable SSL/TLS compression (default)" }, \
|
||||
{"comp", OPT_S_COMP, '-', "Use SSL/TLS-level compression" }, \
|
||||
{"no_ticket", OPT_S_NOTICKET, '-', \
|
||||
"Disable use of TLS session tickets"}, \
|
||||
{"serverpref", OPT_S_SERVERPREF, '-', "Use server's cipher preferences"}, \
|
||||
{"legacy_renegotiation", OPT_S_LEGACYRENEG, '-', \
|
||||
"Enable use of legacy renegotiation (dangerous)"}, \
|
||||
{"no_renegotiation", OPT_S_NO_RENEGOTIATION, '-', \
|
||||
"Disable all renegotiation."}, \
|
||||
{"legacy_server_connect", OPT_S_LEGACYCONN, '-', \
|
||||
"Allow initial connection to servers that don't support RI"}, \
|
||||
{"no_resumption_on_reneg", OPT_S_ONRESUMP, '-', \
|
||||
"Disallow session resumption on renegotiation"}, \
|
||||
{"no_legacy_server_connect", OPT_S_NOLEGACYCONN, '-', \
|
||||
"Disallow initial connection to servers that don't support RI"}, \
|
||||
{"allow_no_dhe_kex", OPT_S_ALLOW_NO_DHE_KEX, '-', \
|
||||
"In TLSv1.3 allow non-(ec)dhe based key exchange on resumption"}, \
|
||||
{"prioritize_chacha", OPT_S_PRIORITIZE_CHACHA, '-', \
|
||||
"Prioritize ChaCha ciphers when preferred by clients"}, \
|
||||
{"strict", OPT_S_STRICT, '-', \
|
||||
"Enforce strict certificate checks as per TLS standard"}, \
|
||||
{"sigalgs", OPT_S_SIGALGS, 's', \
|
||||
"Signature algorithms to support (colon-separated list)" }, \
|
||||
{"client_sigalgs", OPT_S_CLIENTSIGALGS, 's', \
|
||||
"Signature algorithms to support for client certificate" \
|
||||
" authentication (colon-separated list)" }, \
|
||||
{"groups", OPT_S_GROUPS, 's', \
|
||||
"Groups to advertise (colon-separated list)" }, \
|
||||
{"curves", OPT_S_CURVES, 's', \
|
||||
"Groups to advertise (colon-separated list)" }, \
|
||||
{"named_curve", OPT_S_NAMEDCURVE, 's', \
|
||||
"Elliptic curve used for ECDHE (server-side only)" }, \
|
||||
{"cipher", OPT_S_CIPHER, 's', "Specify TLSv1.2 and below cipher list to be used"}, \
|
||||
{"ciphersuites", OPT_S_CIPHERSUITES, 's', "Specify TLSv1.3 ciphersuites to be used"}, \
|
||||
{"min_protocol", OPT_S_MINPROTO, 's', "Specify the minimum protocol version to be used"}, \
|
||||
{"max_protocol", OPT_S_MAXPROTO, 's', "Specify the maximum protocol version to be used"}, \
|
||||
{"record_padding", OPT_S_RECORD_PADDING, 's', \
|
||||
"Block size to pad TLS 1.3 records to."}, \
|
||||
{"debug_broken_protocol", OPT_S_DEBUGBROKE, '-', \
|
||||
"Perform all sorts of protocol violations for testing purposes"}, \
|
||||
{"no_middlebox", OPT_S_NO_MIDDLEBOX, '-', \
|
||||
"Disable TLSv1.3 middlebox compat mode" }
|
||||
|
||||
# define OPT_S_CASES \
|
||||
OPT_S__FIRST: case OPT_S__LAST: break; \
|
||||
case OPT_S_NOSSL3: \
|
||||
case OPT_S_NOTLS1: \
|
||||
case OPT_S_NOTLS1_1: \
|
||||
case OPT_S_NOTLS1_2: \
|
||||
case OPT_S_NOTLS1_3: \
|
||||
case OPT_S_BUGS: \
|
||||
case OPT_S_NO_COMP: \
|
||||
case OPT_S_COMP: \
|
||||
case OPT_S_NOTICKET: \
|
||||
case OPT_S_SERVERPREF: \
|
||||
case OPT_S_LEGACYRENEG: \
|
||||
case OPT_S_LEGACYCONN: \
|
||||
case OPT_S_ONRESUMP: \
|
||||
case OPT_S_NOLEGACYCONN: \
|
||||
case OPT_S_ALLOW_NO_DHE_KEX: \
|
||||
case OPT_S_PRIORITIZE_CHACHA: \
|
||||
case OPT_S_STRICT: \
|
||||
case OPT_S_SIGALGS: \
|
||||
case OPT_S_CLIENTSIGALGS: \
|
||||
case OPT_S_GROUPS: \
|
||||
case OPT_S_CURVES: \
|
||||
case OPT_S_NAMEDCURVE: \
|
||||
case OPT_S_CIPHER: \
|
||||
case OPT_S_CIPHERSUITES: \
|
||||
case OPT_S_RECORD_PADDING: \
|
||||
case OPT_S_NO_RENEGOTIATION: \
|
||||
case OPT_S_MINPROTO: \
|
||||
case OPT_S_MAXPROTO: \
|
||||
case OPT_S_DEBUGBROKE: \
|
||||
case OPT_S_NO_MIDDLEBOX
|
||||
|
||||
#define IS_NO_PROT_FLAG(o) \
|
||||
(o == OPT_S_NOSSL3 || o == OPT_S_NOTLS1 || o == OPT_S_NOTLS1_1 \
|
||||
|| o == OPT_S_NOTLS1_2 || o == OPT_S_NOTLS1_3)
|
||||
|
||||
/*
|
||||
* Random state options.
|
||||
*/
|
||||
# define OPT_R_ENUM \
|
||||
OPT_R__FIRST=1500, OPT_R_RAND, OPT_R_WRITERAND, OPT_R__LAST
|
||||
|
||||
# define OPT_R_OPTIONS \
|
||||
{"rand", OPT_R_RAND, 's', "Load the file(s) into the random number generator"}, \
|
||||
{"writerand", OPT_R_WRITERAND, '>', "Write random data to the specified file"}
|
||||
|
||||
# define OPT_R_CASES \
|
||||
OPT_R__FIRST: case OPT_R__LAST: break; \
|
||||
case OPT_R_RAND: case OPT_R_WRITERAND
|
||||
|
||||
/*
|
||||
* Option parsing.
|
||||
*/
|
||||
extern const char OPT_HELP_STR[];
|
||||
extern const char OPT_MORE_STR[];
|
||||
typedef struct options_st {
|
||||
const char *name;
|
||||
int retval;
|
||||
/*
|
||||
* value type: - no value (also the value zero), n number, p positive
|
||||
* number, u unsigned, l long, s string, < input file, > output file,
|
||||
* f any format, F der/pem format, E der/pem/engine format identifier.
|
||||
* l, n and u include zero; p does not.
|
||||
*/
|
||||
int valtype;
|
||||
const char *helpstr;
|
||||
} OPTIONS;
|
||||
|
||||
/*
|
||||
* A string/int pairing; widely use for option value lookup, hence the
|
||||
* name OPT_PAIR. But that name is misleading in s_cb.c, so we also use
|
||||
* the "generic" name STRINT_PAIR.
|
||||
*/
|
||||
typedef struct string_int_pair_st {
|
||||
const char *name;
|
||||
int retval;
|
||||
} OPT_PAIR, STRINT_PAIR;
|
||||
|
||||
/* Flags to pass into opt_format; see FORMAT_xxx, below. */
|
||||
# define OPT_FMT_PEMDER (1L << 1)
|
||||
# define OPT_FMT_PKCS12 (1L << 2)
|
||||
# define OPT_FMT_SMIME (1L << 3)
|
||||
# define OPT_FMT_ENGINE (1L << 4)
|
||||
# define OPT_FMT_MSBLOB (1L << 5)
|
||||
# define OPT_FMT_NETSCAPE (1L << 6)
|
||||
# define OPT_FMT_NSS (1L << 7)
|
||||
# define OPT_FMT_TEXT (1L << 8)
|
||||
# define OPT_FMT_HTTP (1L << 9)
|
||||
# define OPT_FMT_PVK (1L << 10)
|
||||
# define OPT_FMT_PDE (OPT_FMT_PEMDER | OPT_FMT_ENGINE)
|
||||
# define OPT_FMT_PDS (OPT_FMT_PEMDER | OPT_FMT_SMIME)
|
||||
# define OPT_FMT_ANY ( \
|
||||
OPT_FMT_PEMDER | OPT_FMT_PKCS12 | OPT_FMT_SMIME | \
|
||||
OPT_FMT_ENGINE | OPT_FMT_MSBLOB | OPT_FMT_NETSCAPE | \
|
||||
OPT_FMT_NSS | OPT_FMT_TEXT | OPT_FMT_HTTP | OPT_FMT_PVK)
|
||||
|
||||
char *opt_progname(const char *argv0);
|
||||
char *opt_getprog(void);
|
||||
char *opt_init(int ac, char **av, const OPTIONS * o);
|
||||
int opt_next(void);
|
||||
int opt_format(const char *s, unsigned long flags, int *result);
|
||||
int opt_int(const char *arg, int *result);
|
||||
int opt_ulong(const char *arg, unsigned long *result);
|
||||
int opt_long(const char *arg, long *result);
|
||||
#if defined(__STDC_VERSION__) && __STDC_VERSION__ >= 199901L && \
|
||||
defined(INTMAX_MAX) && defined(UINTMAX_MAX)
|
||||
int opt_imax(const char *arg, intmax_t *result);
|
||||
int opt_umax(const char *arg, uintmax_t *result);
|
||||
#else
|
||||
# define opt_imax opt_long
|
||||
# define opt_umax opt_ulong
|
||||
# define intmax_t long
|
||||
# define uintmax_t unsigned long
|
||||
#endif
|
||||
int opt_pair(const char *arg, const OPT_PAIR * pairs, int *result);
|
||||
int opt_cipher(const char *name, const EVP_CIPHER **cipherp);
|
||||
int opt_md(const char *name, const EVP_MD **mdp);
|
||||
char *opt_arg(void);
|
||||
char *opt_flag(void);
|
||||
char *opt_unknown(void);
|
||||
char **opt_rest(void);
|
||||
int opt_num_rest(void);
|
||||
int opt_verify(int i, X509_VERIFY_PARAM *vpm);
|
||||
int opt_rand(int i);
|
||||
void opt_help(const OPTIONS * list);
|
||||
int opt_format_error(const char *s, unsigned long flags);
|
||||
|
||||
typedef struct args_st {
|
||||
char **data;
|
||||
int count;
|
||||
int size;
|
||||
int argc;
|
||||
char **argv;
|
||||
} ARGS;
|
||||
|
||||
/*
|
||||
* VMS C only for now, implemented in vms_decc_init.c
|
||||
* If other C compilers forget to terminate argv with NULL, this function
|
||||
* can be re-used.
|
||||
*/
|
||||
char **copy_argv(int *argc, char *argv[]);
|
||||
/*
|
||||
* Win32-specific argv initialization that splits OS-supplied UNICODE
|
||||
* command line string to array of UTF8-encoded strings.
|
||||
*/
|
||||
void win32_utf8argv(int *argc, char **argv[]);
|
||||
|
||||
|
||||
# define PW_MIN_LENGTH 4
|
||||
typedef struct pw_cb_data {
|
||||
const void *password;
|
||||
@ -226,54 +441,63 @@ int password_callback(char *buf, int bufsiz, int verify, PW_CB_DATA *cb_data);
|
||||
|
||||
int setup_ui_method(void);
|
||||
void destroy_ui_method(void);
|
||||
const UI_METHOD *get_ui_method(void);
|
||||
|
||||
int should_retry(int i);
|
||||
int args_from_file(char *file, int *argc, char **argv[]);
|
||||
int str2fmt(char *s);
|
||||
void program_name(char *in, char *out, int size);
|
||||
int chopup_args(ARGS *arg, char *buf, int *argc, char **argv[]);
|
||||
int chopup_args(ARGS *arg, char *buf);
|
||||
# ifdef HEADER_X509_H
|
||||
int dump_cert_text(BIO *out, X509 *x);
|
||||
void print_name(BIO *out, const char *title, X509_NAME *nm,
|
||||
unsigned long lflags);
|
||||
# endif
|
||||
void print_bignum_var(BIO *, const BIGNUM *, const char*,
|
||||
int, unsigned char *);
|
||||
void print_array(BIO *, const char *, int, const unsigned char *);
|
||||
int set_nameopt(const char *arg);
|
||||
unsigned long get_nameopt(void);
|
||||
int set_cert_ex(unsigned long *flags, const char *arg);
|
||||
int set_name_ex(unsigned long *flags, const char *arg);
|
||||
int set_ext_copy(int *copy_type, const char *arg);
|
||||
int copy_extensions(X509 *x, X509_REQ *req, int copy_type);
|
||||
int app_passwd(BIO *err, char *arg1, char *arg2, char **pass1, char **pass2);
|
||||
int add_oid_section(BIO *err, CONF *conf);
|
||||
X509 *load_cert(BIO *err, const char *file, int format,
|
||||
const char *pass, ENGINE *e, const char *cert_descrip);
|
||||
int app_passwd(const char *arg1, const char *arg2, char **pass1, char **pass2);
|
||||
int add_oid_section(CONF *conf);
|
||||
X509 *load_cert(const char *file, int format, const char *cert_descrip);
|
||||
X509_CRL *load_crl(const char *infile, int format);
|
||||
int load_cert_crl_http(const char *url, BIO *err,
|
||||
X509 **pcert, X509_CRL **pcrl);
|
||||
EVP_PKEY *load_key(BIO *err, const char *file, int format, int maybe_stdin,
|
||||
EVP_PKEY *load_key(const char *file, int format, int maybe_stdin,
|
||||
const char *pass, ENGINE *e, const char *key_descrip);
|
||||
EVP_PKEY *load_pubkey(BIO *err, const char *file, int format, int maybe_stdin,
|
||||
EVP_PKEY *load_pubkey(const char *file, int format, int maybe_stdin,
|
||||
const char *pass, ENGINE *e, const char *key_descrip);
|
||||
STACK_OF(X509) *load_certs(BIO *err, const char *file, int format,
|
||||
const char *pass, ENGINE *e,
|
||||
const char *cert_descrip);
|
||||
STACK_OF(X509_CRL) *load_crls(BIO *err, const char *file, int format,
|
||||
const char *pass, ENGINE *e,
|
||||
const char *cert_descrip);
|
||||
X509_STORE *setup_verify(BIO *bp, char *CAfile, char *CApath);
|
||||
int load_certs(const char *file, STACK_OF(X509) **certs, int format,
|
||||
const char *pass, const char *cert_descrip);
|
||||
int load_crls(const char *file, STACK_OF(X509_CRL) **crls, int format,
|
||||
const char *pass, const char *cert_descrip);
|
||||
X509_STORE *setup_verify(const char *CAfile, const char *CApath,
|
||||
int noCAfile, int noCApath);
|
||||
__owur int ctx_set_verify_locations(SSL_CTX *ctx, const char *CAfile,
|
||||
const char *CApath, int noCAfile,
|
||||
int noCApath);
|
||||
|
||||
ENGINE *setup_engine(BIO *err, const char *engine, int debug);
|
||||
#ifndef OPENSSL_NO_CT
|
||||
|
||||
/*
|
||||
* Sets the file to load the Certificate Transparency log list from.
|
||||
* If path is NULL, loads from the default file path.
|
||||
* Returns 1 on success, 0 otherwise.
|
||||
*/
|
||||
__owur int ctx_set_ctlog_list_file(SSL_CTX *ctx, const char *path);
|
||||
|
||||
#endif
|
||||
|
||||
ENGINE *setup_engine(const char *engine, int debug);
|
||||
void release_engine(ENGINE *e);
|
||||
|
||||
# ifndef OPENSSL_NO_OCSP
|
||||
OCSP_RESPONSE *process_responder(BIO *err, OCSP_REQUEST *req,
|
||||
OCSP_RESPONSE *process_responder(OCSP_REQUEST *req,
|
||||
const char *host, const char *path,
|
||||
const char *port, int use_ssl,
|
||||
const STACK_OF(CONF_VALUE) *headers,
|
||||
STACK_OF(CONF_VALUE) *headers,
|
||||
int req_timeout);
|
||||
# endif
|
||||
|
||||
int load_config(BIO *err, CONF *cnf);
|
||||
char *make_config_name(void);
|
||||
|
||||
/* Functions defined in ca.c and also used in ocsp.c */
|
||||
int unpack_revinfo(ASN1_TIME **prevtm, int *preason, ASN1_OBJECT **phold,
|
||||
ASN1_GENERALIZEDTIME **pinvtm, const char *str);
|
||||
@ -287,9 +511,10 @@ int unpack_revinfo(ASN1_TIME **prevtm, int *preason, ASN1_OBJECT **phold,
|
||||
* disabled */
|
||||
# define DB_NUMBER 6
|
||||
|
||||
# define DB_TYPE_REV 'R'
|
||||
# define DB_TYPE_EXP 'E'
|
||||
# define DB_TYPE_VAL 'V'
|
||||
# define DB_TYPE_REV 'R' /* Revoked */
|
||||
# define DB_TYPE_EXP 'E' /* Expired */
|
||||
# define DB_TYPE_VAL 'V' /* Valid ; inserted with: ca ... -valid */
|
||||
# define DB_TYPE_SUSP 'S' /* Suspended */
|
||||
|
||||
typedef struct db_attr_st {
|
||||
int unique_subject;
|
||||
@ -297,14 +522,20 @@ typedef struct db_attr_st {
|
||||
typedef struct ca_db_st {
|
||||
DB_ATTR attributes;
|
||||
TXT_DB *db;
|
||||
char *dbfname;
|
||||
# ifndef OPENSSL_NO_POSIX_IO
|
||||
struct stat dbst;
|
||||
# endif
|
||||
} CA_DB;
|
||||
|
||||
BIGNUM *load_serial(char *serialfile, int create, ASN1_INTEGER **retai);
|
||||
int save_serial(char *serialfile, char *suffix, BIGNUM *serial,
|
||||
void* app_malloc(int sz, const char *what);
|
||||
BIGNUM *load_serial(const char *serialfile, int create, ASN1_INTEGER **retai);
|
||||
int save_serial(const char *serialfile, const char *suffix, const BIGNUM *serial,
|
||||
ASN1_INTEGER **retai);
|
||||
int rotate_serial(char *serialfile, char *new_suffix, char *old_suffix);
|
||||
int rotate_serial(const char *serialfile, const char *new_suffix,
|
||||
const char *old_suffix);
|
||||
int rand_serial(BIGNUM *b, ASN1_INTEGER *ai);
|
||||
CA_DB *load_index(char *dbfile, DB_ATTR *dbattr);
|
||||
CA_DB *load_index(const char *dbfile, DB_ATTR *dbattr);
|
||||
int index_index(CA_DB *db);
|
||||
int save_index(const char *dbfile, const char *suffix, CA_DB *db);
|
||||
int rotate_index(const char *dbfile, const char *new_suffix,
|
||||
@ -316,31 +547,23 @@ void free_index(CA_DB *db);
|
||||
int index_name_cmp(const OPENSSL_CSTRING *a, const OPENSSL_CSTRING *b);
|
||||
int parse_yesno(const char *str, int def);
|
||||
|
||||
X509_NAME *parse_name(char *str, long chtype, int multirdn);
|
||||
int args_verify(char ***pargs, int *pargc,
|
||||
int *badarg, BIO *err, X509_VERIFY_PARAM **pm);
|
||||
void policies_print(BIO *out, X509_STORE_CTX *ctx);
|
||||
X509_NAME *parse_name(const char *str, long chtype, int multirdn);
|
||||
void policies_print(X509_STORE_CTX *ctx);
|
||||
int bio_to_mem(unsigned char **out, int maxlen, BIO *in);
|
||||
int pkey_ctrl_string(EVP_PKEY_CTX *ctx, const char *value);
|
||||
int init_gen_str(BIO *err, EVP_PKEY_CTX **pctx,
|
||||
int init_gen_str(EVP_PKEY_CTX **pctx,
|
||||
const char *algname, ENGINE *e, int do_param);
|
||||
int do_X509_sign(BIO *err, X509 *x, EVP_PKEY *pkey, const EVP_MD *md,
|
||||
int do_X509_sign(X509 *x, EVP_PKEY *pkey, const EVP_MD *md,
|
||||
STACK_OF(OPENSSL_STRING) *sigopts);
|
||||
int do_X509_REQ_sign(BIO *err, X509_REQ *x, EVP_PKEY *pkey, const EVP_MD *md,
|
||||
int do_X509_REQ_sign(X509_REQ *x, EVP_PKEY *pkey, const EVP_MD *md,
|
||||
STACK_OF(OPENSSL_STRING) *sigopts);
|
||||
int do_X509_CRL_sign(BIO *err, X509_CRL *x, EVP_PKEY *pkey, const EVP_MD *md,
|
||||
int do_X509_CRL_sign(X509_CRL *x, EVP_PKEY *pkey, const EVP_MD *md,
|
||||
STACK_OF(OPENSSL_STRING) *sigopts);
|
||||
# ifndef OPENSSL_NO_PSK
|
||||
extern char *psk_key;
|
||||
# endif
|
||||
# ifndef OPENSSL_NO_JPAKE
|
||||
void jpake_client_auth(BIO *out, BIO *conn, const char *secret);
|
||||
void jpake_server_auth(BIO *out, BIO *conn, const char *secret);
|
||||
# endif
|
||||
|
||||
# ifndef OPENSSL_NO_TLSEXT
|
||||
unsigned char *next_protos_parse(unsigned short *outlen, const char *in);
|
||||
# endif /* ndef OPENSSL_NO_TLSEXT */
|
||||
extern char *psk_key;
|
||||
|
||||
|
||||
unsigned char *next_protos_parse(size_t *outlen, const char *in);
|
||||
|
||||
void print_cert_checks(BIO *bio, X509 *x,
|
||||
const char *checkhost,
|
||||
@ -348,21 +571,28 @@ void print_cert_checks(BIO *bio, X509 *x,
|
||||
|
||||
void store_setup_crl_download(X509_STORE *st);
|
||||
|
||||
/* See OPT_FMT_xxx, above. */
|
||||
/* On some platforms, it's important to distinguish between text and binary
|
||||
* files. On some, there might even be specific file formats for different
|
||||
* contents. The FORMAT_xxx macros are meant to express an intent with the
|
||||
* file being read or created.
|
||||
*/
|
||||
# define B_FORMAT_TEXT 0x8000
|
||||
# define FORMAT_UNDEF 0
|
||||
# define FORMAT_ASN1 1
|
||||
# define FORMAT_TEXT 2
|
||||
# define FORMAT_PEM 3
|
||||
# define FORMAT_NETSCAPE 4
|
||||
# define FORMAT_PKCS12 5
|
||||
# define FORMAT_SMIME 6
|
||||
# define FORMAT_ENGINE 7
|
||||
# define FORMAT_IISSGC 8 /* XXX this stupid macro helps us to avoid
|
||||
* adding yet another param to load_*key() */
|
||||
# define FORMAT_PEMRSA 9 /* PEM RSAPubicKey format */
|
||||
# define FORMAT_ASN1RSA 10 /* DER RSAPubicKey format */
|
||||
# define FORMAT_MSBLOB 11 /* MS Key blob format */
|
||||
# define FORMAT_PVK 12 /* MS PVK file format */
|
||||
# define FORMAT_HTTP 13 /* Download using HTTP */
|
||||
# define FORMAT_TEXT (1 | B_FORMAT_TEXT) /* Generic text */
|
||||
# define FORMAT_BINARY 2 /* Generic binary */
|
||||
# define FORMAT_BASE64 (3 | B_FORMAT_TEXT) /* Base64 */
|
||||
# define FORMAT_ASN1 4 /* ASN.1/DER */
|
||||
# define FORMAT_PEM (5 | B_FORMAT_TEXT)
|
||||
# define FORMAT_PKCS12 6
|
||||
# define FORMAT_SMIME (7 | B_FORMAT_TEXT)
|
||||
# define FORMAT_ENGINE 8 /* Not really a file format */
|
||||
# define FORMAT_PEMRSA (9 | B_FORMAT_TEXT) /* PEM RSAPubicKey format */
|
||||
# define FORMAT_ASN1RSA 10 /* DER RSAPubicKey format */
|
||||
# define FORMAT_MSBLOB 11 /* MS Key blob format */
|
||||
# define FORMAT_PVK 12 /* MS PVK file format */
|
||||
# define FORMAT_HTTP 13 /* Download using HTTP */
|
||||
# define FORMAT_NSS 14 /* NSS keylog format */
|
||||
|
||||
# define EXT_COPY_NONE 0
|
||||
# define EXT_COPY_ADD 1
|
||||
@ -372,9 +602,15 @@ void store_setup_crl_download(X509_STORE *st);
|
||||
|
||||
# define APP_PASS_LEN 1024
|
||||
|
||||
# define SERIAL_RAND_BITS 64
|
||||
/*
|
||||
* IETF RFC 5280 says serial number must be <= 20 bytes. Use 159 bits
|
||||
* so that the first bit will never be one, so that the DER encoding
|
||||
* rules won't force a leading octet.
|
||||
*/
|
||||
# define SERIAL_RAND_BITS 159
|
||||
|
||||
int app_isdir(const char *);
|
||||
int app_access(const char *, int flag);
|
||||
int fileno_stdin(void);
|
||||
int fileno_stdout(void);
|
||||
int raw_read_stdin(void *, int);
|
||||
@ -384,6 +620,15 @@ int raw_write_stdout(const void *, int);
|
||||
# define TM_STOP 1
|
||||
double app_tminterval(int stop, int usertime);
|
||||
|
||||
# define OPENSSL_NO_SSL_INTERN
|
||||
void make_uppercase(char *string);
|
||||
|
||||
typedef struct verify_options_st {
|
||||
int depth;
|
||||
int quiet;
|
||||
int error;
|
||||
int return_error;
|
||||
} VERIFY_CB_ARGS;
|
||||
|
||||
extern VERIFY_CB_ARGS verify_args;
|
||||
|
||||
#endif
|
||||
|
@ -1,302 +1,233 @@
|
||||
/* apps/asn1pars.c */
|
||||
/* Copyright (C) 1995-1998 Eric Young (eay@cryptsoft.com)
|
||||
* All rights reserved.
|
||||
*
|
||||
* This package is an SSL implementation written
|
||||
* by Eric Young (eay@cryptsoft.com).
|
||||
* The implementation was written so as to conform with Netscapes SSL.
|
||||
*
|
||||
* This library is free for commercial and non-commercial use as long as
|
||||
* the following conditions are aheared to. The following conditions
|
||||
* apply to all code found in this distribution, be it the RC4, RSA,
|
||||
* lhash, DES, etc., code; not just the SSL code. The SSL documentation
|
||||
* included with this distribution is covered by the same copyright terms
|
||||
* except that the holder is Tim Hudson (tjh@cryptsoft.com).
|
||||
*
|
||||
* Copyright remains Eric Young's, and as such any Copyright notices in
|
||||
* the code are not to be removed.
|
||||
* If this package is used in a product, Eric Young should be given attribution
|
||||
* as the author of the parts of the library used.
|
||||
* This can be in the form of a textual message at program startup or
|
||||
* in documentation (online or textual) provided with the package.
|
||||
*
|
||||
* Redistribution and use in source and binary forms, with or without
|
||||
* modification, are permitted provided that the following conditions
|
||||
* are met:
|
||||
* 1. Redistributions of source code must retain the copyright
|
||||
* notice, this list of conditions and the following disclaimer.
|
||||
* 2. Redistributions in binary form must reproduce the above copyright
|
||||
* notice, this list of conditions and the following disclaimer in the
|
||||
* documentation and/or other materials provided with the distribution.
|
||||
* 3. All advertising materials mentioning features or use of this software
|
||||
* must display the following acknowledgement:
|
||||
* "This product includes cryptographic software written by
|
||||
* Eric Young (eay@cryptsoft.com)"
|
||||
* The word 'cryptographic' can be left out if the rouines from the library
|
||||
* being used are not cryptographic related :-).
|
||||
* 4. If you include any Windows specific code (or a derivative thereof) from
|
||||
* the apps directory (application code) you must include an acknowledgement:
|
||||
* "This product includes software written by Tim Hudson (tjh@cryptsoft.com)"
|
||||
*
|
||||
* THIS SOFTWARE IS PROVIDED BY ERIC YOUNG ``AS IS'' AND
|
||||
* ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
|
||||
* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
|
||||
* ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE
|
||||
* FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
|
||||
* DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
|
||||
* OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
|
||||
* HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
|
||||
* LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
|
||||
* OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
|
||||
* SUCH DAMAGE.
|
||||
*
|
||||
* The licence and distribution terms for any publically available version or
|
||||
* derivative of this code cannot be changed. i.e. this code cannot simply be
|
||||
* copied and put under another distribution licence
|
||||
* [including the GNU Public Licence.]
|
||||
*/
|
||||
|
||||
/*
|
||||
* A nice addition from Dr Stephen Henson <steve@openssl.org> to add the
|
||||
* -strparse option which parses nested binary structures
|
||||
* Copyright 1995-2018 The OpenSSL Project Authors. All Rights Reserved.
|
||||
*
|
||||
* Licensed under the OpenSSL license (the "License"). You may not use
|
||||
* this file except in compliance with the License. You can obtain a copy
|
||||
* in the file LICENSE in the source distribution or at
|
||||
* https://www.openssl.org/source/license.html
|
||||
*/
|
||||
|
||||
#include <stdio.h>
|
||||
#include <stdlib.h>
|
||||
#include <string.h>
|
||||
#include "apps.h"
|
||||
#include "progs.h"
|
||||
#include <openssl/err.h>
|
||||
#include <openssl/evp.h>
|
||||
#include <openssl/x509.h>
|
||||
#include <openssl/pem.h>
|
||||
#include <openssl/asn1t.h>
|
||||
|
||||
/*-
|
||||
* -inform arg - input format - default PEM (DER or PEM)
|
||||
* -in arg - input file - default stdin
|
||||
* -i - indent the details by depth
|
||||
* -offset - where in the file to start
|
||||
* -length - how many bytes to use
|
||||
* -oid file - extra oid description file
|
||||
*/
|
||||
typedef enum OPTION_choice {
|
||||
OPT_ERR = -1, OPT_EOF = 0, OPT_HELP,
|
||||
OPT_INFORM, OPT_IN, OPT_OUT, OPT_INDENT, OPT_NOOUT,
|
||||
OPT_OID, OPT_OFFSET, OPT_LENGTH, OPT_DUMP, OPT_DLIMIT,
|
||||
OPT_STRPARSE, OPT_GENSTR, OPT_GENCONF, OPT_STRICTPEM,
|
||||
OPT_ITEM
|
||||
} OPTION_CHOICE;
|
||||
|
||||
#undef PROG
|
||||
#define PROG asn1parse_main
|
||||
const OPTIONS asn1parse_options[] = {
|
||||
{"help", OPT_HELP, '-', "Display this summary"},
|
||||
{"inform", OPT_INFORM, 'F', "input format - one of DER PEM"},
|
||||
{"in", OPT_IN, '<', "input file"},
|
||||
{"out", OPT_OUT, '>', "output file (output format is always DER)"},
|
||||
{"i", OPT_INDENT, 0, "indents the output"},
|
||||
{"noout", OPT_NOOUT, 0, "do not produce any output"},
|
||||
{"offset", OPT_OFFSET, 'p', "offset into file"},
|
||||
{"length", OPT_LENGTH, 'p', "length of section in file"},
|
||||
{"oid", OPT_OID, '<', "file of extra oid definitions"},
|
||||
{"dump", OPT_DUMP, 0, "unknown data in hex form"},
|
||||
{"dlimit", OPT_DLIMIT, 'p',
|
||||
"dump the first arg bytes of unknown data in hex form"},
|
||||
{"strparse", OPT_STRPARSE, 'p',
|
||||
"offset; a series of these can be used to 'dig'"},
|
||||
{OPT_MORE_STR, 0, 0, "into multiple ASN1 blob wrappings"},
|
||||
{"genstr", OPT_GENSTR, 's', "string to generate ASN1 structure from"},
|
||||
{"genconf", OPT_GENCONF, 's', "file to generate ASN1 structure from"},
|
||||
{OPT_MORE_STR, 0, 0, "(-inform will be ignored)"},
|
||||
{"strictpem", OPT_STRICTPEM, 0,
|
||||
"do not attempt base64 decode outside PEM markers"},
|
||||
{"item", OPT_ITEM, 's', "item to parse and print"},
|
||||
{NULL}
|
||||
};
|
||||
|
||||
int MAIN(int, char **);
|
||||
static int do_generate(char *genstr, const char *genconf, BUF_MEM *buf);
|
||||
|
||||
static int do_generate(BIO *bio, char *genstr, char *genconf, BUF_MEM *buf);
|
||||
|
||||
int MAIN(int argc, char **argv)
|
||||
int asn1parse_main(int argc, char **argv)
|
||||
{
|
||||
int i, badops = 0, offset = 0, ret = 1, j;
|
||||
unsigned int length = 0;
|
||||
long num, tmplen;
|
||||
BIO *in = NULL, *out = NULL, *b64 = NULL, *derout = NULL;
|
||||
int informat, indent = 0, noout = 0, dump = 0;
|
||||
char *infile = NULL, *str = NULL, *prog, *oidfile = NULL, *derfile = NULL;
|
||||
char *genstr = NULL, *genconf = NULL;
|
||||
unsigned char *tmpbuf;
|
||||
const unsigned char *ctmpbuf;
|
||||
ASN1_TYPE *at = NULL;
|
||||
BIO *in = NULL, *b64 = NULL, *derout = NULL;
|
||||
BUF_MEM *buf = NULL;
|
||||
STACK_OF(OPENSSL_STRING) *osk = NULL;
|
||||
ASN1_TYPE *at = NULL;
|
||||
char *genstr = NULL, *genconf = NULL;
|
||||
char *infile = NULL, *oidfile = NULL, *derfile = NULL;
|
||||
unsigned char *str = NULL;
|
||||
char *name = NULL, *header = NULL, *prog;
|
||||
const unsigned char *ctmpbuf;
|
||||
int indent = 0, noout = 0, dump = 0, strictpem = 0, informat = FORMAT_PEM;
|
||||
int offset = 0, ret = 1, i, j;
|
||||
long num, tmplen;
|
||||
unsigned char *tmpbuf;
|
||||
unsigned int length = 0;
|
||||
OPTION_CHOICE o;
|
||||
const ASN1_ITEM *it = NULL;
|
||||
|
||||
informat = FORMAT_PEM;
|
||||
prog = opt_init(argc, argv, asn1parse_options);
|
||||
|
||||
apps_startup();
|
||||
|
||||
if (bio_err == NULL)
|
||||
if ((bio_err = BIO_new(BIO_s_file())) != NULL)
|
||||
BIO_set_fp(bio_err, stderr, BIO_NOCLOSE | BIO_FP_TEXT);
|
||||
|
||||
if (!load_config(bio_err, NULL))
|
||||
goto end;
|
||||
|
||||
prog = argv[0];
|
||||
argc--;
|
||||
argv++;
|
||||
if ((osk = sk_OPENSSL_STRING_new_null()) == NULL) {
|
||||
BIO_printf(bio_err, "Memory allocation failure\n");
|
||||
BIO_printf(bio_err, "%s: Memory allocation failure\n", prog);
|
||||
goto end;
|
||||
}
|
||||
while (argc >= 1) {
|
||||
if (strcmp(*argv, "-inform") == 0) {
|
||||
if (--argc < 1)
|
||||
goto bad;
|
||||
informat = str2fmt(*(++argv));
|
||||
} else if (strcmp(*argv, "-in") == 0) {
|
||||
if (--argc < 1)
|
||||
goto bad;
|
||||
infile = *(++argv);
|
||||
} else if (strcmp(*argv, "-out") == 0) {
|
||||
if (--argc < 1)
|
||||
goto bad;
|
||||
derfile = *(++argv);
|
||||
} else if (strcmp(*argv, "-i") == 0) {
|
||||
|
||||
while ((o = opt_next()) != OPT_EOF) {
|
||||
switch (o) {
|
||||
case OPT_EOF:
|
||||
case OPT_ERR:
|
||||
opthelp:
|
||||
BIO_printf(bio_err, "%s: Use -help for summary.\n", prog);
|
||||
goto end;
|
||||
case OPT_HELP:
|
||||
opt_help(asn1parse_options);
|
||||
ret = 0;
|
||||
goto end;
|
||||
case OPT_INFORM:
|
||||
if (!opt_format(opt_arg(), OPT_FMT_PEMDER, &informat))
|
||||
goto opthelp;
|
||||
break;
|
||||
case OPT_IN:
|
||||
infile = opt_arg();
|
||||
break;
|
||||
case OPT_OUT:
|
||||
derfile = opt_arg();
|
||||
break;
|
||||
case OPT_INDENT:
|
||||
indent = 1;
|
||||
} else if (strcmp(*argv, "-noout") == 0)
|
||||
break;
|
||||
case OPT_NOOUT:
|
||||
noout = 1;
|
||||
else if (strcmp(*argv, "-oid") == 0) {
|
||||
if (--argc < 1)
|
||||
goto bad;
|
||||
oidfile = *(++argv);
|
||||
} else if (strcmp(*argv, "-offset") == 0) {
|
||||
if (--argc < 1)
|
||||
goto bad;
|
||||
offset = atoi(*(++argv));
|
||||
} else if (strcmp(*argv, "-length") == 0) {
|
||||
if (--argc < 1)
|
||||
goto bad;
|
||||
length = atoi(*(++argv));
|
||||
if (length == 0)
|
||||
goto bad;
|
||||
} else if (strcmp(*argv, "-dump") == 0) {
|
||||
break;
|
||||
case OPT_OID:
|
||||
oidfile = opt_arg();
|
||||
break;
|
||||
case OPT_OFFSET:
|
||||
offset = strtol(opt_arg(), NULL, 0);
|
||||
break;
|
||||
case OPT_LENGTH:
|
||||
length = strtol(opt_arg(), NULL, 0);
|
||||
break;
|
||||
case OPT_DUMP:
|
||||
dump = -1;
|
||||
} else if (strcmp(*argv, "-dlimit") == 0) {
|
||||
if (--argc < 1)
|
||||
goto bad;
|
||||
dump = atoi(*(++argv));
|
||||
if (dump <= 0)
|
||||
goto bad;
|
||||
} else if (strcmp(*argv, "-strparse") == 0) {
|
||||
if (--argc < 1)
|
||||
goto bad;
|
||||
sk_OPENSSL_STRING_push(osk, *(++argv));
|
||||
} else if (strcmp(*argv, "-genstr") == 0) {
|
||||
if (--argc < 1)
|
||||
goto bad;
|
||||
genstr = *(++argv);
|
||||
} else if (strcmp(*argv, "-genconf") == 0) {
|
||||
if (--argc < 1)
|
||||
goto bad;
|
||||
genconf = *(++argv);
|
||||
} else {
|
||||
BIO_printf(bio_err, "unknown option %s\n", *argv);
|
||||
badops = 1;
|
||||
break;
|
||||
case OPT_DLIMIT:
|
||||
dump = strtol(opt_arg(), NULL, 0);
|
||||
break;
|
||||
case OPT_STRPARSE:
|
||||
sk_OPENSSL_STRING_push(osk, opt_arg());
|
||||
break;
|
||||
case OPT_GENSTR:
|
||||
genstr = opt_arg();
|
||||
break;
|
||||
case OPT_GENCONF:
|
||||
genconf = opt_arg();
|
||||
break;
|
||||
case OPT_STRICTPEM:
|
||||
strictpem = 1;
|
||||
informat = FORMAT_PEM;
|
||||
break;
|
||||
case OPT_ITEM:
|
||||
it = ASN1_ITEM_lookup(opt_arg());
|
||||
if (it == NULL) {
|
||||
size_t tmp;
|
||||
|
||||
BIO_printf(bio_err, "Unknown item name %s\n", opt_arg());
|
||||
BIO_puts(bio_err, "Supported types:\n");
|
||||
for (tmp = 0;; tmp++) {
|
||||
it = ASN1_ITEM_get(tmp);
|
||||
if (it == NULL)
|
||||
break;
|
||||
BIO_printf(bio_err, " %s\n", it->sname);
|
||||
}
|
||||
goto end;
|
||||
}
|
||||
break;
|
||||
}
|
||||
argc--;
|
||||
argv++;
|
||||
}
|
||||
|
||||
if (badops) {
|
||||
bad:
|
||||
BIO_printf(bio_err, "%s [options] <infile\n", prog);
|
||||
BIO_printf(bio_err, "where options are\n");
|
||||
BIO_printf(bio_err, " -inform arg input format - one of DER PEM\n");
|
||||
BIO_printf(bio_err, " -in arg input file\n");
|
||||
BIO_printf(bio_err,
|
||||
" -out arg output file (output format is always DER\n");
|
||||
BIO_printf(bio_err, " -noout arg don't produce any output\n");
|
||||
BIO_printf(bio_err, " -offset arg offset into file\n");
|
||||
BIO_printf(bio_err, " -length arg length of section in file\n");
|
||||
BIO_printf(bio_err, " -i indent entries\n");
|
||||
BIO_printf(bio_err, " -dump dump unknown data in hex form\n");
|
||||
BIO_printf(bio_err,
|
||||
" -dlimit arg dump the first arg bytes of unknown data in hex form\n");
|
||||
BIO_printf(bio_err, " -oid file file of extra oid definitions\n");
|
||||
BIO_printf(bio_err, " -strparse offset\n");
|
||||
BIO_printf(bio_err,
|
||||
" a series of these can be used to 'dig' into multiple\n");
|
||||
BIO_printf(bio_err, " ASN1 blob wrappings\n");
|
||||
BIO_printf(bio_err,
|
||||
" -genstr str string to generate ASN1 structure from\n");
|
||||
BIO_printf(bio_err,
|
||||
" -genconf file file to generate ASN1 structure from\n");
|
||||
goto end;
|
||||
}
|
||||
|
||||
ERR_load_crypto_strings();
|
||||
|
||||
in = BIO_new(BIO_s_file());
|
||||
out = BIO_new(BIO_s_file());
|
||||
if ((in == NULL) || (out == NULL)) {
|
||||
ERR_print_errors(bio_err);
|
||||
goto end;
|
||||
}
|
||||
BIO_set_fp(out, stdout, BIO_NOCLOSE | BIO_FP_TEXT);
|
||||
#ifdef OPENSSL_SYS_VMS
|
||||
{
|
||||
BIO *tmpbio = BIO_new(BIO_f_linebuffer());
|
||||
out = BIO_push(tmpbio, out);
|
||||
}
|
||||
#endif
|
||||
argc = opt_num_rest();
|
||||
if (argc != 0)
|
||||
goto opthelp;
|
||||
|
||||
if (oidfile != NULL) {
|
||||
if (BIO_read_filename(in, oidfile) <= 0) {
|
||||
BIO_printf(bio_err, "problems opening %s\n", oidfile);
|
||||
ERR_print_errors(bio_err);
|
||||
in = bio_open_default(oidfile, 'r', FORMAT_TEXT);
|
||||
if (in == NULL)
|
||||
goto end;
|
||||
}
|
||||
OBJ_create_objects(in);
|
||||
BIO_free(in);
|
||||
}
|
||||
|
||||
if (infile == NULL)
|
||||
BIO_set_fp(in, stdin, BIO_NOCLOSE);
|
||||
else {
|
||||
if (BIO_read_filename(in, infile) <= 0) {
|
||||
perror(infile);
|
||||
goto end;
|
||||
}
|
||||
}
|
||||
|
||||
if (derfile) {
|
||||
if (!(derout = BIO_new_file(derfile, "wb"))) {
|
||||
BIO_printf(bio_err, "problems opening %s\n", derfile);
|
||||
ERR_print_errors(bio_err);
|
||||
goto end;
|
||||
}
|
||||
}
|
||||
|
||||
if ((buf = BUF_MEM_new()) == NULL)
|
||||
if ((in = bio_open_default(infile, 'r', informat)) == NULL)
|
||||
goto end;
|
||||
if (!BUF_MEM_grow(buf, BUFSIZ * 8))
|
||||
goto end; /* Pre-allocate :-) */
|
||||
|
||||
if (genstr || genconf) {
|
||||
num = do_generate(bio_err, genstr, genconf, buf);
|
||||
if (num < 0) {
|
||||
if (derfile && (derout = bio_open_default(derfile, 'w', FORMAT_ASN1)) == NULL)
|
||||
goto end;
|
||||
|
||||
if (strictpem) {
|
||||
if (PEM_read_bio(in, &name, &header, &str, &num) !=
|
||||
1) {
|
||||
BIO_printf(bio_err, "Error reading PEM file\n");
|
||||
ERR_print_errors(bio_err);
|
||||
goto end;
|
||||
}
|
||||
}
|
||||
} else {
|
||||
|
||||
else {
|
||||
if ((buf = BUF_MEM_new()) == NULL)
|
||||
goto end;
|
||||
if (!BUF_MEM_grow(buf, BUFSIZ * 8))
|
||||
goto end; /* Pre-allocate :-) */
|
||||
|
||||
if (informat == FORMAT_PEM) {
|
||||
BIO *tmp;
|
||||
|
||||
if ((b64 = BIO_new(BIO_f_base64())) == NULL)
|
||||
if (genstr || genconf) {
|
||||
num = do_generate(genstr, genconf, buf);
|
||||
if (num < 0) {
|
||||
ERR_print_errors(bio_err);
|
||||
goto end;
|
||||
BIO_push(b64, in);
|
||||
tmp = in;
|
||||
in = b64;
|
||||
b64 = tmp;
|
||||
}
|
||||
}
|
||||
} else {
|
||||
|
||||
num = 0;
|
||||
for (;;) {
|
||||
if (!BUF_MEM_grow(buf, (int)num + BUFSIZ))
|
||||
goto end;
|
||||
i = BIO_read(in, &(buf->data[num]), BUFSIZ);
|
||||
if (i <= 0)
|
||||
break;
|
||||
num += i;
|
||||
if (informat == FORMAT_PEM) {
|
||||
BIO *tmp;
|
||||
|
||||
if ((b64 = BIO_new(BIO_f_base64())) == NULL)
|
||||
goto end;
|
||||
BIO_push(b64, in);
|
||||
tmp = in;
|
||||
in = b64;
|
||||
b64 = tmp;
|
||||
}
|
||||
|
||||
num = 0;
|
||||
for (;;) {
|
||||
if (!BUF_MEM_grow(buf, num + BUFSIZ))
|
||||
goto end;
|
||||
i = BIO_read(in, &(buf->data[num]), BUFSIZ);
|
||||
if (i <= 0)
|
||||
break;
|
||||
num += i;
|
||||
}
|
||||
}
|
||||
str = (unsigned char *)buf->data;
|
||||
|
||||
}
|
||||
str = buf->data;
|
||||
|
||||
/* If any structs to parse go through in sequence */
|
||||
|
||||
if (sk_OPENSSL_STRING_num(osk)) {
|
||||
tmpbuf = (unsigned char *)str;
|
||||
tmpbuf = str;
|
||||
tmplen = num;
|
||||
for (i = 0; i < sk_OPENSSL_STRING_num(osk); i++) {
|
||||
ASN1_TYPE *atmp;
|
||||
int typ;
|
||||
j = atoi(sk_OPENSSL_STRING_value(osk, i));
|
||||
j = strtol(sk_OPENSSL_STRING_value(osk, i), NULL, 0);
|
||||
if (j <= 0 || j >= tmplen) {
|
||||
BIO_printf(bio_err, "'%s' is an invalid number\n",
|
||||
BIO_printf(bio_err, "'%s' is out of range\n",
|
||||
sk_OPENSSL_STRING_value(osk, i));
|
||||
continue;
|
||||
}
|
||||
@ -323,7 +254,7 @@ int MAIN(int argc, char **argv)
|
||||
tmpbuf = at->value.asn1_string->data;
|
||||
tmplen = at->value.asn1_string->length;
|
||||
}
|
||||
str = (char *)tmpbuf;
|
||||
str = tmpbuf;
|
||||
num = tmplen;
|
||||
}
|
||||
|
||||
@ -336,57 +267,63 @@ int MAIN(int argc, char **argv)
|
||||
|
||||
if (length == 0 || length > (unsigned int)num)
|
||||
length = (unsigned int)num;
|
||||
if (derout) {
|
||||
if (derout != NULL) {
|
||||
if (BIO_write(derout, str + offset, length) != (int)length) {
|
||||
BIO_printf(bio_err, "Error writing output\n");
|
||||
ERR_print_errors(bio_err);
|
||||
goto end;
|
||||
}
|
||||
}
|
||||
if (!noout &&
|
||||
!ASN1_parse_dump(out, (unsigned char *)&(str[offset]), length,
|
||||
indent, dump)) {
|
||||
ERR_print_errors(bio_err);
|
||||
goto end;
|
||||
if (!noout) {
|
||||
const unsigned char *p = str + offset;
|
||||
|
||||
if (it != NULL) {
|
||||
ASN1_VALUE *value = ASN1_item_d2i(NULL, &p, length, it);
|
||||
if (value == NULL) {
|
||||
BIO_printf(bio_err, "Error parsing item %s\n", it->sname);
|
||||
ERR_print_errors(bio_err);
|
||||
goto end;
|
||||
}
|
||||
ASN1_item_print(bio_out, value, 0, it, NULL);
|
||||
ASN1_item_free(value, it);
|
||||
} else {
|
||||
if (!ASN1_parse_dump(bio_out, p, length, indent, dump)) {
|
||||
ERR_print_errors(bio_err);
|
||||
goto end;
|
||||
}
|
||||
}
|
||||
}
|
||||
ret = 0;
|
||||
end:
|
||||
BIO_free(derout);
|
||||
if (in != NULL)
|
||||
BIO_free(in);
|
||||
if (out != NULL)
|
||||
BIO_free_all(out);
|
||||
if (b64 != NULL)
|
||||
BIO_free(b64);
|
||||
BIO_free(in);
|
||||
BIO_free(b64);
|
||||
if (ret != 0)
|
||||
ERR_print_errors(bio_err);
|
||||
if (buf != NULL)
|
||||
BUF_MEM_free(buf);
|
||||
if (at != NULL)
|
||||
ASN1_TYPE_free(at);
|
||||
if (osk != NULL)
|
||||
sk_OPENSSL_STRING_free(osk);
|
||||
OBJ_cleanup();
|
||||
apps_shutdown();
|
||||
OPENSSL_EXIT(ret);
|
||||
BUF_MEM_free(buf);
|
||||
OPENSSL_free(name);
|
||||
OPENSSL_free(header);
|
||||
if (strictpem)
|
||||
OPENSSL_free(str);
|
||||
ASN1_TYPE_free(at);
|
||||
sk_OPENSSL_STRING_free(osk);
|
||||
return ret;
|
||||
}
|
||||
|
||||
static int do_generate(BIO *bio, char *genstr, char *genconf, BUF_MEM *buf)
|
||||
static int do_generate(char *genstr, const char *genconf, BUF_MEM *buf)
|
||||
{
|
||||
CONF *cnf = NULL;
|
||||
int len;
|
||||
long errline = 0;
|
||||
unsigned char *p;
|
||||
ASN1_TYPE *atyp = NULL;
|
||||
|
||||
if (genconf) {
|
||||
cnf = NCONF_new(NULL);
|
||||
if (!NCONF_load(cnf, genconf, &errline))
|
||||
goto conferr;
|
||||
if (!genstr)
|
||||
if (genconf != NULL) {
|
||||
if ((cnf = app_load_config(genconf)) == NULL)
|
||||
goto err;
|
||||
if (genstr == NULL)
|
||||
genstr = NCONF_get_string(cnf, "default", "asn1");
|
||||
if (!genstr) {
|
||||
BIO_printf(bio, "Can't find 'asn1' in '%s'\n", genconf);
|
||||
if (genstr == NULL) {
|
||||
BIO_printf(bio_err, "Can't find 'asn1' in '%s'\n", genconf);
|
||||
goto err;
|
||||
}
|
||||
}
|
||||
@ -395,7 +332,7 @@ static int do_generate(BIO *bio, char *genstr, char *genconf, BUF_MEM *buf)
|
||||
NCONF_free(cnf);
|
||||
cnf = NULL;
|
||||
|
||||
if (!atyp)
|
||||
if (atyp == NULL)
|
||||
return -1;
|
||||
|
||||
len = i2d_ASN1_TYPE(atyp, NULL);
|
||||
@ -413,18 +350,8 @@ static int do_generate(BIO *bio, char *genstr, char *genconf, BUF_MEM *buf)
|
||||
ASN1_TYPE_free(atyp);
|
||||
return len;
|
||||
|
||||
conferr:
|
||||
|
||||
if (errline > 0)
|
||||
BIO_printf(bio, "Error on line %ld of config file '%s'\n",
|
||||
errline, genconf);
|
||||
else
|
||||
BIO_printf(bio, "Error loading config file '%s'\n", genconf);
|
||||
|
||||
err:
|
||||
NCONF_free(cnf);
|
||||
ASN1_TYPE_free(atyp);
|
||||
|
||||
return -1;
|
||||
|
||||
}
|
||||
|
177
crypto/openssl/apps/bf_prefix.c
Normal file
177
crypto/openssl/apps/bf_prefix.c
Normal file
@ -0,0 +1,177 @@
|
||||
/*
|
||||
* Copyright 2018 The OpenSSL Project Authors. All Rights Reserved.
|
||||
*
|
||||
* Licensed under the OpenSSL license (the "License"). You may not use
|
||||
* this file except in compliance with the License. You can obtain a copy
|
||||
* in the file LICENSE in the source distribution or at
|
||||
* https://www.openssl.org/source/license.html
|
||||
*/
|
||||
|
||||
#include <stdio.h>
|
||||
#include <string.h>
|
||||
#include <errno.h>
|
||||
#include <openssl/bio.h>
|
||||
#include "apps.h"
|
||||
|
||||
static int prefix_write(BIO *b, const char *out, size_t outl,
|
||||
size_t *numwritten);
|
||||
static int prefix_read(BIO *b, char *buf, size_t size, size_t *numread);
|
||||
static int prefix_puts(BIO *b, const char *str);
|
||||
static int prefix_gets(BIO *b, char *str, int size);
|
||||
static long prefix_ctrl(BIO *b, int cmd, long arg1, void *arg2);
|
||||
static int prefix_create(BIO *b);
|
||||
static int prefix_destroy(BIO *b);
|
||||
static long prefix_callback_ctrl(BIO *b, int cmd, BIO_info_cb *fp);
|
||||
|
||||
static BIO_METHOD *prefix_meth = NULL;
|
||||
|
||||
BIO_METHOD *apps_bf_prefix(void)
|
||||
{
|
||||
if (prefix_meth == NULL) {
|
||||
if ((prefix_meth =
|
||||
BIO_meth_new(BIO_TYPE_FILTER, "Prefix filter")) == NULL
|
||||
|| !BIO_meth_set_create(prefix_meth, prefix_create)
|
||||
|| !BIO_meth_set_destroy(prefix_meth, prefix_destroy)
|
||||
|| !BIO_meth_set_write_ex(prefix_meth, prefix_write)
|
||||
|| !BIO_meth_set_read_ex(prefix_meth, prefix_read)
|
||||
|| !BIO_meth_set_puts(prefix_meth, prefix_puts)
|
||||
|| !BIO_meth_set_gets(prefix_meth, prefix_gets)
|
||||
|| !BIO_meth_set_ctrl(prefix_meth, prefix_ctrl)
|
||||
|| !BIO_meth_set_callback_ctrl(prefix_meth, prefix_callback_ctrl)) {
|
||||
BIO_meth_free(prefix_meth);
|
||||
prefix_meth = NULL;
|
||||
}
|
||||
}
|
||||
return prefix_meth;
|
||||
}
|
||||
|
||||
typedef struct prefix_ctx_st {
|
||||
char *prefix;
|
||||
int linestart; /* flag to indicate we're at the line start */
|
||||
} PREFIX_CTX;
|
||||
|
||||
static int prefix_create(BIO *b)
|
||||
{
|
||||
PREFIX_CTX *ctx = OPENSSL_zalloc(sizeof(*ctx));
|
||||
|
||||
if (ctx == NULL)
|
||||
return 0;
|
||||
|
||||
ctx->prefix = NULL;
|
||||
ctx->linestart = 1;
|
||||
BIO_set_data(b, ctx);
|
||||
BIO_set_init(b, 1);
|
||||
return 1;
|
||||
}
|
||||
|
||||
static int prefix_destroy(BIO *b)
|
||||
{
|
||||
PREFIX_CTX *ctx = BIO_get_data(b);
|
||||
|
||||
OPENSSL_free(ctx->prefix);
|
||||
OPENSSL_free(ctx);
|
||||
return 1;
|
||||
}
|
||||
|
||||
static int prefix_read(BIO *b, char *in, size_t size, size_t *numread)
|
||||
{
|
||||
return BIO_read_ex(BIO_next(b), in, size, numread);
|
||||
}
|
||||
|
||||
static int prefix_write(BIO *b, const char *out, size_t outl,
|
||||
size_t *numwritten)
|
||||
{
|
||||
PREFIX_CTX *ctx = BIO_get_data(b);
|
||||
|
||||
if (ctx == NULL)
|
||||
return 0;
|
||||
|
||||
/* If no prefix is set or if it's empty, we've got nothing to do here */
|
||||
if (ctx->prefix == NULL || *ctx->prefix == '\0') {
|
||||
/* We do note if what comes next will be a new line, though */
|
||||
if (outl > 0)
|
||||
ctx->linestart = (out[outl-1] == '\n');
|
||||
return BIO_write_ex(BIO_next(b), out, outl, numwritten);
|
||||
}
|
||||
|
||||
*numwritten = 0;
|
||||
|
||||
while (outl > 0) {
|
||||
size_t i;
|
||||
char c;
|
||||
|
||||
/* If we know that we're at the start of the line, output the prefix */
|
||||
if (ctx->linestart) {
|
||||
size_t dontcare;
|
||||
|
||||
if (!BIO_write_ex(BIO_next(b), ctx->prefix, strlen(ctx->prefix),
|
||||
&dontcare))
|
||||
return 0;
|
||||
ctx->linestart = 0;
|
||||
}
|
||||
|
||||
/* Now, go look for the next LF, or the end of the string */
|
||||
for (i = 0, c = '\0'; i < outl && (c = out[i]) != '\n'; i++)
|
||||
continue;
|
||||
if (c == '\n')
|
||||
i++;
|
||||
|
||||
/* Output what we found so far */
|
||||
while (i > 0) {
|
||||
size_t num = 0;
|
||||
|
||||
if (!BIO_write_ex(BIO_next(b), out, i, &num))
|
||||
return 0;
|
||||
out += num;
|
||||
outl -= num;
|
||||
*numwritten += num;
|
||||
i -= num;
|
||||
}
|
||||
|
||||
/* If we found a LF, what follows is a new line, so take note */
|
||||
if (c == '\n')
|
||||
ctx->linestart = 1;
|
||||
}
|
||||
|
||||
return 1;
|
||||
}
|
||||
|
||||
static long prefix_ctrl(BIO *b, int cmd, long num, void *ptr)
|
||||
{
|
||||
long ret = 0;
|
||||
|
||||
switch (cmd) {
|
||||
case PREFIX_CTRL_SET_PREFIX:
|
||||
{
|
||||
PREFIX_CTX *ctx = BIO_get_data(b);
|
||||
|
||||
if (ctx == NULL)
|
||||
break;
|
||||
|
||||
OPENSSL_free(ctx->prefix);
|
||||
ctx->prefix = OPENSSL_strdup((const char *)ptr);
|
||||
ret = ctx->prefix != NULL;
|
||||
}
|
||||
break;
|
||||
default:
|
||||
if (BIO_next(b) != NULL)
|
||||
ret = BIO_ctrl(BIO_next(b), cmd, num, ptr);
|
||||
break;
|
||||
}
|
||||
return ret;
|
||||
}
|
||||
|
||||
static long prefix_callback_ctrl(BIO *b, int cmd, BIO_info_cb *fp)
|
||||
{
|
||||
return BIO_callback_ctrl(BIO_next(b), cmd, fp);
|
||||
}
|
||||
|
||||
static int prefix_gets(BIO *b, char *buf, int size)
|
||||
{
|
||||
return BIO_gets(BIO_next(b), buf, size);
|
||||
}
|
||||
|
||||
static int prefix_puts(BIO *b, const char *str)
|
||||
{
|
||||
return BIO_write(b, str, strlen(str));
|
||||
}
|
38
crypto/openssl/apps/build.info
Normal file
38
crypto/openssl/apps/build.info
Normal file
@ -0,0 +1,38 @@
|
||||
{- our @apps_openssl_src =
|
||||
qw(openssl.c
|
||||
asn1pars.c ca.c ciphers.c cms.c crl.c crl2p7.c dgst.c dhparam.c
|
||||
dsa.c dsaparam.c ec.c ecparam.c enc.c engine.c errstr.c gendsa.c
|
||||
genpkey.c genrsa.c nseq.c ocsp.c passwd.c pkcs12.c pkcs7.c pkcs8.c
|
||||
pkey.c pkeyparam.c pkeyutl.c prime.c rand.c req.c rsa.c rsautl.c
|
||||
s_client.c s_server.c s_time.c sess_id.c smime.c speed.c spkac.c
|
||||
srp.c ts.c verify.c version.c x509.c rehash.c storeutl.c);
|
||||
our @apps_lib_src =
|
||||
( qw(apps.c opt.c s_cb.c s_socket.c app_rand.c bf_prefix.c),
|
||||
split(/\s+/, $target{apps_aux_src}) );
|
||||
our @apps_init_src = split(/\s+/, $target{apps_init_src});
|
||||
"" -}
|
||||
IF[{- !$disabled{apps} -}]
|
||||
LIBS_NO_INST=libapps.a
|
||||
SOURCE[libapps.a]={- join(" ", @apps_lib_src) -}
|
||||
INCLUDE[libapps.a]=.. ../include
|
||||
|
||||
PROGRAMS=openssl
|
||||
SOURCE[openssl]={- join(" ", @apps_init_src) -}
|
||||
SOURCE[openssl]={- join(" ", @apps_openssl_src) -}
|
||||
INCLUDE[openssl]=.. ../include
|
||||
DEPEND[openssl]=libapps.a ../libssl
|
||||
|
||||
IF[{- $config{target} =~ /^(?:Cygwin|mingw|VC-)/ -}]
|
||||
GENERATE[openssl.rc]=../util/mkrc.pl openssl
|
||||
SOURCE[openssl]=openssl.rc
|
||||
ENDIF
|
||||
|
||||
{- join("\n ", map { (my $x = $_) =~ s|\.c$|.o|; "DEPEND[$x]=progs.h" }
|
||||
@apps_openssl_src) -}
|
||||
GENERATE[progs.h]=progs.pl $(APPS_OPENSSL)
|
||||
DEPEND[progs.h]=../configdata.pm
|
||||
|
||||
SCRIPTS=CA.pl tsget.pl
|
||||
SOURCE[CA.pl]=CA.pl.in
|
||||
SOURCE[tsget.pl]=tsget.in
|
||||
ENDIF
|
@ -1,15 +1,16 @@
|
||||
-----BEGIN RSA PRIVATE KEY-----
|
||||
MIICXQIBAAKBgQCju6PLddelT+nIMm07GQwmYa/eZ2JWbsmt2gotSCqM7asFp425
|
||||
gxSK4jqhhT62UPpqDBEwvQ+fYkVv3RV0r9ReuZGv12NoS4fXsQgqO17lHA7Od0Kd
|
||||
2yNwJjKh44MxPKDt2o8iQMyZE0zlHnEFNpsP4COLTDNC6ljEEu5bk8uPsQIDAQAB
|
||||
AoGAVZmpFZsDZfr0l2S9tLLwpjRWNOlKATQkno6q2WesT0eGLQufTciY+c8ypfU6
|
||||
hyio8r5iUl/VhhdjhAtKx1mRpiotftHo/eYf8rtsrnprOnWG0bWjLjtIoMbcxGn2
|
||||
J3bN6LJmbJMjDs0eJ3KnTu646F3nDUw2oGAwmpzKXA1KAP0CQQDRvQhxk2D3Pehs
|
||||
HvG665u2pB5ipYQngEFlZO7RHJZzJOZEWSLuuMqaF/7pTfA5jiBvWqCgJeCRRInL
|
||||
21ru4dlPAkEAx9jj7BgKn5TYnMoBSSe0afjsV9oApVpN1Nacb1YDtCwy+scp3++s
|
||||
nFxlv98wxIlSdpwMUn+AUWfjiWR7Tu/G/wJBAJ/KjwZIrFVxewP0x2ILYsTRYLzz
|
||||
MS4PDsO7FB+I0i7DbBOifXS2oNSpd3I0CNMwrxFnUHzynpbOStVfN3ZL5w0CQQCa
|
||||
pwFahxBRhkJKsxhjoFJBX9yl75JoY4Wvm5Tbo9ih6UJaRx3kqfkN14L2BKYcsZgb
|
||||
KY9vmDOYy6iNfjDeWTfJAkBkfPUb8oTJ/nSP5zN6sqGxSY4krc4xLxpRmxoJ8HL2
|
||||
XfhqXkTzbU13RX9JJ/NZ8vQN9Vm2NhxRGJocQkmcdVtJ
|
||||
-----END RSA PRIVATE KEY-----
|
||||
-----BEGIN PRIVATE KEY-----
|
||||
MIICdgIBADANBgkqhkiG9w0BAQEFAASCAmAwggJcAgEAAoGBAL4tQNyKy4U2zX6l
|
||||
IZvORB1edmwMwIgSB4cgoFECrG5pixzYxKauZkAwKG9/+L4DB8qXRjfXWcvafcOU
|
||||
DlYpRROykJ7wGkiqmqbZyrxY8DWjk5ZZQXiSuhYOAJB+Fyfb11JZV6+CvBQX/1g+
|
||||
vhJr39Gmp6oAesoYrj90ecozClmnAgMBAAECgYA3j6sSg+5f9hnldUMzbPjTh8Sb
|
||||
XsJlPrc6UFrmMBzGiUleXSpe9Dbla+x0XvQCN4pwMvAN4nnWp/f0Su5BV/9Y93nb
|
||||
im5ijGNrfN9i6QrnqGCr+MMute+4E8HR2pCScX0mBLDDf40SmDvMzCaxtd21keyr
|
||||
9DqHgInQZNEi6NKlkQJBAPCbUTFg6iQ6VTCQ8CsEf5q2xHhuTK23fJ999lvWVxN7
|
||||
QsvWb9RP9Ng34HVtvB7Pl6P7FyHLQYiDJhhvYR0L0+kCQQDKV/09Kt6Wjf5Omp1I
|
||||
wd3A+tFnipdqnPw+qNHGjevv0hYiEIWQOYbx00zXgaX+WN/pzV9eeNN2XAxlNJ++
|
||||
dxcPAkBrzeuPKFFAcjKBVC+H1rgl5gYZv7Hzk+buv02G0H6rZ+sB0c7BXiHiTwbv
|
||||
Fn/XfkP/YR14Ms3mEH0dLaphjU8hAkEAh3Ar/rRiN04mCcEuRFQXtaNtZSv8PA2G
|
||||
Pf7MI2Y9pdHupLCAZlBLRjTUO2/5hu1AO4QPMPIZQSFN3rRBtMCL+wJAMp/m2hvI
|
||||
TmtbMp/IrKGfma09e3yFiCmoNn7cHLJ7jLvXcacV2XNzpr9YHfBxiZo0g9FqZKvv
|
||||
PZoQ5B2XJ7bhTQ==
|
||||
-----END PRIVATE KEY-----
|
||||
|
@ -1,11 +1,11 @@
|
||||
-----BEGIN CERTIFICATE REQUEST-----
|
||||
MIIBmTCCAQICAQAwWzELMAkGA1UEBhMCQVUxEzARBgNVBAgTClF1ZWVuc2xhbmQx
|
||||
GjAYBgNVBAoTEUNyeXB0U29mdCBQdHkgTHRkMRswGQYDVQQDExJUZXN0IENBICgx
|
||||
MDI0IGJpdCkwgZ8wDQYJKoZIhvcNAQEBBQADgY0AMIGJAoGBAKO7o8t116VP6cgy
|
||||
bTsZDCZhr95nYlZuya3aCi1IKoztqwWnjbmDFIriOqGFPrZQ+moMETC9D59iRW/d
|
||||
FXSv1F65ka/XY2hLh9exCCo7XuUcDs53Qp3bI3AmMqHjgzE8oO3ajyJAzJkTTOUe
|
||||
cQU2mw/gI4tMM0LqWMQS7luTy4+xAgMBAAEwDQYJKoZIhvcNAQEEBQADgYEAKlk7
|
||||
cxu9gCJN3/iQFyJXQ6YphaiQAT5VBXTx9ftRrQIjA3vxlDzPWGDy+V5Tqa7h8PtR
|
||||
5Bn00JShII2zf0hjyjKils6x/UkWmjEiwSiFp4hR70iE8XwSNEHY2P6j6nQEIpgW
|
||||
kbfgmmUqk7dl2V+ossTJ80B8SBpEhrn81V/cHxA=
|
||||
MIIBmzCCAQQCAQAwWzELMAkGA1UEBhMCQVUxEzARBgNVBAgMClF1ZWVuc2xhbmQx
|
||||
GjAYBgNVBAoMEUNyeXB0U29mdCBQdHkgTHRkMRswGQYDVQQDDBJUZXN0IENBICgx
|
||||
MDI0IGJpdCkwgZ8wDQYJKoZIhvcNAQEBBQADgY0AMIGJAoGBAL4tQNyKy4U2zX6l
|
||||
IZvORB1edmwMwIgSB4cgoFECrG5pixzYxKauZkAwKG9/+L4DB8qXRjfXWcvafcOU
|
||||
DlYpRROykJ7wGkiqmqbZyrxY8DWjk5ZZQXiSuhYOAJB+Fyfb11JZV6+CvBQX/1g+
|
||||
vhJr39Gmp6oAesoYrj90ecozClmnAgMBAAGgADANBgkqhkiG9w0BAQsFAAOBgQCo
|
||||
2jE7J1SNV7kyRm9m8CoPw8xYsuVcVFxPheBymYp8BlO0/rSdYygRjobpYnLVRUPZ
|
||||
pV792wzT1Rp4sXfZWO10lkFY4yi0pH2cdK2RX7qedibV1Xu9vt/yYANFBKVpA4dy
|
||||
PRyTQwi3In1N8hdfddpYR8f5MIUYRe5poFMIJcf8JA==
|
||||
-----END CERTIFICATE REQUEST-----
|
||||
|
File diff suppressed because it is too large
Load Diff
@ -1,164 +1,202 @@
|
||||
/* apps/ciphers.c */
|
||||
/* Copyright (C) 1995-1998 Eric Young (eay@cryptsoft.com)
|
||||
* All rights reserved.
|
||||
/*
|
||||
* Copyright 1995-2018 The OpenSSL Project Authors. All Rights Reserved.
|
||||
*
|
||||
* This package is an SSL implementation written
|
||||
* by Eric Young (eay@cryptsoft.com).
|
||||
* The implementation was written so as to conform with Netscapes SSL.
|
||||
*
|
||||
* This library is free for commercial and non-commercial use as long as
|
||||
* the following conditions are aheared to. The following conditions
|
||||
* apply to all code found in this distribution, be it the RC4, RSA,
|
||||
* lhash, DES, etc., code; not just the SSL code. The SSL documentation
|
||||
* included with this distribution is covered by the same copyright terms
|
||||
* except that the holder is Tim Hudson (tjh@cryptsoft.com).
|
||||
*
|
||||
* Copyright remains Eric Young's, and as such any Copyright notices in
|
||||
* the code are not to be removed.
|
||||
* If this package is used in a product, Eric Young should be given attribution
|
||||
* as the author of the parts of the library used.
|
||||
* This can be in the form of a textual message at program startup or
|
||||
* in documentation (online or textual) provided with the package.
|
||||
*
|
||||
* Redistribution and use in source and binary forms, with or without
|
||||
* modification, are permitted provided that the following conditions
|
||||
* are met:
|
||||
* 1. Redistributions of source code must retain the copyright
|
||||
* notice, this list of conditions and the following disclaimer.
|
||||
* 2. Redistributions in binary form must reproduce the above copyright
|
||||
* notice, this list of conditions and the following disclaimer in the
|
||||
* documentation and/or other materials provided with the distribution.
|
||||
* 3. All advertising materials mentioning features or use of this software
|
||||
* must display the following acknowledgement:
|
||||
* "This product includes cryptographic software written by
|
||||
* Eric Young (eay@cryptsoft.com)"
|
||||
* The word 'cryptographic' can be left out if the rouines from the library
|
||||
* being used are not cryptographic related :-).
|
||||
* 4. If you include any Windows specific code (or a derivative thereof) from
|
||||
* the apps directory (application code) you must include an acknowledgement:
|
||||
* "This product includes software written by Tim Hudson (tjh@cryptsoft.com)"
|
||||
*
|
||||
* THIS SOFTWARE IS PROVIDED BY ERIC YOUNG ``AS IS'' AND
|
||||
* ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
|
||||
* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
|
||||
* ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE
|
||||
* FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
|
||||
* DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
|
||||
* OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
|
||||
* HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
|
||||
* LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
|
||||
* OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
|
||||
* SUCH DAMAGE.
|
||||
*
|
||||
* The licence and distribution terms for any publically available version or
|
||||
* derivative of this code cannot be changed. i.e. this code cannot simply be
|
||||
* copied and put under another distribution licence
|
||||
* [including the GNU Public Licence.]
|
||||
* Licensed under the OpenSSL license (the "License"). You may not use
|
||||
* this file except in compliance with the License. You can obtain a copy
|
||||
* in the file LICENSE in the source distribution or at
|
||||
* https://www.openssl.org/source/license.html
|
||||
*/
|
||||
|
||||
#include <stdio.h>
|
||||
#include <stdlib.h>
|
||||
#include <string.h>
|
||||
#ifdef OPENSSL_NO_STDIO
|
||||
# define APPS_WIN16
|
||||
#endif
|
||||
#include "apps.h"
|
||||
#include "progs.h"
|
||||
#include <openssl/err.h>
|
||||
#include <openssl/ssl.h>
|
||||
|
||||
#undef PROG
|
||||
#define PROG ciphers_main
|
||||
typedef enum OPTION_choice {
|
||||
OPT_ERR = -1, OPT_EOF = 0, OPT_HELP,
|
||||
OPT_STDNAME,
|
||||
OPT_CONVERT,
|
||||
OPT_SSL3,
|
||||
OPT_TLS1,
|
||||
OPT_TLS1_1,
|
||||
OPT_TLS1_2,
|
||||
OPT_TLS1_3,
|
||||
OPT_PSK,
|
||||
OPT_SRP,
|
||||
OPT_CIPHERSUITES,
|
||||
OPT_V, OPT_UPPER_V, OPT_S
|
||||
} OPTION_CHOICE;
|
||||
|
||||
static const char *ciphers_usage[] = {
|
||||
"usage: ciphers args\n",
|
||||
" -v - verbose mode, a textual listing of the SSL/TLS ciphers in OpenSSL\n",
|
||||
" -V - even more verbose\n",
|
||||
" -ssl2 - SSL2 mode\n",
|
||||
" -ssl3 - SSL3 mode\n",
|
||||
" -tls1 - TLS1 mode\n",
|
||||
NULL
|
||||
};
|
||||
|
||||
int MAIN(int, char **);
|
||||
|
||||
int MAIN(int argc, char **argv)
|
||||
{
|
||||
int ret = 1, i;
|
||||
int verbose = 0, Verbose = 0;
|
||||
#ifndef OPENSSL_NO_SSL_TRACE
|
||||
int stdname = 0;
|
||||
#endif
|
||||
const char **pp;
|
||||
const char *p;
|
||||
int badops = 0;
|
||||
SSL_CTX *ctx = NULL;
|
||||
SSL *ssl = NULL;
|
||||
char *ciphers = NULL;
|
||||
const SSL_METHOD *meth = NULL;
|
||||
STACK_OF(SSL_CIPHER) *sk;
|
||||
char buf[512];
|
||||
BIO *STDout = NULL;
|
||||
|
||||
meth = SSLv23_server_method();
|
||||
|
||||
apps_startup();
|
||||
|
||||
if (bio_err == NULL)
|
||||
bio_err = BIO_new_fp(stderr, BIO_NOCLOSE);
|
||||
STDout = BIO_new_fp(stdout, BIO_NOCLOSE);
|
||||
#ifdef OPENSSL_SYS_VMS
|
||||
{
|
||||
BIO *tmpbio = BIO_new(BIO_f_linebuffer());
|
||||
STDout = BIO_push(tmpbio, STDout);
|
||||
}
|
||||
#endif
|
||||
if (!load_config(bio_err, NULL))
|
||||
goto end;
|
||||
|
||||
argc--;
|
||||
argv++;
|
||||
while (argc >= 1) {
|
||||
if (strcmp(*argv, "-v") == 0)
|
||||
verbose = 1;
|
||||
else if (strcmp(*argv, "-V") == 0)
|
||||
verbose = Verbose = 1;
|
||||
#ifndef OPENSSL_NO_SSL_TRACE
|
||||
else if (strcmp(*argv, "-stdname") == 0)
|
||||
stdname = verbose = 1;
|
||||
#endif
|
||||
#ifndef OPENSSL_NO_SSL2
|
||||
else if (strcmp(*argv, "-ssl2") == 0)
|
||||
meth = SSLv2_client_method();
|
||||
#endif
|
||||
const OPTIONS ciphers_options[] = {
|
||||
{"help", OPT_HELP, '-', "Display this summary"},
|
||||
{"v", OPT_V, '-', "Verbose listing of the SSL/TLS ciphers"},
|
||||
{"V", OPT_UPPER_V, '-', "Even more verbose"},
|
||||
{"s", OPT_S, '-', "Only supported ciphers"},
|
||||
#ifndef OPENSSL_NO_SSL3
|
||||
else if (strcmp(*argv, "-ssl3") == 0)
|
||||
meth = SSLv3_client_method();
|
||||
{"ssl3", OPT_SSL3, '-', "SSL3 mode"},
|
||||
#endif
|
||||
#ifndef OPENSSL_NO_TLS1
|
||||
else if (strcmp(*argv, "-tls1") == 0)
|
||||
meth = TLSv1_client_method();
|
||||
{"tls1", OPT_TLS1, '-', "TLS1 mode"},
|
||||
#endif
|
||||
else if ((strncmp(*argv, "-h", 2) == 0) || (strcmp(*argv, "-?") == 0)) {
|
||||
badops = 1;
|
||||
break;
|
||||
} else {
|
||||
ciphers = *argv;
|
||||
}
|
||||
argc--;
|
||||
argv++;
|
||||
}
|
||||
#ifndef OPENSSL_NO_TLS1_1
|
||||
{"tls1_1", OPT_TLS1_1, '-', "TLS1.1 mode"},
|
||||
#endif
|
||||
#ifndef OPENSSL_NO_TLS1_2
|
||||
{"tls1_2", OPT_TLS1_2, '-', "TLS1.2 mode"},
|
||||
#endif
|
||||
#ifndef OPENSSL_NO_TLS1_3
|
||||
{"tls1_3", OPT_TLS1_3, '-', "TLS1.3 mode"},
|
||||
#endif
|
||||
{"stdname", OPT_STDNAME, '-', "Show standard cipher names"},
|
||||
#ifndef OPENSSL_NO_PSK
|
||||
{"psk", OPT_PSK, '-', "include ciphersuites requiring PSK"},
|
||||
#endif
|
||||
#ifndef OPENSSL_NO_SRP
|
||||
{"srp", OPT_SRP, '-', "include ciphersuites requiring SRP"},
|
||||
#endif
|
||||
{"convert", OPT_CONVERT, 's', "Convert standard name into OpenSSL name"},
|
||||
{"ciphersuites", OPT_CIPHERSUITES, 's',
|
||||
"Configure the TLSv1.3 ciphersuites to use"},
|
||||
{NULL}
|
||||
};
|
||||
|
||||
if (badops) {
|
||||
for (pp = ciphers_usage; (*pp != NULL); pp++)
|
||||
BIO_printf(bio_err, "%s", *pp);
|
||||
#ifndef OPENSSL_NO_PSK
|
||||
static unsigned int dummy_psk(SSL *ssl, const char *hint, char *identity,
|
||||
unsigned int max_identity_len,
|
||||
unsigned char *psk,
|
||||
unsigned int max_psk_len)
|
||||
{
|
||||
return 0;
|
||||
}
|
||||
#endif
|
||||
#ifndef OPENSSL_NO_SRP
|
||||
static char *dummy_srp(SSL *ssl, void *arg)
|
||||
{
|
||||
return "";
|
||||
}
|
||||
#endif
|
||||
|
||||
int ciphers_main(int argc, char **argv)
|
||||
{
|
||||
SSL_CTX *ctx = NULL;
|
||||
SSL *ssl = NULL;
|
||||
STACK_OF(SSL_CIPHER) *sk = NULL;
|
||||
const SSL_METHOD *meth = TLS_server_method();
|
||||
int ret = 1, i, verbose = 0, Verbose = 0, use_supported = 0;
|
||||
int stdname = 0;
|
||||
#ifndef OPENSSL_NO_PSK
|
||||
int psk = 0;
|
||||
#endif
|
||||
#ifndef OPENSSL_NO_SRP
|
||||
int srp = 0;
|
||||
#endif
|
||||
const char *p;
|
||||
char *ciphers = NULL, *prog, *convert = NULL, *ciphersuites = NULL;
|
||||
char buf[512];
|
||||
OPTION_CHOICE o;
|
||||
int min_version = 0, max_version = 0;
|
||||
|
||||
prog = opt_init(argc, argv, ciphers_options);
|
||||
while ((o = opt_next()) != OPT_EOF) {
|
||||
switch (o) {
|
||||
case OPT_EOF:
|
||||
case OPT_ERR:
|
||||
opthelp:
|
||||
BIO_printf(bio_err, "%s: Use -help for summary.\n", prog);
|
||||
goto end;
|
||||
case OPT_HELP:
|
||||
opt_help(ciphers_options);
|
||||
ret = 0;
|
||||
goto end;
|
||||
case OPT_V:
|
||||
verbose = 1;
|
||||
break;
|
||||
case OPT_UPPER_V:
|
||||
verbose = Verbose = 1;
|
||||
break;
|
||||
case OPT_S:
|
||||
use_supported = 1;
|
||||
break;
|
||||
case OPT_STDNAME:
|
||||
stdname = verbose = 1;
|
||||
break;
|
||||
case OPT_CONVERT:
|
||||
convert = opt_arg();
|
||||
break;
|
||||
case OPT_SSL3:
|
||||
min_version = SSL3_VERSION;
|
||||
max_version = SSL3_VERSION;
|
||||
break;
|
||||
case OPT_TLS1:
|
||||
min_version = TLS1_VERSION;
|
||||
max_version = TLS1_VERSION;
|
||||
break;
|
||||
case OPT_TLS1_1:
|
||||
min_version = TLS1_1_VERSION;
|
||||
max_version = TLS1_1_VERSION;
|
||||
break;
|
||||
case OPT_TLS1_2:
|
||||
min_version = TLS1_2_VERSION;
|
||||
max_version = TLS1_2_VERSION;
|
||||
break;
|
||||
case OPT_TLS1_3:
|
||||
min_version = TLS1_3_VERSION;
|
||||
max_version = TLS1_3_VERSION;
|
||||
break;
|
||||
case OPT_PSK:
|
||||
#ifndef OPENSSL_NO_PSK
|
||||
psk = 1;
|
||||
#endif
|
||||
break;
|
||||
case OPT_SRP:
|
||||
#ifndef OPENSSL_NO_SRP
|
||||
srp = 1;
|
||||
#endif
|
||||
break;
|
||||
case OPT_CIPHERSUITES:
|
||||
ciphersuites = opt_arg();
|
||||
break;
|
||||
}
|
||||
}
|
||||
argv = opt_rest();
|
||||
argc = opt_num_rest();
|
||||
|
||||
if (argc == 1)
|
||||
ciphers = *argv;
|
||||
else if (argc != 0)
|
||||
goto opthelp;
|
||||
|
||||
if (convert != NULL) {
|
||||
BIO_printf(bio_out, "OpenSSL cipher name: %s\n",
|
||||
OPENSSL_cipher_name(convert));
|
||||
goto end;
|
||||
}
|
||||
|
||||
OpenSSL_add_ssl_algorithms();
|
||||
|
||||
ctx = SSL_CTX_new(meth);
|
||||
if (ctx == NULL)
|
||||
goto err;
|
||||
if (SSL_CTX_set_min_proto_version(ctx, min_version) == 0)
|
||||
goto err;
|
||||
if (SSL_CTX_set_max_proto_version(ctx, max_version) == 0)
|
||||
goto err;
|
||||
|
||||
#ifndef OPENSSL_NO_PSK
|
||||
if (psk)
|
||||
SSL_CTX_set_psk_client_callback(ctx, dummy_psk);
|
||||
#endif
|
||||
#ifndef OPENSSL_NO_SRP
|
||||
if (srp)
|
||||
SSL_CTX_set_srp_client_pwd_callback(ctx, dummy_srp);
|
||||
#endif
|
||||
|
||||
if (ciphersuites != NULL && !SSL_CTX_set_ciphersuites(ctx, ciphersuites)) {
|
||||
BIO_printf(bio_err, "Error setting TLSv1.3 ciphersuites\n");
|
||||
goto err;
|
||||
}
|
||||
|
||||
if (ciphers != NULL) {
|
||||
if (!SSL_CTX_set_cipher_list(ctx, ciphers)) {
|
||||
BIO_printf(bio_err, "Error in cipher list\n");
|
||||
@ -169,22 +207,26 @@ int MAIN(int argc, char **argv)
|
||||
if (ssl == NULL)
|
||||
goto err;
|
||||
|
||||
if (use_supported)
|
||||
sk = SSL_get1_supported_ciphers(ssl);
|
||||
else
|
||||
sk = SSL_get_ciphers(ssl);
|
||||
|
||||
if (!verbose) {
|
||||
for (i = 0;; i++) {
|
||||
p = SSL_get_cipher_list(ssl, i);
|
||||
for (i = 0; i < sk_SSL_CIPHER_num(sk); i++) {
|
||||
const SSL_CIPHER *c = sk_SSL_CIPHER_value(sk, i);
|
||||
p = SSL_CIPHER_get_name(c);
|
||||
if (p == NULL)
|
||||
break;
|
||||
if (i != 0)
|
||||
BIO_printf(STDout, ":");
|
||||
BIO_printf(STDout, "%s", p);
|
||||
BIO_printf(bio_out, ":");
|
||||
BIO_printf(bio_out, "%s", p);
|
||||
}
|
||||
BIO_printf(STDout, "\n");
|
||||
} else { /* verbose */
|
||||
|
||||
sk = SSL_get_ciphers(ssl);
|
||||
BIO_printf(bio_out, "\n");
|
||||
} else {
|
||||
|
||||
for (i = 0; i < sk_SSL_CIPHER_num(sk); i++) {
|
||||
SSL_CIPHER *c;
|
||||
const SSL_CIPHER *c;
|
||||
|
||||
c = sk_SSL_CIPHER_value(sk, i);
|
||||
|
||||
@ -195,45 +237,30 @@ int MAIN(int argc, char **argv)
|
||||
int id2 = (int)((id >> 8) & 0xffL);
|
||||
int id3 = (int)(id & 0xffL);
|
||||
|
||||
if ((id & 0xff000000L) == 0x02000000L) {
|
||||
/* SSL2 cipher */
|
||||
BIO_printf(STDout, " 0x%02X,0x%02X,0x%02X - ", id1,
|
||||
id2, id3);
|
||||
} else if ((id & 0xff000000L) == 0x03000000L) {
|
||||
/* SSL3 cipher */
|
||||
BIO_printf(STDout, " 0x%02X,0x%02X - ", id2,
|
||||
id3);
|
||||
} else {
|
||||
/* whatever */
|
||||
BIO_printf(STDout, "0x%02X,0x%02X,0x%02X,0x%02X - ", id0,
|
||||
id1, id2, id3);
|
||||
}
|
||||
if ((id & 0xff000000L) == 0x03000000L)
|
||||
BIO_printf(bio_out, " 0x%02X,0x%02X - ", id2, id3); /* SSL3
|
||||
* cipher */
|
||||
else
|
||||
BIO_printf(bio_out, "0x%02X,0x%02X,0x%02X,0x%02X - ", id0, id1, id2, id3); /* whatever */
|
||||
}
|
||||
#ifndef OPENSSL_NO_SSL_TRACE
|
||||
if (stdname) {
|
||||
const char *nm = SSL_CIPHER_standard_name(c);
|
||||
if (nm == NULL)
|
||||
nm = "UNKNOWN";
|
||||
BIO_printf(STDout, "%s - ", nm);
|
||||
BIO_printf(bio_out, "%s - ", nm);
|
||||
}
|
||||
#endif
|
||||
BIO_puts(STDout, SSL_CIPHER_description(c, buf, sizeof(buf)));
|
||||
BIO_puts(bio_out, SSL_CIPHER_description(c, buf, sizeof(buf)));
|
||||
}
|
||||
}
|
||||
|
||||
ret = 0;
|
||||
if (0) {
|
||||
goto end;
|
||||
err:
|
||||
SSL_load_error_strings();
|
||||
ERR_print_errors(bio_err);
|
||||
}
|
||||
ERR_print_errors(bio_err);
|
||||
end:
|
||||
if (ctx != NULL)
|
||||
SSL_CTX_free(ctx);
|
||||
if (ssl != NULL)
|
||||
SSL_free(ssl);
|
||||
if (STDout != NULL)
|
||||
BIO_free_all(STDout);
|
||||
apps_shutdown();
|
||||
OPENSSL_EXIT(ret);
|
||||
if (use_supported)
|
||||
sk_SSL_CIPHER_free(sk);
|
||||
SSL_CTX_free(ctx);
|
||||
SSL_free(ssl);
|
||||
return ret;
|
||||
}
|
||||
|
File diff suppressed because it is too large
Load Diff
@ -1,286 +1,209 @@
|
||||
/* apps/crl.c */
|
||||
/* Copyright (C) 1995-1998 Eric Young (eay@cryptsoft.com)
|
||||
* All rights reserved.
|
||||
/*
|
||||
* Copyright 1995-2018 The OpenSSL Project Authors. All Rights Reserved.
|
||||
*
|
||||
* This package is an SSL implementation written
|
||||
* by Eric Young (eay@cryptsoft.com).
|
||||
* The implementation was written so as to conform with Netscapes SSL.
|
||||
*
|
||||
* This library is free for commercial and non-commercial use as long as
|
||||
* the following conditions are aheared to. The following conditions
|
||||
* apply to all code found in this distribution, be it the RC4, RSA,
|
||||
* lhash, DES, etc., code; not just the SSL code. The SSL documentation
|
||||
* included with this distribution is covered by the same copyright terms
|
||||
* except that the holder is Tim Hudson (tjh@cryptsoft.com).
|
||||
*
|
||||
* Copyright remains Eric Young's, and as such any Copyright notices in
|
||||
* the code are not to be removed.
|
||||
* If this package is used in a product, Eric Young should be given attribution
|
||||
* as the author of the parts of the library used.
|
||||
* This can be in the form of a textual message at program startup or
|
||||
* in documentation (online or textual) provided with the package.
|
||||
*
|
||||
* Redistribution and use in source and binary forms, with or without
|
||||
* modification, are permitted provided that the following conditions
|
||||
* are met:
|
||||
* 1. Redistributions of source code must retain the copyright
|
||||
* notice, this list of conditions and the following disclaimer.
|
||||
* 2. Redistributions in binary form must reproduce the above copyright
|
||||
* notice, this list of conditions and the following disclaimer in the
|
||||
* documentation and/or other materials provided with the distribution.
|
||||
* 3. All advertising materials mentioning features or use of this software
|
||||
* must display the following acknowledgement:
|
||||
* "This product includes cryptographic software written by
|
||||
* Eric Young (eay@cryptsoft.com)"
|
||||
* The word 'cryptographic' can be left out if the rouines from the library
|
||||
* being used are not cryptographic related :-).
|
||||
* 4. If you include any Windows specific code (or a derivative thereof) from
|
||||
* the apps directory (application code) you must include an acknowledgement:
|
||||
* "This product includes software written by Tim Hudson (tjh@cryptsoft.com)"
|
||||
*
|
||||
* THIS SOFTWARE IS PROVIDED BY ERIC YOUNG ``AS IS'' AND
|
||||
* ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
|
||||
* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
|
||||
* ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE
|
||||
* FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
|
||||
* DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
|
||||
* OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
|
||||
* HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
|
||||
* LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
|
||||
* OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
|
||||
* SUCH DAMAGE.
|
||||
*
|
||||
* The licence and distribution terms for any publically available version or
|
||||
* derivative of this code cannot be changed. i.e. this code cannot simply be
|
||||
* copied and put under another distribution licence
|
||||
* [including the GNU Public Licence.]
|
||||
* Licensed under the OpenSSL license (the "License"). You may not use
|
||||
* this file except in compliance with the License. You can obtain a copy
|
||||
* in the file LICENSE in the source distribution or at
|
||||
* https://www.openssl.org/source/license.html
|
||||
*/
|
||||
|
||||
#include <stdio.h>
|
||||
#include <stdlib.h>
|
||||
#include <string.h>
|
||||
#include "apps.h"
|
||||
#include "progs.h"
|
||||
#include <openssl/bio.h>
|
||||
#include <openssl/err.h>
|
||||
#include <openssl/x509.h>
|
||||
#include <openssl/x509v3.h>
|
||||
#include <openssl/pem.h>
|
||||
|
||||
#undef PROG
|
||||
#define PROG crl_main
|
||||
typedef enum OPTION_choice {
|
||||
OPT_ERR = -1, OPT_EOF = 0, OPT_HELP,
|
||||
OPT_INFORM, OPT_IN, OPT_OUTFORM, OPT_OUT, OPT_KEYFORM, OPT_KEY,
|
||||
OPT_ISSUER, OPT_LASTUPDATE, OPT_NEXTUPDATE, OPT_FINGERPRINT,
|
||||
OPT_CRLNUMBER, OPT_BADSIG, OPT_GENDELTA, OPT_CAPATH, OPT_CAFILE,
|
||||
OPT_NOCAPATH, OPT_NOCAFILE, OPT_VERIFY, OPT_TEXT, OPT_HASH, OPT_HASH_OLD,
|
||||
OPT_NOOUT, OPT_NAMEOPT, OPT_MD
|
||||
} OPTION_CHOICE;
|
||||
|
||||
#undef POSTFIX
|
||||
#define POSTFIX ".rvk"
|
||||
|
||||
static const char *crl_usage[] = {
|
||||
"usage: crl args\n",
|
||||
"\n",
|
||||
" -inform arg - input format - default PEM (DER or PEM)\n",
|
||||
" -outform arg - output format - default PEM\n",
|
||||
" -text - print out a text format version\n",
|
||||
" -in arg - input file - default stdin\n",
|
||||
" -out arg - output file - default stdout\n",
|
||||
" -hash - print hash value\n",
|
||||
const OPTIONS crl_options[] = {
|
||||
{"help", OPT_HELP, '-', "Display this summary"},
|
||||
{"inform", OPT_INFORM, 'F', "Input format; default PEM"},
|
||||
{"in", OPT_IN, '<', "Input file - default stdin"},
|
||||
{"outform", OPT_OUTFORM, 'F', "Output format - default PEM"},
|
||||
{"out", OPT_OUT, '>', "output file - default stdout"},
|
||||
{"keyform", OPT_KEYFORM, 'F', "Private key file format (PEM or ENGINE)"},
|
||||
{"key", OPT_KEY, '<', "CRL signing Private key to use"},
|
||||
{"issuer", OPT_ISSUER, '-', "Print issuer DN"},
|
||||
{"lastupdate", OPT_LASTUPDATE, '-', "Set lastUpdate field"},
|
||||
{"nextupdate", OPT_NEXTUPDATE, '-', "Set nextUpdate field"},
|
||||
{"noout", OPT_NOOUT, '-', "No CRL output"},
|
||||
{"fingerprint", OPT_FINGERPRINT, '-', "Print the crl fingerprint"},
|
||||
{"crlnumber", OPT_CRLNUMBER, '-', "Print CRL number"},
|
||||
{"badsig", OPT_BADSIG, '-', "Corrupt last byte of loaded CRL signature (for test)" },
|
||||
{"gendelta", OPT_GENDELTA, '<', "Other CRL to compare/diff to the Input one"},
|
||||
{"CApath", OPT_CAPATH, '/', "Verify CRL using certificates in dir"},
|
||||
{"CAfile", OPT_CAFILE, '<', "Verify CRL using certificates in file name"},
|
||||
{"no-CAfile", OPT_NOCAFILE, '-',
|
||||
"Do not load the default certificates file"},
|
||||
{"no-CApath", OPT_NOCAPATH, '-',
|
||||
"Do not load certificates from the default certificates directory"},
|
||||
{"verify", OPT_VERIFY, '-', "Verify CRL signature"},
|
||||
{"text", OPT_TEXT, '-', "Print out a text format version"},
|
||||
{"hash", OPT_HASH, '-', "Print hash value"},
|
||||
{"nameopt", OPT_NAMEOPT, 's', "Various certificate name options"},
|
||||
{"", OPT_MD, '-', "Any supported digest"},
|
||||
#ifndef OPENSSL_NO_MD5
|
||||
" -hash_old - print old-style (MD5) hash value\n",
|
||||
{"hash_old", OPT_HASH_OLD, '-', "Print old-style (MD5) hash value"},
|
||||
#endif
|
||||
" -fingerprint - print the crl fingerprint\n",
|
||||
" -issuer - print issuer DN\n",
|
||||
" -lastupdate - lastUpdate field\n",
|
||||
" -nextupdate - nextUpdate field\n",
|
||||
" -crlnumber - print CRL number\n",
|
||||
" -noout - no CRL output\n",
|
||||
" -CAfile name - verify CRL using certificates in file \"name\"\n",
|
||||
" -CApath dir - verify CRL using certificates in \"dir\"\n",
|
||||
" -nameopt arg - various certificate name options\n",
|
||||
NULL
|
||||
{NULL}
|
||||
};
|
||||
|
||||
static BIO *bio_out = NULL;
|
||||
|
||||
int MAIN(int, char **);
|
||||
|
||||
int MAIN(int argc, char **argv)
|
||||
int crl_main(int argc, char **argv)
|
||||
{
|
||||
unsigned long nmflag = 0;
|
||||
X509_CRL *x = NULL;
|
||||
char *CAfile = NULL, *CApath = NULL;
|
||||
int ret = 1, i, num, badops = 0, badsig = 0;
|
||||
BIO *out = NULL;
|
||||
int informat, outformat, keyformat;
|
||||
X509_STORE *store = NULL;
|
||||
X509_STORE_CTX *ctx = NULL;
|
||||
X509_LOOKUP *lookup = NULL;
|
||||
X509_OBJECT *xobj = NULL;
|
||||
EVP_PKEY *pkey;
|
||||
const EVP_MD *digest = EVP_sha1();
|
||||
char *infile = NULL, *outfile = NULL, *crldiff = NULL, *keyfile = NULL;
|
||||
int hash = 0, issuer = 0, lastupdate = 0, nextupdate = 0, noout =
|
||||
0, text = 0;
|
||||
const char *CAfile = NULL, *CApath = NULL, *prog;
|
||||
OPTION_CHOICE o;
|
||||
int hash = 0, issuer = 0, lastupdate = 0, nextupdate = 0, noout = 0;
|
||||
int informat = FORMAT_PEM, outformat = FORMAT_PEM, keyformat = FORMAT_PEM;
|
||||
int ret = 1, num = 0, badsig = 0, fingerprint = 0, crlnumber = 0;
|
||||
int text = 0, do_ver = 0, noCAfile = 0, noCApath = 0;
|
||||
int i;
|
||||
#ifndef OPENSSL_NO_MD5
|
||||
int hash_old = 0;
|
||||
#endif
|
||||
int fingerprint = 0, crlnumber = 0;
|
||||
const char **pp;
|
||||
X509_STORE *store = NULL;
|
||||
X509_STORE_CTX ctx;
|
||||
X509_LOOKUP *lookup = NULL;
|
||||
X509_OBJECT xobj;
|
||||
EVP_PKEY *pkey;
|
||||
int do_ver = 0;
|
||||
const EVP_MD *md_alg, *digest = EVP_sha1();
|
||||
|
||||
apps_startup();
|
||||
|
||||
if (bio_err == NULL)
|
||||
if ((bio_err = BIO_new(BIO_s_file())) != NULL)
|
||||
BIO_set_fp(bio_err, stderr, BIO_NOCLOSE | BIO_FP_TEXT);
|
||||
|
||||
if (!load_config(bio_err, NULL))
|
||||
goto end;
|
||||
|
||||
if (bio_out == NULL)
|
||||
if ((bio_out = BIO_new(BIO_s_file())) != NULL) {
|
||||
BIO_set_fp(bio_out, stdout, BIO_NOCLOSE);
|
||||
#ifdef OPENSSL_SYS_VMS
|
||||
{
|
||||
BIO *tmpbio = BIO_new(BIO_f_linebuffer());
|
||||
bio_out = BIO_push(tmpbio, bio_out);
|
||||
}
|
||||
#endif
|
||||
}
|
||||
|
||||
informat = FORMAT_PEM;
|
||||
outformat = FORMAT_PEM;
|
||||
keyformat = FORMAT_PEM;
|
||||
|
||||
argc--;
|
||||
argv++;
|
||||
num = 0;
|
||||
while (argc >= 1) {
|
||||
#ifdef undef
|
||||
if (strcmp(*argv, "-p") == 0) {
|
||||
if (--argc < 1)
|
||||
goto bad;
|
||||
if (!args_from_file(++argv, Nargc, Nargv)) {
|
||||
goto end;
|
||||
}
|
||||
*/}
|
||||
#endif
|
||||
if (strcmp(*argv, "-inform") == 0) {
|
||||
if (--argc < 1)
|
||||
goto bad;
|
||||
informat = str2fmt(*(++argv));
|
||||
} else if (strcmp(*argv, "-outform") == 0) {
|
||||
if (--argc < 1)
|
||||
goto bad;
|
||||
outformat = str2fmt(*(++argv));
|
||||
} else if (strcmp(*argv, "-in") == 0) {
|
||||
if (--argc < 1)
|
||||
goto bad;
|
||||
infile = *(++argv);
|
||||
} else if (strcmp(*argv, "-gendelta") == 0) {
|
||||
if (--argc < 1)
|
||||
goto bad;
|
||||
crldiff = *(++argv);
|
||||
} else if (strcmp(*argv, "-key") == 0) {
|
||||
if (--argc < 1)
|
||||
goto bad;
|
||||
keyfile = *(++argv);
|
||||
} else if (strcmp(*argv, "-keyform") == 0) {
|
||||
if (--argc < 1)
|
||||
goto bad;
|
||||
keyformat = str2fmt(*(++argv));
|
||||
} else if (strcmp(*argv, "-out") == 0) {
|
||||
if (--argc < 1)
|
||||
goto bad;
|
||||
outfile = *(++argv);
|
||||
} else if (strcmp(*argv, "-CApath") == 0) {
|
||||
if (--argc < 1)
|
||||
goto bad;
|
||||
CApath = *(++argv);
|
||||
prog = opt_init(argc, argv, crl_options);
|
||||
while ((o = opt_next()) != OPT_EOF) {
|
||||
switch (o) {
|
||||
case OPT_EOF:
|
||||
case OPT_ERR:
|
||||
opthelp:
|
||||
BIO_printf(bio_err, "%s: Use -help for summary.\n", prog);
|
||||
goto end;
|
||||
case OPT_HELP:
|
||||
opt_help(crl_options);
|
||||
ret = 0;
|
||||
goto end;
|
||||
case OPT_INFORM:
|
||||
if (!opt_format(opt_arg(), OPT_FMT_PEMDER, &informat))
|
||||
goto opthelp;
|
||||
break;
|
||||
case OPT_IN:
|
||||
infile = opt_arg();
|
||||
break;
|
||||
case OPT_OUTFORM:
|
||||
if (!opt_format(opt_arg(), OPT_FMT_PEMDER, &outformat))
|
||||
goto opthelp;
|
||||
break;
|
||||
case OPT_OUT:
|
||||
outfile = opt_arg();
|
||||
break;
|
||||
case OPT_KEYFORM:
|
||||
if (!opt_format(opt_arg(), OPT_FMT_PEMDER, &keyformat))
|
||||
goto opthelp;
|
||||
break;
|
||||
case OPT_KEY:
|
||||
keyfile = opt_arg();
|
||||
break;
|
||||
case OPT_GENDELTA:
|
||||
crldiff = opt_arg();
|
||||
break;
|
||||
case OPT_CAPATH:
|
||||
CApath = opt_arg();
|
||||
do_ver = 1;
|
||||
} else if (strcmp(*argv, "-CAfile") == 0) {
|
||||
if (--argc < 1)
|
||||
goto bad;
|
||||
CAfile = *(++argv);
|
||||
break;
|
||||
case OPT_CAFILE:
|
||||
CAfile = opt_arg();
|
||||
do_ver = 1;
|
||||
} else if (strcmp(*argv, "-verify") == 0)
|
||||
do_ver = 1;
|
||||
else if (strcmp(*argv, "-text") == 0)
|
||||
text = 1;
|
||||
else if (strcmp(*argv, "-hash") == 0)
|
||||
hash = ++num;
|
||||
break;
|
||||
case OPT_NOCAPATH:
|
||||
noCApath = 1;
|
||||
break;
|
||||
case OPT_NOCAFILE:
|
||||
noCAfile = 1;
|
||||
break;
|
||||
case OPT_HASH_OLD:
|
||||
#ifndef OPENSSL_NO_MD5
|
||||
else if (strcmp(*argv, "-hash_old") == 0)
|
||||
hash_old = ++num;
|
||||
#endif
|
||||
else if (strcmp(*argv, "-nameopt") == 0) {
|
||||
if (--argc < 1)
|
||||
goto bad;
|
||||
if (!set_name_ex(&nmflag, *(++argv)))
|
||||
goto bad;
|
||||
} else if (strcmp(*argv, "-issuer") == 0)
|
||||
issuer = ++num;
|
||||
else if (strcmp(*argv, "-lastupdate") == 0)
|
||||
lastupdate = ++num;
|
||||
else if (strcmp(*argv, "-nextupdate") == 0)
|
||||
nextupdate = ++num;
|
||||
else if (strcmp(*argv, "-noout") == 0)
|
||||
noout = ++num;
|
||||
else if (strcmp(*argv, "-fingerprint") == 0)
|
||||
fingerprint = ++num;
|
||||
else if (strcmp(*argv, "-crlnumber") == 0)
|
||||
crlnumber = ++num;
|
||||
else if (strcmp(*argv, "-badsig") == 0)
|
||||
badsig = 1;
|
||||
else if ((md_alg = EVP_get_digestbyname(*argv + 1))) {
|
||||
/* ok */
|
||||
digest = md_alg;
|
||||
} else {
|
||||
BIO_printf(bio_err, "unknown option %s\n", *argv);
|
||||
badops = 1;
|
||||
break;
|
||||
case OPT_VERIFY:
|
||||
do_ver = 1;
|
||||
break;
|
||||
case OPT_TEXT:
|
||||
text = 1;
|
||||
break;
|
||||
case OPT_HASH:
|
||||
hash = ++num;
|
||||
break;
|
||||
case OPT_ISSUER:
|
||||
issuer = ++num;
|
||||
break;
|
||||
case OPT_LASTUPDATE:
|
||||
lastupdate = ++num;
|
||||
break;
|
||||
case OPT_NEXTUPDATE:
|
||||
nextupdate = ++num;
|
||||
break;
|
||||
case OPT_NOOUT:
|
||||
noout = ++num;
|
||||
break;
|
||||
case OPT_FINGERPRINT:
|
||||
fingerprint = ++num;
|
||||
break;
|
||||
case OPT_CRLNUMBER:
|
||||
crlnumber = ++num;
|
||||
break;
|
||||
case OPT_BADSIG:
|
||||
badsig = 1;
|
||||
break;
|
||||
case OPT_NAMEOPT:
|
||||
if (!set_nameopt(opt_arg()))
|
||||
goto opthelp;
|
||||
break;
|
||||
case OPT_MD:
|
||||
if (!opt_md(opt_unknown(), &digest))
|
||||
goto opthelp;
|
||||
}
|
||||
argc--;
|
||||
argv++;
|
||||
}
|
||||
argc = opt_num_rest();
|
||||
if (argc != 0)
|
||||
goto opthelp;
|
||||
|
||||
if (badops) {
|
||||
bad:
|
||||
for (pp = crl_usage; (*pp != NULL); pp++)
|
||||
BIO_printf(bio_err, "%s", *pp);
|
||||
goto end;
|
||||
}
|
||||
|
||||
ERR_load_crypto_strings();
|
||||
x = load_crl(infile, informat);
|
||||
if (x == NULL) {
|
||||
if (x == NULL)
|
||||
goto end;
|
||||
}
|
||||
|
||||
if (do_ver) {
|
||||
store = X509_STORE_new();
|
||||
if ((store = setup_verify(CAfile, CApath, noCAfile, noCApath)) == NULL)
|
||||
goto end;
|
||||
lookup = X509_STORE_add_lookup(store, X509_LOOKUP_file());
|
||||
if (lookup == NULL)
|
||||
goto end;
|
||||
if (!X509_LOOKUP_load_file(lookup, CAfile, X509_FILETYPE_PEM))
|
||||
X509_LOOKUP_load_file(lookup, NULL, X509_FILETYPE_DEFAULT);
|
||||
|
||||
lookup = X509_STORE_add_lookup(store, X509_LOOKUP_hash_dir());
|
||||
if (lookup == NULL)
|
||||
goto end;
|
||||
if (!X509_LOOKUP_add_dir(lookup, CApath, X509_FILETYPE_PEM))
|
||||
X509_LOOKUP_add_dir(lookup, NULL, X509_FILETYPE_DEFAULT);
|
||||
ERR_clear_error();
|
||||
|
||||
if (!X509_STORE_CTX_init(&ctx, store, NULL, NULL)) {
|
||||
ctx = X509_STORE_CTX_new();
|
||||
if (ctx == NULL || !X509_STORE_CTX_init(ctx, store, NULL, NULL)) {
|
||||
BIO_printf(bio_err, "Error initialising X509 store\n");
|
||||
goto end;
|
||||
}
|
||||
|
||||
i = X509_STORE_get_by_subject(&ctx, X509_LU_X509,
|
||||
X509_CRL_get_issuer(x), &xobj);
|
||||
if (i <= 0) {
|
||||
xobj = X509_STORE_CTX_get_obj_by_subject(ctx, X509_LU_X509,
|
||||
X509_CRL_get_issuer(x));
|
||||
if (xobj == NULL) {
|
||||
BIO_printf(bio_err, "Error getting CRL issuer certificate\n");
|
||||
goto end;
|
||||
}
|
||||
pkey = X509_get_pubkey(xobj.data.x509);
|
||||
X509_OBJECT_free_contents(&xobj);
|
||||
pkey = X509_get_pubkey(X509_OBJECT_get0_X509(xobj));
|
||||
X509_OBJECT_free(xobj);
|
||||
if (!pkey) {
|
||||
BIO_printf(bio_err, "Error getting CRL issuer public key\n");
|
||||
goto end;
|
||||
@ -304,8 +227,7 @@ int MAIN(int argc, char **argv)
|
||||
newcrl = load_crl(crldiff, informat);
|
||||
if (!newcrl)
|
||||
goto end;
|
||||
pkey = load_key(bio_err, keyfile, keyformat, 0, NULL, NULL,
|
||||
"CRL signing key");
|
||||
pkey = load_key(keyfile, keyformat, 0, NULL, NULL, "CRL signing key");
|
||||
if (!pkey) {
|
||||
X509_CRL_free(newcrl);
|
||||
goto end;
|
||||
@ -322,11 +244,18 @@ int MAIN(int argc, char **argv)
|
||||
}
|
||||
}
|
||||
|
||||
if (badsig) {
|
||||
const ASN1_BIT_STRING *sig;
|
||||
|
||||
X509_CRL_get0_signature(x, &sig, NULL);
|
||||
corrupt_signature(sig);
|
||||
}
|
||||
|
||||
if (num) {
|
||||
for (i = 1; i <= num; i++) {
|
||||
if (issuer == i) {
|
||||
print_name(bio_out, "issuer=", X509_CRL_get_issuer(x),
|
||||
nmflag);
|
||||
get_nameopt());
|
||||
}
|
||||
if (crlnumber == i) {
|
||||
ASN1_INTEGER *crlnum;
|
||||
@ -351,13 +280,13 @@ int MAIN(int argc, char **argv)
|
||||
#endif
|
||||
if (lastupdate == i) {
|
||||
BIO_printf(bio_out, "lastUpdate=");
|
||||
ASN1_TIME_print(bio_out, X509_CRL_get_lastUpdate(x));
|
||||
ASN1_TIME_print(bio_out, X509_CRL_get0_lastUpdate(x));
|
||||
BIO_printf(bio_out, "\n");
|
||||
}
|
||||
if (nextupdate == i) {
|
||||
BIO_printf(bio_out, "nextUpdate=");
|
||||
if (X509_CRL_get_nextUpdate(x))
|
||||
ASN1_TIME_print(bio_out, X509_CRL_get_nextUpdate(x));
|
||||
if (X509_CRL_get0_nextUpdate(x))
|
||||
ASN1_TIME_print(bio_out, X509_CRL_get0_nextUpdate(x));
|
||||
else
|
||||
BIO_printf(bio_out, "NONE");
|
||||
BIO_printf(bio_out, "\n");
|
||||
@ -380,63 +309,34 @@ int MAIN(int argc, char **argv)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
out = BIO_new(BIO_s_file());
|
||||
if (out == NULL) {
|
||||
ERR_print_errors(bio_err);
|
||||
out = bio_open_default(outfile, 'w', outformat);
|
||||
if (out == NULL)
|
||||
goto end;
|
||||
}
|
||||
|
||||
if (outfile == NULL) {
|
||||
BIO_set_fp(out, stdout, BIO_NOCLOSE);
|
||||
#ifdef OPENSSL_SYS_VMS
|
||||
{
|
||||
BIO *tmpbio = BIO_new(BIO_f_linebuffer());
|
||||
out = BIO_push(tmpbio, out);
|
||||
}
|
||||
#endif
|
||||
} else {
|
||||
if (BIO_write_filename(out, outfile) <= 0) {
|
||||
perror(outfile);
|
||||
goto end;
|
||||
}
|
||||
}
|
||||
|
||||
if (text)
|
||||
X509_CRL_print(out, x);
|
||||
X509_CRL_print_ex(out, x, get_nameopt());
|
||||
|
||||
if (noout) {
|
||||
ret = 0;
|
||||
goto end;
|
||||
}
|
||||
|
||||
if (badsig)
|
||||
x->signature->data[x->signature->length - 1] ^= 0x1;
|
||||
|
||||
if (outformat == FORMAT_ASN1)
|
||||
i = (int)i2d_X509_CRL_bio(out, x);
|
||||
else if (outformat == FORMAT_PEM)
|
||||
else
|
||||
i = PEM_write_bio_X509_CRL(out, x);
|
||||
else {
|
||||
BIO_printf(bio_err, "bad output format specified for outfile\n");
|
||||
goto end;
|
||||
}
|
||||
if (!i) {
|
||||
BIO_printf(bio_err, "unable to write CRL\n");
|
||||
goto end;
|
||||
}
|
||||
ret = 0;
|
||||
|
||||
end:
|
||||
if (ret != 0)
|
||||
ERR_print_errors(bio_err);
|
||||
BIO_free_all(out);
|
||||
BIO_free_all(bio_out);
|
||||
bio_out = NULL;
|
||||
X509_CRL_free(x);
|
||||
if (store) {
|
||||
X509_STORE_CTX_cleanup(&ctx);
|
||||
X509_STORE_free(store);
|
||||
}
|
||||
apps_shutdown();
|
||||
OPENSSL_EXIT(ret);
|
||||
X509_STORE_CTX_free(ctx);
|
||||
X509_STORE_free(store);
|
||||
return ret;
|
||||
}
|
||||
|
@ -1,71 +1,17 @@
|
||||
/* apps/crl2p7.c */
|
||||
/* Copyright (C) 1995-1998 Eric Young (eay@cryptsoft.com)
|
||||
* All rights reserved.
|
||||
*
|
||||
* This package is an SSL implementation written
|
||||
* by Eric Young (eay@cryptsoft.com).
|
||||
* The implementation was written so as to conform with Netscapes SSL.
|
||||
*
|
||||
* This library is free for commercial and non-commercial use as long as
|
||||
* the following conditions are aheared to. The following conditions
|
||||
* apply to all code found in this distribution, be it the RC4, RSA,
|
||||
* lhash, DES, etc., code; not just the SSL code. The SSL documentation
|
||||
* included with this distribution is covered by the same copyright terms
|
||||
* except that the holder is Tim Hudson (tjh@cryptsoft.com).
|
||||
*
|
||||
* Copyright remains Eric Young's, and as such any Copyright notices in
|
||||
* the code are not to be removed.
|
||||
* If this package is used in a product, Eric Young should be given attribution
|
||||
* as the author of the parts of the library used.
|
||||
* This can be in the form of a textual message at program startup or
|
||||
* in documentation (online or textual) provided with the package.
|
||||
*
|
||||
* Redistribution and use in source and binary forms, with or without
|
||||
* modification, are permitted provided that the following conditions
|
||||
* are met:
|
||||
* 1. Redistributions of source code must retain the copyright
|
||||
* notice, this list of conditions and the following disclaimer.
|
||||
* 2. Redistributions in binary form must reproduce the above copyright
|
||||
* notice, this list of conditions and the following disclaimer in the
|
||||
* documentation and/or other materials provided with the distribution.
|
||||
* 3. All advertising materials mentioning features or use of this software
|
||||
* must display the following acknowledgement:
|
||||
* "This product includes cryptographic software written by
|
||||
* Eric Young (eay@cryptsoft.com)"
|
||||
* The word 'cryptographic' can be left out if the rouines from the library
|
||||
* being used are not cryptographic related :-).
|
||||
* 4. If you include any Windows specific code (or a derivative thereof) from
|
||||
* the apps directory (application code) you must include an acknowledgement:
|
||||
* "This product includes software written by Tim Hudson (tjh@cryptsoft.com)"
|
||||
*
|
||||
* THIS SOFTWARE IS PROVIDED BY ERIC YOUNG ``AS IS'' AND
|
||||
* ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
|
||||
* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
|
||||
* ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE
|
||||
* FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
|
||||
* DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
|
||||
* OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
|
||||
* HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
|
||||
* LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
|
||||
* OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
|
||||
* SUCH DAMAGE.
|
||||
*
|
||||
* The licence and distribution terms for any publically available version or
|
||||
* derivative of this code cannot be changed. i.e. this code cannot simply be
|
||||
* copied and put under another distribution licence
|
||||
* [including the GNU Public Licence.]
|
||||
*/
|
||||
|
||||
/*
|
||||
* This was written by Gordon Chaffee <chaffee@plateau.cs.berkeley.edu> and
|
||||
* donated 'to the cause' along with lots and lots of other fixes to the
|
||||
* library.
|
||||
* Copyright 1995-2018 The OpenSSL Project Authors. All Rights Reserved.
|
||||
*
|
||||
* Licensed under the OpenSSL license (the "License"). You may not use
|
||||
* this file except in compliance with the License. You can obtain a copy
|
||||
* in the file LICENSE in the source distribution or at
|
||||
* https://www.openssl.org/source/license.html
|
||||
*/
|
||||
|
||||
#include <stdio.h>
|
||||
#include <string.h>
|
||||
#include <sys/types.h>
|
||||
#include "apps.h"
|
||||
#include "progs.h"
|
||||
#include <openssl/err.h>
|
||||
#include <openssl/evp.h>
|
||||
#include <openssl/x509.h>
|
||||
@ -74,129 +20,89 @@
|
||||
#include <openssl/objects.h>
|
||||
|
||||
static int add_certs_from_file(STACK_OF(X509) *stack, char *certfile);
|
||||
#undef PROG
|
||||
#define PROG crl2pkcs7_main
|
||||
|
||||
/*-
|
||||
* -inform arg - input format - default PEM (DER or PEM)
|
||||
* -outform arg - output format - default PEM
|
||||
* -in arg - input file - default stdin
|
||||
* -out arg - output file - default stdout
|
||||
*/
|
||||
typedef enum OPTION_choice {
|
||||
OPT_ERR = -1, OPT_EOF = 0, OPT_HELP,
|
||||
OPT_INFORM, OPT_OUTFORM, OPT_IN, OPT_OUT, OPT_NOCRL, OPT_CERTFILE
|
||||
} OPTION_CHOICE;
|
||||
|
||||
int MAIN(int, char **);
|
||||
const OPTIONS crl2pkcs7_options[] = {
|
||||
{"help", OPT_HELP, '-', "Display this summary"},
|
||||
{"inform", OPT_INFORM, 'F', "Input format - DER or PEM"},
|
||||
{"outform", OPT_OUTFORM, 'F', "Output format - DER or PEM"},
|
||||
{"in", OPT_IN, '<', "Input file"},
|
||||
{"out", OPT_OUT, '>', "Output file"},
|
||||
{"nocrl", OPT_NOCRL, '-', "No crl to load, just certs from '-certfile'"},
|
||||
{"certfile", OPT_CERTFILE, '<',
|
||||
"File of chain of certs to a trusted CA; can be repeated"},
|
||||
{NULL}
|
||||
};
|
||||
|
||||
int MAIN(int argc, char **argv)
|
||||
int crl2pkcs7_main(int argc, char **argv)
|
||||
{
|
||||
int i, badops = 0;
|
||||
BIO *in = NULL, *out = NULL;
|
||||
int informat, outformat;
|
||||
char *infile, *outfile, *prog, *certfile;
|
||||
PKCS7 *p7 = NULL;
|
||||
PKCS7_SIGNED *p7s = NULL;
|
||||
X509_CRL *crl = NULL;
|
||||
STACK_OF(OPENSSL_STRING) *certflst = NULL;
|
||||
STACK_OF(X509_CRL) *crl_stack = NULL;
|
||||
STACK_OF(X509) *cert_stack = NULL;
|
||||
int ret = 1, nocrl = 0;
|
||||
STACK_OF(X509_CRL) *crl_stack = NULL;
|
||||
X509_CRL *crl = NULL;
|
||||
char *infile = NULL, *outfile = NULL, *prog, *certfile;
|
||||
int i = 0, informat = FORMAT_PEM, outformat = FORMAT_PEM, ret = 1, nocrl =
|
||||
0;
|
||||
OPTION_CHOICE o;
|
||||
|
||||
apps_startup();
|
||||
|
||||
if (bio_err == NULL)
|
||||
if ((bio_err = BIO_new(BIO_s_file())) != NULL)
|
||||
BIO_set_fp(bio_err, stderr, BIO_NOCLOSE | BIO_FP_TEXT);
|
||||
|
||||
infile = NULL;
|
||||
outfile = NULL;
|
||||
informat = FORMAT_PEM;
|
||||
outformat = FORMAT_PEM;
|
||||
|
||||
prog = argv[0];
|
||||
argc--;
|
||||
argv++;
|
||||
while (argc >= 1) {
|
||||
if (strcmp(*argv, "-inform") == 0) {
|
||||
if (--argc < 1)
|
||||
goto bad;
|
||||
informat = str2fmt(*(++argv));
|
||||
} else if (strcmp(*argv, "-outform") == 0) {
|
||||
if (--argc < 1)
|
||||
goto bad;
|
||||
outformat = str2fmt(*(++argv));
|
||||
} else if (strcmp(*argv, "-in") == 0) {
|
||||
if (--argc < 1)
|
||||
goto bad;
|
||||
infile = *(++argv);
|
||||
} else if (strcmp(*argv, "-nocrl") == 0) {
|
||||
prog = opt_init(argc, argv, crl2pkcs7_options);
|
||||
while ((o = opt_next()) != OPT_EOF) {
|
||||
switch (o) {
|
||||
case OPT_EOF:
|
||||
case OPT_ERR:
|
||||
opthelp:
|
||||
BIO_printf(bio_err, "%s: Use -help for summary.\n", prog);
|
||||
goto end;
|
||||
case OPT_HELP:
|
||||
opt_help(crl2pkcs7_options);
|
||||
ret = 0;
|
||||
goto end;
|
||||
case OPT_INFORM:
|
||||
if (!opt_format(opt_arg(), OPT_FMT_PEMDER, &informat))
|
||||
goto opthelp;
|
||||
break;
|
||||
case OPT_OUTFORM:
|
||||
if (!opt_format(opt_arg(), OPT_FMT_PEMDER, &outformat))
|
||||
goto opthelp;
|
||||
break;
|
||||
case OPT_IN:
|
||||
infile = opt_arg();
|
||||
break;
|
||||
case OPT_OUT:
|
||||
outfile = opt_arg();
|
||||
break;
|
||||
case OPT_NOCRL:
|
||||
nocrl = 1;
|
||||
} else if (strcmp(*argv, "-out") == 0) {
|
||||
if (--argc < 1)
|
||||
goto bad;
|
||||
outfile = *(++argv);
|
||||
} else if (strcmp(*argv, "-certfile") == 0) {
|
||||
if (--argc < 1)
|
||||
goto bad;
|
||||
if (!certflst)
|
||||
certflst = sk_OPENSSL_STRING_new_null();
|
||||
if (!certflst)
|
||||
break;
|
||||
case OPT_CERTFILE:
|
||||
if ((certflst == NULL)
|
||||
&& (certflst = sk_OPENSSL_STRING_new_null()) == NULL)
|
||||
goto end;
|
||||
if (!sk_OPENSSL_STRING_push(certflst, *(++argv))) {
|
||||
sk_OPENSSL_STRING_free(certflst);
|
||||
if (!sk_OPENSSL_STRING_push(certflst, opt_arg()))
|
||||
goto end;
|
||||
}
|
||||
} else {
|
||||
BIO_printf(bio_err, "unknown option %s\n", *argv);
|
||||
badops = 1;
|
||||
break;
|
||||
}
|
||||
argc--;
|
||||
argv++;
|
||||
}
|
||||
|
||||
if (badops) {
|
||||
bad:
|
||||
BIO_printf(bio_err, "%s [options] <infile >outfile\n", prog);
|
||||
BIO_printf(bio_err, "where options are\n");
|
||||
BIO_printf(bio_err, " -inform arg input format - DER or PEM\n");
|
||||
BIO_printf(bio_err, " -outform arg output format - DER or PEM\n");
|
||||
BIO_printf(bio_err, " -in arg input file\n");
|
||||
BIO_printf(bio_err, " -out arg output file\n");
|
||||
BIO_printf(bio_err,
|
||||
" -certfile arg certificates file of chain to a trusted CA\n");
|
||||
BIO_printf(bio_err, " (can be used more than once)\n");
|
||||
BIO_printf(bio_err,
|
||||
" -nocrl no crl to load, just certs from '-certfile'\n");
|
||||
ret = 1;
|
||||
goto end;
|
||||
}
|
||||
|
||||
ERR_load_crypto_strings();
|
||||
|
||||
in = BIO_new(BIO_s_file());
|
||||
out = BIO_new(BIO_s_file());
|
||||
if ((in == NULL) || (out == NULL)) {
|
||||
ERR_print_errors(bio_err);
|
||||
goto end;
|
||||
}
|
||||
argc = opt_num_rest();
|
||||
if (argc != 0)
|
||||
goto opthelp;
|
||||
|
||||
if (!nocrl) {
|
||||
if (infile == NULL)
|
||||
BIO_set_fp(in, stdin, BIO_NOCLOSE);
|
||||
else {
|
||||
if (BIO_read_filename(in, infile) <= 0) {
|
||||
perror(infile);
|
||||
goto end;
|
||||
}
|
||||
}
|
||||
in = bio_open_default(infile, 'r', informat);
|
||||
if (in == NULL)
|
||||
goto end;
|
||||
|
||||
if (informat == FORMAT_ASN1)
|
||||
crl = d2i_X509_CRL_bio(in, NULL);
|
||||
else if (informat == FORMAT_PEM)
|
||||
crl = PEM_read_bio_X509_CRL(in, NULL, NULL, NULL);
|
||||
else {
|
||||
BIO_printf(bio_err, "bad input format specified for input crl\n");
|
||||
goto end;
|
||||
}
|
||||
if (crl == NULL) {
|
||||
BIO_printf(bio_err, "unable to load CRL\n");
|
||||
ERR_print_errors(bio_err);
|
||||
@ -226,7 +132,7 @@ int MAIN(int argc, char **argv)
|
||||
goto end;
|
||||
p7s->cert = cert_stack;
|
||||
|
||||
if (certflst)
|
||||
if (certflst != NULL)
|
||||
for (i = 0; i < sk_OPENSSL_STRING_num(certflst); i++) {
|
||||
certfile = sk_OPENSSL_STRING_value(certflst, i);
|
||||
if (add_certs_from_file(cert_stack, certfile) < 0) {
|
||||
@ -236,31 +142,14 @@ int MAIN(int argc, char **argv)
|
||||
}
|
||||
}
|
||||
|
||||
sk_OPENSSL_STRING_free(certflst);
|
||||
|
||||
if (outfile == NULL) {
|
||||
BIO_set_fp(out, stdout, BIO_NOCLOSE);
|
||||
#ifdef OPENSSL_SYS_VMS
|
||||
{
|
||||
BIO *tmpbio = BIO_new(BIO_f_linebuffer());
|
||||
out = BIO_push(tmpbio, out);
|
||||
}
|
||||
#endif
|
||||
} else {
|
||||
if (BIO_write_filename(out, outfile) <= 0) {
|
||||
perror(outfile);
|
||||
goto end;
|
||||
}
|
||||
}
|
||||
out = bio_open_default(outfile, 'w', outformat);
|
||||
if (out == NULL)
|
||||
goto end;
|
||||
|
||||
if (outformat == FORMAT_ASN1)
|
||||
i = i2d_PKCS7_bio(out, p7);
|
||||
else if (outformat == FORMAT_PEM)
|
||||
i = PEM_write_bio_PKCS7(out, p7);
|
||||
else {
|
||||
BIO_printf(bio_err, "bad output format specified for outfile\n");
|
||||
goto end;
|
||||
}
|
||||
if (!i) {
|
||||
BIO_printf(bio_err, "unable to write pkcs7 object\n");
|
||||
ERR_print_errors(bio_err);
|
||||
@ -268,17 +157,13 @@ int MAIN(int argc, char **argv)
|
||||
}
|
||||
ret = 0;
|
||||
end:
|
||||
if (in != NULL)
|
||||
BIO_free(in);
|
||||
if (out != NULL)
|
||||
BIO_free_all(out);
|
||||
if (p7 != NULL)
|
||||
PKCS7_free(p7);
|
||||
if (crl != NULL)
|
||||
X509_CRL_free(crl);
|
||||
sk_OPENSSL_STRING_free(certflst);
|
||||
BIO_free(in);
|
||||
BIO_free_all(out);
|
||||
PKCS7_free(p7);
|
||||
X509_CRL_free(crl);
|
||||
|
||||
apps_shutdown();
|
||||
OPENSSL_EXIT(ret);
|
||||
return ret;
|
||||
}
|
||||
|
||||
/*-
|
||||
@ -299,8 +184,8 @@ static int add_certs_from_file(STACK_OF(X509) *stack, char *certfile)
|
||||
STACK_OF(X509_INFO) *sk = NULL;
|
||||
X509_INFO *xi;
|
||||
|
||||
in = BIO_new(BIO_s_file());
|
||||
if ((in == NULL) || (BIO_read_filename(in, certfile) <= 0)) {
|
||||
in = BIO_new_file(certfile, "r");
|
||||
if (in == NULL) {
|
||||
BIO_printf(bio_err, "error opening the file, %s\n", certfile);
|
||||
goto end;
|
||||
}
|
||||
@ -326,9 +211,7 @@ static int add_certs_from_file(STACK_OF(X509) *stack, char *certfile)
|
||||
ret = count;
|
||||
end:
|
||||
/* never need to OPENSSL_free x */
|
||||
if (in != NULL)
|
||||
BIO_free(in);
|
||||
if (sk != NULL)
|
||||
sk_X509_INFO_free(sk);
|
||||
return (ret);
|
||||
BIO_free(in);
|
||||
sk_X509_INFO_free(sk);
|
||||
return ret;
|
||||
}
|
||||
|
9
crypto/openssl/apps/ct_log_list.cnf
Normal file
9
crypto/openssl/apps/ct_log_list.cnf
Normal file
@ -0,0 +1,9 @@
|
||||
# This file specifies the Certificate Transparency logs
|
||||
# that are to be trusted.
|
||||
|
||||
# Google's list of logs can be found here:
|
||||
# www.certificate-transparency.org/known-logs
|
||||
# A Python program to convert the log list to OpenSSL's format can be
|
||||
# found here:
|
||||
# https://github.com/google/certificate-transparency/blob/master/python/utilities/log_list/print_log_list.py
|
||||
# Use the "--openssl_output" flag.
|
@ -1,65 +1,17 @@
|
||||
/* apps/dgst.c */
|
||||
/* Copyright (C) 1995-1998 Eric Young (eay@cryptsoft.com)
|
||||
* All rights reserved.
|
||||
/*
|
||||
* Copyright 1995-2018 The OpenSSL Project Authors. All Rights Reserved.
|
||||
*
|
||||
* This package is an SSL implementation written
|
||||
* by Eric Young (eay@cryptsoft.com).
|
||||
* The implementation was written so as to conform with Netscapes SSL.
|
||||
*
|
||||
* This library is free for commercial and non-commercial use as long as
|
||||
* the following conditions are aheared to. The following conditions
|
||||
* apply to all code found in this distribution, be it the RC4, RSA,
|
||||
* lhash, DES, etc., code; not just the SSL code. The SSL documentation
|
||||
* included with this distribution is covered by the same copyright terms
|
||||
* except that the holder is Tim Hudson (tjh@cryptsoft.com).
|
||||
*
|
||||
* Copyright remains Eric Young's, and as such any Copyright notices in
|
||||
* the code are not to be removed.
|
||||
* If this package is used in a product, Eric Young should be given attribution
|
||||
* as the author of the parts of the library used.
|
||||
* This can be in the form of a textual message at program startup or
|
||||
* in documentation (online or textual) provided with the package.
|
||||
*
|
||||
* Redistribution and use in source and binary forms, with or without
|
||||
* modification, are permitted provided that the following conditions
|
||||
* are met:
|
||||
* 1. Redistributions of source code must retain the copyright
|
||||
* notice, this list of conditions and the following disclaimer.
|
||||
* 2. Redistributions in binary form must reproduce the above copyright
|
||||
* notice, this list of conditions and the following disclaimer in the
|
||||
* documentation and/or other materials provided with the distribution.
|
||||
* 3. All advertising materials mentioning features or use of this software
|
||||
* must display the following acknowledgement:
|
||||
* "This product includes cryptographic software written by
|
||||
* Eric Young (eay@cryptsoft.com)"
|
||||
* The word 'cryptographic' can be left out if the rouines from the library
|
||||
* being used are not cryptographic related :-).
|
||||
* 4. If you include any Windows specific code (or a derivative thereof) from
|
||||
* the apps directory (application code) you must include an acknowledgement:
|
||||
* "This product includes software written by Tim Hudson (tjh@cryptsoft.com)"
|
||||
*
|
||||
* THIS SOFTWARE IS PROVIDED BY ERIC YOUNG ``AS IS'' AND
|
||||
* ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
|
||||
* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
|
||||
* ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE
|
||||
* FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
|
||||
* DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
|
||||
* OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
|
||||
* HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
|
||||
* LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
|
||||
* OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
|
||||
* SUCH DAMAGE.
|
||||
*
|
||||
* The licence and distribution terms for any publically available version or
|
||||
* derivative of this code cannot be changed. i.e. this code cannot simply be
|
||||
* copied and put under another distribution licence
|
||||
* [including the GNU Public Licence.]
|
||||
* Licensed under the OpenSSL license (the "License"). You may not use
|
||||
* this file except in compliance with the License. You can obtain a copy
|
||||
* in the file LICENSE in the source distribution or at
|
||||
* https://www.openssl.org/source/license.html
|
||||
*/
|
||||
|
||||
#include <stdio.h>
|
||||
#include <string.h>
|
||||
#include <stdlib.h>
|
||||
#include "apps.h"
|
||||
#include "progs.h"
|
||||
#include <openssl/bio.h>
|
||||
#include <openssl/err.h>
|
||||
#include <openssl/evp.h>
|
||||
@ -71,230 +23,182 @@
|
||||
#undef BUFSIZE
|
||||
#define BUFSIZE 1024*8
|
||||
|
||||
#undef PROG
|
||||
#define PROG dgst_main
|
||||
|
||||
int do_fp(BIO *out, unsigned char *buf, BIO *bp, int sep, int binout,
|
||||
EVP_PKEY *key, unsigned char *sigin, int siglen,
|
||||
const char *sig_name, const char *md_name,
|
||||
const char *file, BIO *bmd);
|
||||
const char *file);
|
||||
|
||||
static void list_md_fn(const EVP_MD *m,
|
||||
const char *from, const char *to, void *arg)
|
||||
{
|
||||
const char *mname;
|
||||
/* Skip aliases */
|
||||
if (!m)
|
||||
return;
|
||||
mname = OBJ_nid2ln(EVP_MD_type(m));
|
||||
/* Skip shortnames */
|
||||
if (strcmp(from, mname))
|
||||
return;
|
||||
/* Skip clones */
|
||||
if (EVP_MD_flags(m) & EVP_MD_FLAG_PKEY_DIGEST)
|
||||
return;
|
||||
if (strchr(mname, ' '))
|
||||
mname = EVP_MD_name(m);
|
||||
BIO_printf(arg, "-%-14s to use the %s message digest algorithm\n",
|
||||
mname, mname);
|
||||
}
|
||||
typedef enum OPTION_choice {
|
||||
OPT_ERR = -1, OPT_EOF = 0, OPT_HELP,
|
||||
OPT_C, OPT_R, OPT_OUT, OPT_SIGN, OPT_PASSIN, OPT_VERIFY,
|
||||
OPT_PRVERIFY, OPT_SIGNATURE, OPT_KEYFORM, OPT_ENGINE, OPT_ENGINE_IMPL,
|
||||
OPT_HEX, OPT_BINARY, OPT_DEBUG, OPT_FIPS_FINGERPRINT,
|
||||
OPT_HMAC, OPT_MAC, OPT_SIGOPT, OPT_MACOPT,
|
||||
OPT_DIGEST,
|
||||
OPT_R_ENUM
|
||||
} OPTION_CHOICE;
|
||||
|
||||
int MAIN(int, char **);
|
||||
|
||||
int MAIN(int argc, char **argv)
|
||||
{
|
||||
ENGINE *e = NULL, *impl = NULL;
|
||||
unsigned char *buf = NULL;
|
||||
int i, err = 1;
|
||||
const EVP_MD *md = NULL, *m;
|
||||
BIO *in = NULL, *inp;
|
||||
BIO *bmd = NULL;
|
||||
BIO *out = NULL;
|
||||
#define PROG_NAME_SIZE 39
|
||||
char pname[PROG_NAME_SIZE + 1];
|
||||
int separator = 0;
|
||||
int debug = 0;
|
||||
int keyform = FORMAT_PEM;
|
||||
const char *outfile = NULL, *keyfile = NULL;
|
||||
const char *sigfile = NULL, *randfile = NULL;
|
||||
int out_bin = -1, want_pub = 0, do_verify = 0;
|
||||
EVP_PKEY *sigkey = NULL;
|
||||
unsigned char *sigbuf = NULL;
|
||||
int siglen = 0;
|
||||
char *passargin = NULL, *passin = NULL;
|
||||
const OPTIONS dgst_options[] = {
|
||||
{OPT_HELP_STR, 1, '-', "Usage: %s [options] [file...]\n"},
|
||||
{OPT_HELP_STR, 1, '-',
|
||||
" file... files to digest (default is stdin)\n"},
|
||||
{"help", OPT_HELP, '-', "Display this summary"},
|
||||
{"c", OPT_C, '-', "Print the digest with separating colons"},
|
||||
{"r", OPT_R, '-', "Print the digest in coreutils format"},
|
||||
{"out", OPT_OUT, '>', "Output to filename rather than stdout"},
|
||||
{"passin", OPT_PASSIN, 's', "Input file pass phrase source"},
|
||||
{"sign", OPT_SIGN, 's', "Sign digest using private key"},
|
||||
{"verify", OPT_VERIFY, 's',
|
||||
"Verify a signature using public key"},
|
||||
{"prverify", OPT_PRVERIFY, 's',
|
||||
"Verify a signature using private key"},
|
||||
{"signature", OPT_SIGNATURE, '<', "File with signature to verify"},
|
||||
{"keyform", OPT_KEYFORM, 'f', "Key file format (PEM or ENGINE)"},
|
||||
{"hex", OPT_HEX, '-', "Print as hex dump"},
|
||||
{"binary", OPT_BINARY, '-', "Print in binary form"},
|
||||
{"d", OPT_DEBUG, '-', "Print debug info"},
|
||||
{"debug", OPT_DEBUG, '-', "Print debug info"},
|
||||
{"fips-fingerprint", OPT_FIPS_FINGERPRINT, '-',
|
||||
"Compute HMAC with the key used in OpenSSL-FIPS fingerprint"},
|
||||
{"hmac", OPT_HMAC, 's', "Create hashed MAC with key"},
|
||||
{"mac", OPT_MAC, 's', "Create MAC (not necessarily HMAC)"},
|
||||
{"sigopt", OPT_SIGOPT, 's', "Signature parameter in n:v form"},
|
||||
{"macopt", OPT_MACOPT, 's', "MAC algorithm parameters in n:v form or key"},
|
||||
{"", OPT_DIGEST, '-', "Any supported digest"},
|
||||
OPT_R_OPTIONS,
|
||||
#ifndef OPENSSL_NO_ENGINE
|
||||
char *engine = NULL;
|
||||
int engine_impl = 0;
|
||||
{"engine", OPT_ENGINE, 's', "Use engine e, possibly a hardware device"},
|
||||
{"engine_impl", OPT_ENGINE_IMPL, '-',
|
||||
"Also use engine given by -engine for digest operations"},
|
||||
#endif
|
||||
{NULL}
|
||||
};
|
||||
|
||||
int dgst_main(int argc, char **argv)
|
||||
{
|
||||
BIO *in = NULL, *inp, *bmd = NULL, *out = NULL;
|
||||
ENGINE *e = NULL, *impl = NULL;
|
||||
EVP_PKEY *sigkey = NULL;
|
||||
STACK_OF(OPENSSL_STRING) *sigopts = NULL, *macopts = NULL;
|
||||
char *hmac_key = NULL;
|
||||
char *mac_name = NULL;
|
||||
int non_fips_allow = 0;
|
||||
STACK_OF(OPENSSL_STRING) *sigopts = NULL, *macopts = NULL;
|
||||
char *passinarg = NULL, *passin = NULL;
|
||||
const EVP_MD *md = NULL, *m;
|
||||
const char *outfile = NULL, *keyfile = NULL, *prog = NULL;
|
||||
const char *sigfile = NULL;
|
||||
OPTION_CHOICE o;
|
||||
int separator = 0, debug = 0, keyform = FORMAT_PEM, siglen = 0;
|
||||
int i, ret = 1, out_bin = -1, want_pub = 0, do_verify = 0;
|
||||
unsigned char *buf = NULL, *sigbuf = NULL;
|
||||
int engine_impl = 0;
|
||||
|
||||
apps_startup();
|
||||
prog = opt_progname(argv[0]);
|
||||
buf = app_malloc(BUFSIZE, "I/O buffer");
|
||||
md = EVP_get_digestbyname(prog);
|
||||
|
||||
if ((buf = (unsigned char *)OPENSSL_malloc(BUFSIZE)) == NULL) {
|
||||
BIO_printf(bio_err, "out of memory\n");
|
||||
goto end;
|
||||
}
|
||||
if (bio_err == NULL)
|
||||
if ((bio_err = BIO_new(BIO_s_file())) != NULL)
|
||||
BIO_set_fp(bio_err, stderr, BIO_NOCLOSE | BIO_FP_TEXT);
|
||||
|
||||
if (!load_config(bio_err, NULL))
|
||||
goto end;
|
||||
|
||||
/* first check the program name */
|
||||
program_name(argv[0], pname, sizeof(pname));
|
||||
|
||||
md = EVP_get_digestbyname(pname);
|
||||
|
||||
argc--;
|
||||
argv++;
|
||||
while (argc > 0) {
|
||||
if ((*argv)[0] != '-')
|
||||
break;
|
||||
if (strcmp(*argv, "-c") == 0)
|
||||
prog = opt_init(argc, argv, dgst_options);
|
||||
while ((o = opt_next()) != OPT_EOF) {
|
||||
switch (o) {
|
||||
case OPT_EOF:
|
||||
case OPT_ERR:
|
||||
opthelp:
|
||||
BIO_printf(bio_err, "%s: Use -help for summary.\n", prog);
|
||||
goto end;
|
||||
case OPT_HELP:
|
||||
opt_help(dgst_options);
|
||||
ret = 0;
|
||||
goto end;
|
||||
case OPT_C:
|
||||
separator = 1;
|
||||
else if (strcmp(*argv, "-r") == 0)
|
||||
break;
|
||||
case OPT_R:
|
||||
separator = 2;
|
||||
else if (strcmp(*argv, "-rand") == 0) {
|
||||
if (--argc < 1)
|
||||
break;
|
||||
randfile = *(++argv);
|
||||
} else if (strcmp(*argv, "-out") == 0) {
|
||||
if (--argc < 1)
|
||||
break;
|
||||
outfile = *(++argv);
|
||||
} else if (strcmp(*argv, "-sign") == 0) {
|
||||
if (--argc < 1)
|
||||
break;
|
||||
keyfile = *(++argv);
|
||||
} else if (!strcmp(*argv, "-passin")) {
|
||||
if (--argc < 1)
|
||||
break;
|
||||
passargin = *++argv;
|
||||
} else if (strcmp(*argv, "-verify") == 0) {
|
||||
if (--argc < 1)
|
||||
break;
|
||||
keyfile = *(++argv);
|
||||
want_pub = 1;
|
||||
break;
|
||||
case OPT_R_CASES:
|
||||
if (!opt_rand(o))
|
||||
goto end;
|
||||
break;
|
||||
case OPT_OUT:
|
||||
outfile = opt_arg();
|
||||
break;
|
||||
case OPT_SIGN:
|
||||
keyfile = opt_arg();
|
||||
break;
|
||||
case OPT_PASSIN:
|
||||
passinarg = opt_arg();
|
||||
break;
|
||||
case OPT_VERIFY:
|
||||
keyfile = opt_arg();
|
||||
want_pub = do_verify = 1;
|
||||
break;
|
||||
case OPT_PRVERIFY:
|
||||
keyfile = opt_arg();
|
||||
do_verify = 1;
|
||||
} else if (strcmp(*argv, "-prverify") == 0) {
|
||||
if (--argc < 1)
|
||||
break;
|
||||
keyfile = *(++argv);
|
||||
do_verify = 1;
|
||||
} else if (strcmp(*argv, "-signature") == 0) {
|
||||
if (--argc < 1)
|
||||
break;
|
||||
sigfile = *(++argv);
|
||||
} else if (strcmp(*argv, "-keyform") == 0) {
|
||||
if (--argc < 1)
|
||||
break;
|
||||
keyform = str2fmt(*(++argv));
|
||||
}
|
||||
#ifndef OPENSSL_NO_ENGINE
|
||||
else if (strcmp(*argv, "-engine") == 0) {
|
||||
if (--argc < 1)
|
||||
break;
|
||||
engine = *(++argv);
|
||||
e = setup_engine(bio_err, engine, 0);
|
||||
} else if (strcmp(*argv, "-engine_impl") == 0)
|
||||
break;
|
||||
case OPT_SIGNATURE:
|
||||
sigfile = opt_arg();
|
||||
break;
|
||||
case OPT_KEYFORM:
|
||||
if (!opt_format(opt_arg(), OPT_FMT_ANY, &keyform))
|
||||
goto opthelp;
|
||||
break;
|
||||
case OPT_ENGINE:
|
||||
e = setup_engine(opt_arg(), 0);
|
||||
break;
|
||||
case OPT_ENGINE_IMPL:
|
||||
engine_impl = 1;
|
||||
#endif
|
||||
else if (strcmp(*argv, "-hex") == 0)
|
||||
break;
|
||||
case OPT_HEX:
|
||||
out_bin = 0;
|
||||
else if (strcmp(*argv, "-binary") == 0)
|
||||
break;
|
||||
case OPT_BINARY:
|
||||
out_bin = 1;
|
||||
else if (strcmp(*argv, "-d") == 0)
|
||||
break;
|
||||
case OPT_DEBUG:
|
||||
debug = 1;
|
||||
else if (!strcmp(*argv, "-fips-fingerprint"))
|
||||
break;
|
||||
case OPT_FIPS_FINGERPRINT:
|
||||
hmac_key = "etaonrishdlcupfm";
|
||||
else if (strcmp(*argv, "-non-fips-allow") == 0)
|
||||
non_fips_allow = 1;
|
||||
else if (!strcmp(*argv, "-hmac")) {
|
||||
if (--argc < 1)
|
||||
break;
|
||||
hmac_key = *++argv;
|
||||
} else if (!strcmp(*argv, "-mac")) {
|
||||
if (--argc < 1)
|
||||
break;
|
||||
mac_name = *++argv;
|
||||
} else if (strcmp(*argv, "-sigopt") == 0) {
|
||||
if (--argc < 1)
|
||||
break;
|
||||
break;
|
||||
case OPT_HMAC:
|
||||
hmac_key = opt_arg();
|
||||
break;
|
||||
case OPT_MAC:
|
||||
mac_name = opt_arg();
|
||||
break;
|
||||
case OPT_SIGOPT:
|
||||
if (!sigopts)
|
||||
sigopts = sk_OPENSSL_STRING_new_null();
|
||||
if (!sigopts || !sk_OPENSSL_STRING_push(sigopts, *(++argv)))
|
||||
break;
|
||||
} else if (strcmp(*argv, "-macopt") == 0) {
|
||||
if (--argc < 1)
|
||||
break;
|
||||
if (!sigopts || !sk_OPENSSL_STRING_push(sigopts, opt_arg()))
|
||||
goto opthelp;
|
||||
break;
|
||||
case OPT_MACOPT:
|
||||
if (!macopts)
|
||||
macopts = sk_OPENSSL_STRING_new_null();
|
||||
if (!macopts || !sk_OPENSSL_STRING_push(macopts, *(++argv)))
|
||||
break;
|
||||
} else if ((m = EVP_get_digestbyname(&((*argv)[1]))) != NULL)
|
||||
md = m;
|
||||
else
|
||||
if (!macopts || !sk_OPENSSL_STRING_push(macopts, opt_arg()))
|
||||
goto opthelp;
|
||||
break;
|
||||
argc--;
|
||||
argv++;
|
||||
case OPT_DIGEST:
|
||||
if (!opt_md(opt_unknown(), &m))
|
||||
goto opthelp;
|
||||
md = m;
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
argc = opt_num_rest();
|
||||
argv = opt_rest();
|
||||
if (keyfile != NULL && argc > 1) {
|
||||
BIO_printf(bio_err, "Can only sign or verify one file\n");
|
||||
BIO_printf(bio_err, "%s: Can only sign or verify one file.\n", prog);
|
||||
goto end;
|
||||
}
|
||||
|
||||
if (do_verify && !sigfile) {
|
||||
if (do_verify && sigfile == NULL) {
|
||||
BIO_printf(bio_err,
|
||||
"No signature to verify: use the -signature option\n");
|
||||
goto end;
|
||||
}
|
||||
|
||||
if ((argc > 0) && (argv[0][0] == '-')) { /* bad option */
|
||||
BIO_printf(bio_err, "unknown option '%s'\n", *argv);
|
||||
BIO_printf(bio_err, "options are\n");
|
||||
BIO_printf(bio_err,
|
||||
"-c to output the digest with separating colons\n");
|
||||
BIO_printf(bio_err,
|
||||
"-r to output the digest in coreutils format\n");
|
||||
BIO_printf(bio_err, "-d to output debug info\n");
|
||||
BIO_printf(bio_err, "-hex output as hex dump\n");
|
||||
BIO_printf(bio_err, "-binary output in binary form\n");
|
||||
BIO_printf(bio_err, "-hmac arg set the HMAC key to arg\n");
|
||||
BIO_printf(bio_err, "-non-fips-allow allow use of non FIPS digest\n");
|
||||
BIO_printf(bio_err,
|
||||
"-sign file sign digest using private key in file\n");
|
||||
BIO_printf(bio_err,
|
||||
"-verify file verify a signature using public key in file\n");
|
||||
BIO_printf(bio_err,
|
||||
"-prverify file verify a signature using private key in file\n");
|
||||
BIO_printf(bio_err,
|
||||
"-keyform arg key file format (PEM or ENGINE)\n");
|
||||
BIO_printf(bio_err,
|
||||
"-out filename output to filename rather than stdout\n");
|
||||
BIO_printf(bio_err, "-signature file signature to verify\n");
|
||||
BIO_printf(bio_err, "-sigopt nm:v signature parameter\n");
|
||||
BIO_printf(bio_err, "-hmac key create hashed MAC with key\n");
|
||||
BIO_printf(bio_err,
|
||||
"-mac algorithm create MAC (not neccessarily HMAC)\n");
|
||||
BIO_printf(bio_err,
|
||||
"-macopt nm:v MAC algorithm parameters or key\n");
|
||||
#ifndef OPENSSL_NO_ENGINE
|
||||
BIO_printf(bio_err,
|
||||
"-engine e use engine e, possibly a hardware device.\n");
|
||||
#endif
|
||||
|
||||
EVP_MD_do_all_sorted(list_md_fn, bio_err);
|
||||
goto end;
|
||||
}
|
||||
#ifndef OPENSSL_NO_ENGINE
|
||||
if (engine_impl)
|
||||
impl = e;
|
||||
#endif
|
||||
|
||||
in = BIO_new(BIO_s_file());
|
||||
bmd = BIO_new(BIO_f_md());
|
||||
@ -309,68 +213,57 @@ int MAIN(int argc, char **argv)
|
||||
BIO_set_callback_arg(in, (char *)bio_err);
|
||||
}
|
||||
|
||||
if (!app_passwd(bio_err, passargin, NULL, &passin, NULL)) {
|
||||
if (!app_passwd(passinarg, NULL, &passin, NULL)) {
|
||||
BIO_printf(bio_err, "Error getting password\n");
|
||||
goto end;
|
||||
}
|
||||
|
||||
if (out_bin == -1) {
|
||||
if (keyfile)
|
||||
if (keyfile != NULL)
|
||||
out_bin = 1;
|
||||
else
|
||||
out_bin = 0;
|
||||
}
|
||||
|
||||
if (randfile)
|
||||
app_RAND_load_file(randfile, bio_err, 0);
|
||||
|
||||
if (outfile) {
|
||||
if (out_bin)
|
||||
out = BIO_new_file(outfile, "wb");
|
||||
else
|
||||
out = BIO_new_file(outfile, "w");
|
||||
} else {
|
||||
out = BIO_new_fp(stdout, BIO_NOCLOSE);
|
||||
#ifdef OPENSSL_SYS_VMS
|
||||
{
|
||||
BIO *tmpbio = BIO_new(BIO_f_linebuffer());
|
||||
out = BIO_push(tmpbio, out);
|
||||
}
|
||||
#endif
|
||||
}
|
||||
|
||||
if (!out) {
|
||||
BIO_printf(bio_err, "Error opening output file %s\n",
|
||||
outfile ? outfile : "(stdout)");
|
||||
ERR_print_errors(bio_err);
|
||||
out = bio_open_default(outfile, 'w', out_bin ? FORMAT_BINARY : FORMAT_TEXT);
|
||||
if (out == NULL)
|
||||
goto end;
|
||||
}
|
||||
if ((! !mac_name + ! !keyfile + ! !hmac_key) > 1) {
|
||||
|
||||
if ((!(mac_name == NULL) + !(keyfile == NULL) + !(hmac_key == NULL)) > 1) {
|
||||
BIO_printf(bio_err, "MAC and Signing key cannot both be specified\n");
|
||||
goto end;
|
||||
}
|
||||
|
||||
if (keyfile) {
|
||||
if (keyfile != NULL) {
|
||||
int type;
|
||||
|
||||
if (want_pub)
|
||||
sigkey = load_pubkey(bio_err, keyfile, keyform, 0, NULL,
|
||||
e, "key file");
|
||||
sigkey = load_pubkey(keyfile, keyform, 0, NULL, e, "key file");
|
||||
else
|
||||
sigkey = load_key(bio_err, keyfile, keyform, 0, passin,
|
||||
e, "key file");
|
||||
if (!sigkey) {
|
||||
sigkey = load_key(keyfile, keyform, 0, passin, e, "key file");
|
||||
if (sigkey == NULL) {
|
||||
/*
|
||||
* load_[pub]key() has already printed an appropriate message
|
||||
*/
|
||||
goto end;
|
||||
}
|
||||
type = EVP_PKEY_id(sigkey);
|
||||
if (type == EVP_PKEY_ED25519 || type == EVP_PKEY_ED448) {
|
||||
/*
|
||||
* We implement PureEdDSA for these which doesn't have a separate
|
||||
* digest, and only supports one shot.
|
||||
*/
|
||||
BIO_printf(bio_err, "Key type not supported for this operation\n");
|
||||
goto end;
|
||||
}
|
||||
}
|
||||
|
||||
if (mac_name) {
|
||||
if (mac_name != NULL) {
|
||||
EVP_PKEY_CTX *mac_ctx = NULL;
|
||||
int r = 0;
|
||||
if (!init_gen_str(bio_err, &mac_ctx, mac_name, impl, 0))
|
||||
if (!init_gen_str(&mac_ctx, mac_name, impl, 0))
|
||||
goto mac_end;
|
||||
if (macopts) {
|
||||
if (macopts != NULL) {
|
||||
char *macopt;
|
||||
for (i = 0; i < sk_OPENSSL_STRING_num(macopts); i++) {
|
||||
macopt = sk_OPENSSL_STRING_value(macopts, i);
|
||||
@ -389,26 +282,19 @@ int MAIN(int argc, char **argv)
|
||||
}
|
||||
r = 1;
|
||||
mac_end:
|
||||
if (mac_ctx)
|
||||
EVP_PKEY_CTX_free(mac_ctx);
|
||||
EVP_PKEY_CTX_free(mac_ctx);
|
||||
if (r == 0)
|
||||
goto end;
|
||||
}
|
||||
|
||||
if (non_fips_allow) {
|
||||
EVP_MD_CTX *md_ctx;
|
||||
BIO_get_md_ctx(bmd, &md_ctx);
|
||||
EVP_MD_CTX_set_flags(md_ctx, EVP_MD_CTX_FLAG_NON_FIPS_ALLOW);
|
||||
}
|
||||
|
||||
if (hmac_key) {
|
||||
sigkey = EVP_PKEY_new_mac_key(EVP_PKEY_HMAC, impl,
|
||||
(unsigned char *)hmac_key, -1);
|
||||
if (!sigkey)
|
||||
if (hmac_key != NULL) {
|
||||
sigkey = EVP_PKEY_new_raw_private_key(EVP_PKEY_HMAC, impl,
|
||||
(unsigned char *)hmac_key, -1);
|
||||
if (sigkey == NULL)
|
||||
goto end;
|
||||
}
|
||||
|
||||
if (sigkey) {
|
||||
if (sigkey != NULL) {
|
||||
EVP_MD_CTX *mctx = NULL;
|
||||
EVP_PKEY_CTX *pctx = NULL;
|
||||
int r;
|
||||
@ -426,7 +312,7 @@ int MAIN(int argc, char **argv)
|
||||
ERR_print_errors(bio_err);
|
||||
goto end;
|
||||
}
|
||||
if (sigopts) {
|
||||
if (sigopts != NULL) {
|
||||
char *sigopt;
|
||||
for (i = 0; i < sk_OPENSSL_STRING_num(sigopts); i++) {
|
||||
sigopt = sk_OPENSSL_STRING_value(sigopts, i);
|
||||
@ -447,29 +333,23 @@ int MAIN(int argc, char **argv)
|
||||
goto end;
|
||||
}
|
||||
if (md == NULL)
|
||||
md = EVP_md5();
|
||||
md = EVP_sha256();
|
||||
if (!EVP_DigestInit_ex(mctx, md, impl)) {
|
||||
BIO_printf(bio_err, "Error setting digest %s\n", pname);
|
||||
BIO_printf(bio_err, "Error setting digest\n");
|
||||
ERR_print_errors(bio_err);
|
||||
goto end;
|
||||
}
|
||||
}
|
||||
|
||||
if (sigfile && sigkey) {
|
||||
BIO *sigbio;
|
||||
sigbio = BIO_new_file(sigfile, "rb");
|
||||
siglen = EVP_PKEY_size(sigkey);
|
||||
sigbuf = OPENSSL_malloc(siglen);
|
||||
if (!sigbio) {
|
||||
if (sigfile != NULL && sigkey != NULL) {
|
||||
BIO *sigbio = BIO_new_file(sigfile, "rb");
|
||||
if (sigbio == NULL) {
|
||||
BIO_printf(bio_err, "Error opening signature file %s\n", sigfile);
|
||||
ERR_print_errors(bio_err);
|
||||
goto end;
|
||||
}
|
||||
if (!sigbuf) {
|
||||
BIO_printf(bio_err, "Out of memory\n");
|
||||
ERR_print_errors(bio_err);
|
||||
goto end;
|
||||
}
|
||||
siglen = EVP_PKEY_size(sigkey);
|
||||
sigbuf = app_malloc(siglen, "signature buffer");
|
||||
siglen = BIO_read(sigbio, sigbuf, siglen);
|
||||
BIO_free(sigbio);
|
||||
if (siglen <= 0) {
|
||||
@ -488,64 +368,55 @@ int MAIN(int argc, char **argv)
|
||||
|
||||
if (argc == 0) {
|
||||
BIO_set_fp(in, stdin, BIO_NOCLOSE);
|
||||
err = do_fp(out, buf, inp, separator, out_bin, sigkey, sigbuf,
|
||||
siglen, NULL, NULL, "stdin", bmd);
|
||||
ret = do_fp(out, buf, inp, separator, out_bin, sigkey, sigbuf,
|
||||
siglen, NULL, NULL, "stdin");
|
||||
} else {
|
||||
const char *md_name = NULL, *sig_name = NULL;
|
||||
if (!out_bin) {
|
||||
if (sigkey) {
|
||||
if (sigkey != NULL) {
|
||||
const EVP_PKEY_ASN1_METHOD *ameth;
|
||||
ameth = EVP_PKEY_get0_asn1(sigkey);
|
||||
if (ameth)
|
||||
EVP_PKEY_asn1_get0_info(NULL, NULL,
|
||||
NULL, NULL, &sig_name, ameth);
|
||||
}
|
||||
if (md)
|
||||
if (md != NULL)
|
||||
md_name = EVP_MD_name(md);
|
||||
}
|
||||
err = 0;
|
||||
ret = 0;
|
||||
for (i = 0; i < argc; i++) {
|
||||
int r;
|
||||
if (BIO_read_filename(in, argv[i]) <= 0) {
|
||||
perror(argv[i]);
|
||||
err++;
|
||||
ret++;
|
||||
continue;
|
||||
} else
|
||||
} else {
|
||||
r = do_fp(out, buf, inp, separator, out_bin, sigkey, sigbuf,
|
||||
siglen, sig_name, md_name, argv[i], bmd);
|
||||
siglen, sig_name, md_name, argv[i]);
|
||||
}
|
||||
if (r)
|
||||
err = r;
|
||||
ret = r;
|
||||
(void)BIO_reset(bmd);
|
||||
}
|
||||
}
|
||||
end:
|
||||
if (buf != NULL) {
|
||||
OPENSSL_cleanse(buf, BUFSIZE);
|
||||
OPENSSL_free(buf);
|
||||
}
|
||||
if (in != NULL)
|
||||
BIO_free(in);
|
||||
if (passin)
|
||||
OPENSSL_free(passin);
|
||||
OPENSSL_clear_free(buf, BUFSIZE);
|
||||
BIO_free(in);
|
||||
OPENSSL_free(passin);
|
||||
BIO_free_all(out);
|
||||
EVP_PKEY_free(sigkey);
|
||||
if (sigopts)
|
||||
sk_OPENSSL_STRING_free(sigopts);
|
||||
if (macopts)
|
||||
sk_OPENSSL_STRING_free(macopts);
|
||||
if (sigbuf)
|
||||
OPENSSL_free(sigbuf);
|
||||
if (bmd != NULL)
|
||||
BIO_free(bmd);
|
||||
sk_OPENSSL_STRING_free(sigopts);
|
||||
sk_OPENSSL_STRING_free(macopts);
|
||||
OPENSSL_free(sigbuf);
|
||||
BIO_free(bmd);
|
||||
release_engine(e);
|
||||
apps_shutdown();
|
||||
OPENSSL_EXIT(err);
|
||||
return ret;
|
||||
}
|
||||
|
||||
int do_fp(BIO *out, unsigned char *buf, BIO *bp, int sep, int binout,
|
||||
EVP_PKEY *key, unsigned char *sigin, int siglen,
|
||||
const char *sig_name, const char *md_name,
|
||||
const char *file, BIO *bmd)
|
||||
const char *file)
|
||||
{
|
||||
size_t len;
|
||||
int i;
|
||||
@ -560,13 +431,13 @@ int do_fp(BIO *out, unsigned char *buf, BIO *bp, int sep, int binout,
|
||||
if (i == 0)
|
||||
break;
|
||||
}
|
||||
if (sigin) {
|
||||
if (sigin != NULL) {
|
||||
EVP_MD_CTX *ctx;
|
||||
BIO_get_md_ctx(bp, &ctx);
|
||||
i = EVP_DigestVerifyFinal(ctx, sigin, (unsigned int)siglen);
|
||||
if (i > 0)
|
||||
if (i > 0) {
|
||||
BIO_printf(out, "Verified OK\n");
|
||||
else if (i == 0) {
|
||||
} else if (i == 0) {
|
||||
BIO_printf(out, "Verification Failure\n");
|
||||
return 1;
|
||||
} else {
|
||||
@ -576,7 +447,7 @@ int do_fp(BIO *out, unsigned char *buf, BIO *bp, int sep, int binout,
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
if (key) {
|
||||
if (key != NULL) {
|
||||
EVP_MD_CTX *ctx;
|
||||
BIO_get_md_ctx(bp, &ctx);
|
||||
len = BUFSIZE;
|
||||
@ -593,22 +464,23 @@ int do_fp(BIO *out, unsigned char *buf, BIO *bp, int sep, int binout,
|
||||
}
|
||||
}
|
||||
|
||||
if (binout)
|
||||
if (binout) {
|
||||
BIO_write(out, buf, len);
|
||||
else if (sep == 2) {
|
||||
} else if (sep == 2) {
|
||||
for (i = 0; i < (int)len; i++)
|
||||
BIO_printf(out, "%02x", buf[i]);
|
||||
BIO_printf(out, " *%s\n", file);
|
||||
} else {
|
||||
if (sig_name) {
|
||||
if (sig_name != NULL) {
|
||||
BIO_puts(out, sig_name);
|
||||
if (md_name)
|
||||
if (md_name != NULL)
|
||||
BIO_printf(out, "-%s", md_name);
|
||||
BIO_printf(out, "(%s)= ", file);
|
||||
} else if (md_name)
|
||||
} else if (md_name != NULL) {
|
||||
BIO_printf(out, "%s(%s)= ", md_name, file);
|
||||
else
|
||||
} else {
|
||||
BIO_printf(out, "(%s)= ", file);
|
||||
}
|
||||
for (i = 0; i < (int)len; i++) {
|
||||
if (sep && (i != 0))
|
||||
BIO_printf(out, ":");
|
||||
|
@ -1,331 +0,0 @@
|
||||
/* apps/dh.c */
|
||||
/* obsoleted by dhparam.c */
|
||||
/* Copyright (C) 1995-1998 Eric Young (eay@cryptsoft.com)
|
||||
* All rights reserved.
|
||||
*
|
||||
* This package is an SSL implementation written
|
||||
* by Eric Young (eay@cryptsoft.com).
|
||||
* The implementation was written so as to conform with Netscapes SSL.
|
||||
*
|
||||
* This library is free for commercial and non-commercial use as long as
|
||||
* the following conditions are aheared to. The following conditions
|
||||
* apply to all code found in this distribution, be it the RC4, RSA,
|
||||
* lhash, DES, etc., code; not just the SSL code. The SSL documentation
|
||||
* included with this distribution is covered by the same copyright terms
|
||||
* except that the holder is Tim Hudson (tjh@cryptsoft.com).
|
||||
*
|
||||
* Copyright remains Eric Young's, and as such any Copyright notices in
|
||||
* the code are not to be removed.
|
||||
* If this package is used in a product, Eric Young should be given attribution
|
||||
* as the author of the parts of the library used.
|
||||
* This can be in the form of a textual message at program startup or
|
||||
* in documentation (online or textual) provided with the package.
|
||||
*
|
||||
* Redistribution and use in source and binary forms, with or without
|
||||
* modification, are permitted provided that the following conditions
|
||||
* are met:
|
||||
* 1. Redistributions of source code must retain the copyright
|
||||
* notice, this list of conditions and the following disclaimer.
|
||||
* 2. Redistributions in binary form must reproduce the above copyright
|
||||
* notice, this list of conditions and the following disclaimer in the
|
||||
* documentation and/or other materials provided with the distribution.
|
||||
* 3. All advertising materials mentioning features or use of this software
|
||||
* must display the following acknowledgement:
|
||||
* "This product includes cryptographic software written by
|
||||
* Eric Young (eay@cryptsoft.com)"
|
||||
* The word 'cryptographic' can be left out if the rouines from the library
|
||||
* being used are not cryptographic related :-).
|
||||
* 4. If you include any Windows specific code (or a derivative thereof) from
|
||||
* the apps directory (application code) you must include an acknowledgement:
|
||||
* "This product includes software written by Tim Hudson (tjh@cryptsoft.com)"
|
||||
*
|
||||
* THIS SOFTWARE IS PROVIDED BY ERIC YOUNG ``AS IS'' AND
|
||||
* ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
|
||||
* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
|
||||
* ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE
|
||||
* FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
|
||||
* DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
|
||||
* OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
|
||||
* HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
|
||||
* LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
|
||||
* OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
|
||||
* SUCH DAMAGE.
|
||||
*
|
||||
* The licence and distribution terms for any publically available version or
|
||||
* derivative of this code cannot be changed. i.e. this code cannot simply be
|
||||
* copied and put under another distribution licence
|
||||
* [including the GNU Public Licence.]
|
||||
*/
|
||||
|
||||
#include <openssl/opensslconf.h> /* for OPENSSL_NO_DH */
|
||||
#ifndef OPENSSL_NO_DH
|
||||
# include <stdio.h>
|
||||
# include <stdlib.h>
|
||||
# include <time.h>
|
||||
# include <string.h>
|
||||
# include "apps.h"
|
||||
# include <openssl/bio.h>
|
||||
# include <openssl/err.h>
|
||||
# include <openssl/bn.h>
|
||||
# include <openssl/dh.h>
|
||||
# include <openssl/x509.h>
|
||||
# include <openssl/pem.h>
|
||||
|
||||
# undef PROG
|
||||
# define PROG dh_main
|
||||
|
||||
/*-
|
||||
* -inform arg - input format - default PEM (DER or PEM)
|
||||
* -outform arg - output format - default PEM
|
||||
* -in arg - input file - default stdin
|
||||
* -out arg - output file - default stdout
|
||||
* -check - check the parameters are ok
|
||||
* -noout
|
||||
* -text
|
||||
* -C
|
||||
*/
|
||||
|
||||
int MAIN(int, char **);
|
||||
|
||||
int MAIN(int argc, char **argv)
|
||||
{
|
||||
DH *dh = NULL;
|
||||
int i, badops = 0, text = 0;
|
||||
BIO *in = NULL, *out = NULL;
|
||||
int informat, outformat, check = 0, noout = 0, C = 0, ret = 1;
|
||||
char *infile, *outfile, *prog;
|
||||
char *engine;
|
||||
|
||||
apps_startup();
|
||||
|
||||
if (bio_err == NULL)
|
||||
if ((bio_err = BIO_new(BIO_s_file())) != NULL)
|
||||
BIO_set_fp(bio_err, stderr, BIO_NOCLOSE | BIO_FP_TEXT);
|
||||
|
||||
if (!load_config(bio_err, NULL))
|
||||
goto end;
|
||||
|
||||
engine = NULL;
|
||||
infile = NULL;
|
||||
outfile = NULL;
|
||||
informat = FORMAT_PEM;
|
||||
outformat = FORMAT_PEM;
|
||||
|
||||
prog = argv[0];
|
||||
argc--;
|
||||
argv++;
|
||||
while (argc >= 1) {
|
||||
if (strcmp(*argv, "-inform") == 0) {
|
||||
if (--argc < 1)
|
||||
goto bad;
|
||||
informat = str2fmt(*(++argv));
|
||||
} else if (strcmp(*argv, "-outform") == 0) {
|
||||
if (--argc < 1)
|
||||
goto bad;
|
||||
outformat = str2fmt(*(++argv));
|
||||
} else if (strcmp(*argv, "-in") == 0) {
|
||||
if (--argc < 1)
|
||||
goto bad;
|
||||
infile = *(++argv);
|
||||
} else if (strcmp(*argv, "-out") == 0) {
|
||||
if (--argc < 1)
|
||||
goto bad;
|
||||
outfile = *(++argv);
|
||||
}
|
||||
# ifndef OPENSSL_NO_ENGINE
|
||||
else if (strcmp(*argv, "-engine") == 0) {
|
||||
if (--argc < 1)
|
||||
goto bad;
|
||||
engine = *(++argv);
|
||||
}
|
||||
# endif
|
||||
else if (strcmp(*argv, "-check") == 0)
|
||||
check = 1;
|
||||
else if (strcmp(*argv, "-text") == 0)
|
||||
text = 1;
|
||||
else if (strcmp(*argv, "-C") == 0)
|
||||
C = 1;
|
||||
else if (strcmp(*argv, "-noout") == 0)
|
||||
noout = 1;
|
||||
else {
|
||||
BIO_printf(bio_err, "unknown option %s\n", *argv);
|
||||
badops = 1;
|
||||
break;
|
||||
}
|
||||
argc--;
|
||||
argv++;
|
||||
}
|
||||
|
||||
if (badops) {
|
||||
bad:
|
||||
BIO_printf(bio_err, "%s [options] <infile >outfile\n", prog);
|
||||
BIO_printf(bio_err, "where options are\n");
|
||||
BIO_printf(bio_err, " -inform arg input format - one of DER PEM\n");
|
||||
BIO_printf(bio_err,
|
||||
" -outform arg output format - one of DER PEM\n");
|
||||
BIO_printf(bio_err, " -in arg input file\n");
|
||||
BIO_printf(bio_err, " -out arg output file\n");
|
||||
BIO_printf(bio_err, " -check check the DH parameters\n");
|
||||
BIO_printf(bio_err,
|
||||
" -text print a text form of the DH parameters\n");
|
||||
BIO_printf(bio_err, " -C Output C code\n");
|
||||
BIO_printf(bio_err, " -noout no output\n");
|
||||
# ifndef OPENSSL_NO_ENGINE
|
||||
BIO_printf(bio_err,
|
||||
" -engine e use engine e, possibly a hardware device.\n");
|
||||
# endif
|
||||
goto end;
|
||||
}
|
||||
|
||||
ERR_load_crypto_strings();
|
||||
|
||||
setup_engine(bio_err, engine, 0);
|
||||
|
||||
in = BIO_new(BIO_s_file());
|
||||
out = BIO_new(BIO_s_file());
|
||||
if ((in == NULL) || (out == NULL)) {
|
||||
ERR_print_errors(bio_err);
|
||||
goto end;
|
||||
}
|
||||
|
||||
if (infile == NULL)
|
||||
BIO_set_fp(in, stdin, BIO_NOCLOSE);
|
||||
else {
|
||||
if (BIO_read_filename(in, infile) <= 0) {
|
||||
perror(infile);
|
||||
goto end;
|
||||
}
|
||||
}
|
||||
if (outfile == NULL) {
|
||||
BIO_set_fp(out, stdout, BIO_NOCLOSE);
|
||||
# ifdef OPENSSL_SYS_VMS
|
||||
{
|
||||
BIO *tmpbio = BIO_new(BIO_f_linebuffer());
|
||||
out = BIO_push(tmpbio, out);
|
||||
}
|
||||
# endif
|
||||
} else {
|
||||
if (BIO_write_filename(out, outfile) <= 0) {
|
||||
perror(outfile);
|
||||
goto end;
|
||||
}
|
||||
}
|
||||
|
||||
if (informat == FORMAT_ASN1)
|
||||
dh = d2i_DHparams_bio(in, NULL);
|
||||
else if (informat == FORMAT_PEM)
|
||||
dh = PEM_read_bio_DHparams(in, NULL, NULL, NULL);
|
||||
else {
|
||||
BIO_printf(bio_err, "bad input format specified\n");
|
||||
goto end;
|
||||
}
|
||||
if (dh == NULL) {
|
||||
BIO_printf(bio_err, "unable to load DH parameters\n");
|
||||
ERR_print_errors(bio_err);
|
||||
goto end;
|
||||
}
|
||||
|
||||
if (text) {
|
||||
DHparams_print(out, dh);
|
||||
# ifdef undef
|
||||
printf("p=");
|
||||
BN_print(stdout, dh->p);
|
||||
printf("\ng=");
|
||||
BN_print(stdout, dh->g);
|
||||
printf("\n");
|
||||
if (dh->length != 0)
|
||||
printf("recommended private length=%ld\n", dh->length);
|
||||
# endif
|
||||
}
|
||||
|
||||
if (check) {
|
||||
if (!DH_check(dh, &i)) {
|
||||
ERR_print_errors(bio_err);
|
||||
goto end;
|
||||
}
|
||||
if (i & DH_CHECK_P_NOT_PRIME)
|
||||
printf("p value is not prime\n");
|
||||
if (i & DH_CHECK_P_NOT_SAFE_PRIME)
|
||||
printf("p value is not a safe prime\n");
|
||||
if (i & DH_UNABLE_TO_CHECK_GENERATOR)
|
||||
printf("unable to check the generator value\n");
|
||||
if (i & DH_NOT_SUITABLE_GENERATOR)
|
||||
printf("the g value is not a generator\n");
|
||||
if (i == 0)
|
||||
printf("DH parameters appear to be ok.\n");
|
||||
}
|
||||
if (C) {
|
||||
unsigned char *data;
|
||||
int len, l, bits;
|
||||
|
||||
len = BN_num_bytes(dh->p);
|
||||
bits = BN_num_bits(dh->p);
|
||||
data = (unsigned char *)OPENSSL_malloc(len);
|
||||
if (data == NULL) {
|
||||
perror("OPENSSL_malloc");
|
||||
goto end;
|
||||
}
|
||||
l = BN_bn2bin(dh->p, data);
|
||||
printf("static unsigned char dh%d_p[]={", bits);
|
||||
for (i = 0; i < l; i++) {
|
||||
if ((i % 12) == 0)
|
||||
printf("\n\t");
|
||||
printf("0x%02X,", data[i]);
|
||||
}
|
||||
printf("\n\t};\n");
|
||||
|
||||
l = BN_bn2bin(dh->g, data);
|
||||
printf("static unsigned char dh%d_g[]={", bits);
|
||||
for (i = 0; i < l; i++) {
|
||||
if ((i % 12) == 0)
|
||||
printf("\n\t");
|
||||
printf("0x%02X,", data[i]);
|
||||
}
|
||||
printf("\n\t};\n\n");
|
||||
|
||||
printf("DH *get_dh%d()\n\t{\n", bits);
|
||||
printf("\tDH *dh;\n\n");
|
||||
printf("\tif ((dh=DH_new()) == NULL) return(NULL);\n");
|
||||
printf("\tdh->p=BN_bin2bn(dh%d_p,sizeof(dh%d_p),NULL);\n",
|
||||
bits, bits);
|
||||
printf("\tdh->g=BN_bin2bn(dh%d_g,sizeof(dh%d_g),NULL);\n",
|
||||
bits, bits);
|
||||
printf("\tif ((dh->p == NULL) || (dh->g == NULL))\n");
|
||||
printf("\t\treturn(NULL);\n");
|
||||
printf("\treturn(dh);\n\t}\n");
|
||||
OPENSSL_free(data);
|
||||
}
|
||||
|
||||
if (!noout) {
|
||||
if (outformat == FORMAT_ASN1)
|
||||
i = i2d_DHparams_bio(out, dh);
|
||||
else if (outformat == FORMAT_PEM)
|
||||
i = PEM_write_bio_DHparams(out, dh);
|
||||
else {
|
||||
BIO_printf(bio_err, "bad output format specified for outfile\n");
|
||||
goto end;
|
||||
}
|
||||
if (!i) {
|
||||
BIO_printf(bio_err, "unable to write DH parameters\n");
|
||||
ERR_print_errors(bio_err);
|
||||
goto end;
|
||||
}
|
||||
}
|
||||
ret = 0;
|
||||
end:
|
||||
if (in != NULL)
|
||||
BIO_free(in);
|
||||
if (out != NULL)
|
||||
BIO_free_all(out);
|
||||
if (dh != NULL)
|
||||
DH_free(dh);
|
||||
apps_shutdown();
|
||||
OPENSSL_EXIT(ret);
|
||||
}
|
||||
#else /* !OPENSSL_NO_DH */
|
||||
|
||||
# if PEDANTIC
|
||||
static void *dummy = &dummy;
|
||||
# endif
|
||||
|
||||
#endif
|
@ -1,10 +1,10 @@
|
||||
-----BEGIN DH PARAMETERS-----
|
||||
MIGHAoGBAPSI/VhOSdvNILSd5JEHNmszbDgNRR0PfIizHHxbLY7288kjwEPwpVsY
|
||||
jY67VYy4XTjTNP18F1dDox0YbN4zISy1Kv884bEpQBgRjXyEpwpy1obEAxnIByl6
|
||||
ypUM2Zafq9AKUJsCRtMIPWakXUGfnHy9iUsiGSa6q6Jew1XpL3jHAgEC
|
||||
MIGHAoGBAP//////////yQ/aoiFowjTExmKLgNwc0SkCTgiKZ8x0Agu+pjsTmyJR
|
||||
Sgh5jjQE3e+VGbPNOkMbMCsKbfJfFDdP4TVtbVHCReSFtXZiXn7G9ExC6aY37WsL
|
||||
/1y29Aa37e44a/taiZ+lrp8kEXxLH+ZJKGZR7OZTgf//////////AgEC
|
||||
-----END DH PARAMETERS-----
|
||||
|
||||
These are the 1024 bit DH parameters from "Assigned Number for SKIP Protocols"
|
||||
(http://www.skip-vpn.org/spec/numbers.html).
|
||||
See there for how they were generated.
|
||||
Note that g is not a generator, but this is not a problem since p is a safe prime.
|
||||
These are the 1024-bit DH parameters from "Internet Key Exchange
|
||||
Protocol Version 2 (IKEv2)": https://tools.ietf.org/html/rfc5996
|
||||
|
||||
See https://tools.ietf.org/html/rfc2412 for how they were generated.
|
||||
|
@ -1,12 +1,14 @@
|
||||
-----BEGIN DH PARAMETERS-----
|
||||
MIIBCAKCAQEA9kJXtwh/CBdyorrWqULzBej5UxE5T7bxbrlLOCDaAadWoxTpj0BV
|
||||
89AHxstDqZSt90xkhkn4DIO9ZekX1KHTUPj1WV/cdlJPPT2N286Z4VeSWc39uK50
|
||||
T8X8dryDxUcwYc58yWb/Ffm7/ZFexwGq01uejaClcjrUGvC/RgBYK+X0iP1YTknb
|
||||
zSC0neSRBzZrM2w4DUUdD3yIsxx8Wy2O9vPJI8BD8KVbGI2Ou1WMuF040zT9fBdX
|
||||
Q6MdGGzeMyEstSr/POGxKUAYEY18hKcKctaGxAMZyAcpesqVDNmWn6vQClCbAkbT
|
||||
CD1mpF1Bn5x8vYlLIhkmuquiXsNV6TILOwIBAg==
|
||||
MIIBCAKCAQEA///////////JD9qiIWjCNMTGYouA3BzRKQJOCIpnzHQCC76mOxOb
|
||||
IlFKCHmONATd75UZs806QxswKwpt8l8UN0/hNW1tUcJF5IW1dmJefsb0TELppjft
|
||||
awv/XLb0Brft7jhr+1qJn6WunyQRfEsf5kkoZlHs5Fs9wgB8uKFjvwWY2kg2HFXT
|
||||
mmkWP6j9JM9fg2VdI9yjrZYcYvNWIIVSu57VKQdwlpZtZww1Tkq8mATxdGwIyhgh
|
||||
fDKQXkYuNs474553LBgOhgObJ4Oi7Aeij7XFXfBvTFLJ3ivL9pVYFxg5lUl86pVq
|
||||
5RXSJhiY+gUQFXKOWoqsqmj//////////wIBAg==
|
||||
-----END DH PARAMETERS-----
|
||||
|
||||
These are the 2048 bit DH parameters from "Assigned Number for SKIP Protocols"
|
||||
(http://www.skip-vpn.org/spec/numbers.html).
|
||||
See there for how they were generated.
|
||||
These are the 2048-bit DH parameters from "More Modular Exponential
|
||||
(MODP) Diffie-Hellman groups for Internet Key Exchange (IKE)":
|
||||
https://tools.ietf.org/html/rfc3526
|
||||
|
||||
See https://tools.ietf.org/html/rfc2412 for how they were generated.
|
||||
|
@ -1,18 +1,19 @@
|
||||
-----BEGIN DH PARAMETERS-----
|
||||
MIICCAKCAgEA+hRyUsFN4VpJ1O8JLcCo/VWr19k3BCgJ4uk+d+KhehjdRqNDNyOQ
|
||||
l/MOyQNQfWXPeGKmOmIig6Ev/nm6Nf9Z2B1h3R4hExf+zTiHnvVPeRBhjdQi81rt
|
||||
Xeoh6TNrSBIKIHfUJWBh3va0TxxjQIs6IZOLeVNRLMqzeylWqMf49HsIXqbcokUS
|
||||
Vt1BkvLdW48j8PPv5DsKRN3tloTxqDJGo9tKvj1Fuk74A+Xda1kNhB7KFlqMyN98
|
||||
VETEJ6c7KpfOo30mnK30wqw3S8OtaIR/maYX72tGOno2ehFDkq3pnPtEbD2CScxc
|
||||
alJC+EL7RPk5c/tgeTvCngvc1KZn92Y//EI7G9tPZtylj2b56sHtMftIoYJ9+ODM
|
||||
sccD5Piz/rejE3Ome8EOOceUSCYAhXn8b3qvxVI1ddd1pED6FHRhFvLrZxFvBEM9
|
||||
ERRMp5QqOaHJkM+Dxv8Cj6MqrCbfC4u+ZErxodzuusgDgvZiLF22uxMZbobFWyte
|
||||
OvOzKGtwcTqO/1wV5gKkzu1ZVswVUQd5Gg8lJicwqRWyyNRczDDoG9jVDxmogKTH
|
||||
AaqLulO7R8Ifa1SwF2DteSGVtgWEN8gDpN3RBmmPTDngyF2DHb5qmpnznwtFKdTL
|
||||
KWbuHn491xNO25CQWMtem80uKw+pTnisBRF/454n1Jnhub144YRBoN8CAQI=
|
||||
MIICCAKCAgEA///////////JD9qiIWjCNMTGYouA3BzRKQJOCIpnzHQCC76mOxOb
|
||||
IlFKCHmONATd75UZs806QxswKwpt8l8UN0/hNW1tUcJF5IW1dmJefsb0TELppjft
|
||||
awv/XLb0Brft7jhr+1qJn6WunyQRfEsf5kkoZlHs5Fs9wgB8uKFjvwWY2kg2HFXT
|
||||
mmkWP6j9JM9fg2VdI9yjrZYcYvNWIIVSu57VKQdwlpZtZww1Tkq8mATxdGwIyhgh
|
||||
fDKQXkYuNs474553LBgOhgObJ4Oi7Aeij7XFXfBvTFLJ3ivL9pVYFxg5lUl86pVq
|
||||
5RXSJhiY+gUQFXKOWoqqxC2tMxcNBFB6M6hVIavfHLpk7PuFBFjb7wqK6nFXXQYM
|
||||
fbOXD4Wm4eTHq/WujNsJM9cejJTgSiVhnc7j0iYa0u5r8S/6BtmKCGTYdgJzPshq
|
||||
ZFIfKxgXeyAMu+EXV3phXWx3CYjAutlG4gjiT6B05asxQ9tb/OD9EI5LgtEgqSEI
|
||||
ARpyPBKnh+bXiHGaEL26WyaZwycYavTiPBqUaDS2FQvaJYPpyirUTOjbu8LbBN6O
|
||||
+S6O/BQfvsqmKHxZR05rwF2ZspZPoJDDoiM7oYZRW+ftH2EpcM7i16+4G912IXBI
|
||||
HNAGkSfVsFqpk7TqmI2P3cGG/7fckKbAj030Nck0BjGZ//////////8CAQI=
|
||||
-----END DH PARAMETERS-----
|
||||
|
||||
These are the 4096 bit DH parameters from "Assigned Number for SKIP Protocols"
|
||||
(http://www.skip-vpn.org/spec/numbers.html).
|
||||
See there for how they were generated.
|
||||
Note that g is not a generator, but this is not a problem since p is a safe prime.
|
||||
These are the 4096-bit DH parameters from "More Modular Exponential
|
||||
(MODP) Diffie-Hellman groups for Internet Key Exchange (IKE)":
|
||||
https://tools.ietf.org/html/rfc3526
|
||||
|
||||
See https://tools.ietf.org/html/rfc2412 for how they were generated.
|
||||
|
@ -1,9 +0,0 @@
|
||||
-----BEGIN DH PARAMETERS-----
|
||||
MEYCQQD1Kv884bEpQBgRjXyEpwpy1obEAxnIByl6ypUM2Zafq9AKUJsCRtMIPWak
|
||||
XUGfnHy9iUsiGSa6q6Jew1XpKgVfAgEC
|
||||
-----END DH PARAMETERS-----
|
||||
|
||||
These are the 512 bit DH parameters from "Assigned Number for SKIP Protocols"
|
||||
(http://www.skip-vpn.org/spec/numbers.html).
|
||||
See there for how they were generated.
|
||||
Note that g is not a generator, but this is not a problem since p is a safe prime.
|
@ -1,121 +1,23 @@
|
||||
/* apps/dhparam.c */
|
||||
/* Copyright (C) 1995-1998 Eric Young (eay@cryptsoft.com)
|
||||
* All rights reserved.
|
||||
*
|
||||
* This package is an SSL implementation written
|
||||
* by Eric Young (eay@cryptsoft.com).
|
||||
* The implementation was written so as to conform with Netscapes SSL.
|
||||
*
|
||||
* This library is free for commercial and non-commercial use as long as
|
||||
* the following conditions are aheared to. The following conditions
|
||||
* apply to all code found in this distribution, be it the RC4, RSA,
|
||||
* lhash, DES, etc., code; not just the SSL code. The SSL documentation
|
||||
* included with this distribution is covered by the same copyright terms
|
||||
* except that the holder is Tim Hudson (tjh@cryptsoft.com).
|
||||
*
|
||||
* Copyright remains Eric Young's, and as such any Copyright notices in
|
||||
* the code are not to be removed.
|
||||
* If this package is used in a product, Eric Young should be given attribution
|
||||
* as the author of the parts of the library used.
|
||||
* This can be in the form of a textual message at program startup or
|
||||
* in documentation (online or textual) provided with the package.
|
||||
*
|
||||
* Redistribution and use in source and binary forms, with or without
|
||||
* modification, are permitted provided that the following conditions
|
||||
* are met:
|
||||
* 1. Redistributions of source code must retain the copyright
|
||||
* notice, this list of conditions and the following disclaimer.
|
||||
* 2. Redistributions in binary form must reproduce the above copyright
|
||||
* notice, this list of conditions and the following disclaimer in the
|
||||
* documentation and/or other materials provided with the distribution.
|
||||
* 3. All advertising materials mentioning features or use of this software
|
||||
* must display the following acknowledgement:
|
||||
* "This product includes cryptographic software written by
|
||||
* Eric Young (eay@cryptsoft.com)"
|
||||
* The word 'cryptographic' can be left out if the rouines from the library
|
||||
* being used are not cryptographic related :-).
|
||||
* 4. If you include any Windows specific code (or a derivative thereof) from
|
||||
* the apps directory (application code) you must include an acknowledgement:
|
||||
* "This product includes software written by Tim Hudson (tjh@cryptsoft.com)"
|
||||
*
|
||||
* THIS SOFTWARE IS PROVIDED BY ERIC YOUNG ``AS IS'' AND
|
||||
* ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
|
||||
* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
|
||||
* ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE
|
||||
* FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
|
||||
* DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
|
||||
* OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
|
||||
* HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
|
||||
* LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
|
||||
* OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
|
||||
* SUCH DAMAGE.
|
||||
*
|
||||
* The licence and distribution terms for any publically available version or
|
||||
* derivative of this code cannot be changed. i.e. this code cannot simply be
|
||||
* copied and put under another distribution licence
|
||||
* [including the GNU Public Licence.]
|
||||
*/
|
||||
/* ====================================================================
|
||||
* Copyright (c) 1998-2000 The OpenSSL Project. All rights reserved.
|
||||
*
|
||||
* Redistribution and use in source and binary forms, with or without
|
||||
* modification, are permitted provided that the following conditions
|
||||
* are met:
|
||||
*
|
||||
* 1. Redistributions of source code must retain the above copyright
|
||||
* notice, this list of conditions and the following disclaimer.
|
||||
*
|
||||
* 2. Redistributions in binary form must reproduce the above copyright
|
||||
* notice, this list of conditions and the following disclaimer in
|
||||
* the documentation and/or other materials provided with the
|
||||
* distribution.
|
||||
*
|
||||
* 3. All advertising materials mentioning features or use of this
|
||||
* software must display the following acknowledgment:
|
||||
* "This product includes software developed by the OpenSSL Project
|
||||
* for use in the OpenSSL Toolkit. (http://www.openssl.org/)"
|
||||
*
|
||||
* 4. The names "OpenSSL Toolkit" and "OpenSSL Project" must not be used to
|
||||
* endorse or promote products derived from this software without
|
||||
* prior written permission. For written permission, please contact
|
||||
* openssl-core@openssl.org.
|
||||
*
|
||||
* 5. Products derived from this software may not be called "OpenSSL"
|
||||
* nor may "OpenSSL" appear in their names without prior written
|
||||
* permission of the OpenSSL Project.
|
||||
*
|
||||
* 6. Redistributions of any form whatsoever must retain the following
|
||||
* acknowledgment:
|
||||
* "This product includes software developed by the OpenSSL Project
|
||||
* for use in the OpenSSL Toolkit (http://www.openssl.org/)"
|
||||
*
|
||||
* THIS SOFTWARE IS PROVIDED BY THE OpenSSL PROJECT ``AS IS'' AND ANY
|
||||
* EXPRESSED OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
|
||||
* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
|
||||
* PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE OpenSSL PROJECT OR
|
||||
* ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
|
||||
* SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
|
||||
* NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
|
||||
* LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
|
||||
* HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT,
|
||||
* STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
|
||||
* ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED
|
||||
* OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
* ====================================================================
|
||||
*
|
||||
* This product includes cryptographic software written by Eric Young
|
||||
* (eay@cryptsoft.com). This product includes software written by Tim
|
||||
* Hudson (tjh@cryptsoft.com).
|
||||
/*
|
||||
* Copyright 1995-2018 The OpenSSL Project Authors. All Rights Reserved.
|
||||
*
|
||||
* Licensed under the OpenSSL license (the "License"). You may not use
|
||||
* this file except in compliance with the License. You can obtain a copy
|
||||
* in the file LICENSE in the source distribution or at
|
||||
* https://www.openssl.org/source/license.html
|
||||
*/
|
||||
|
||||
#include <openssl/opensslconf.h> /* for OPENSSL_NO_DH */
|
||||
#ifndef OPENSSL_NO_DH
|
||||
#include <openssl/opensslconf.h>
|
||||
#ifdef OPENSSL_NO_DH
|
||||
NON_EMPTY_TRANSLATION_UNIT
|
||||
#else
|
||||
|
||||
# include <stdio.h>
|
||||
# include <stdlib.h>
|
||||
# include <time.h>
|
||||
# include <string.h>
|
||||
# include "apps.h"
|
||||
# include "progs.h"
|
||||
# include <openssl/bio.h>
|
||||
# include <openssl/err.h>
|
||||
# include <openssl/bn.h>
|
||||
@ -127,179 +29,149 @@
|
||||
# include <openssl/dsa.h>
|
||||
# endif
|
||||
|
||||
# undef PROG
|
||||
# define PROG dhparam_main
|
||||
|
||||
# define DEFBITS 2048
|
||||
|
||||
/*-
|
||||
* -inform arg - input format - default PEM (DER or PEM)
|
||||
* -outform arg - output format - default PEM
|
||||
* -in arg - input file - default stdin
|
||||
* -out arg - output file - default stdout
|
||||
* -dsaparam - read or generate DSA parameters, convert to DH
|
||||
* -check - check the parameters are ok
|
||||
* -noout
|
||||
* -text
|
||||
* -C
|
||||
*/
|
||||
static int dh_cb(int p, int n, BN_GENCB *cb);
|
||||
|
||||
static int MS_CALLBACK dh_cb(int p, int n, BN_GENCB *cb);
|
||||
typedef enum OPTION_choice {
|
||||
OPT_ERR = -1, OPT_EOF = 0, OPT_HELP,
|
||||
OPT_INFORM, OPT_OUTFORM, OPT_IN, OPT_OUT,
|
||||
OPT_ENGINE, OPT_CHECK, OPT_TEXT, OPT_NOOUT,
|
||||
OPT_DSAPARAM, OPT_C, OPT_2, OPT_5,
|
||||
OPT_R_ENUM
|
||||
} OPTION_CHOICE;
|
||||
|
||||
int MAIN(int, char **);
|
||||
const OPTIONS dhparam_options[] = {
|
||||
{OPT_HELP_STR, 1, '-', "Usage: %s [flags] [numbits]\n"},
|
||||
{OPT_HELP_STR, 1, '-', "Valid options are:\n"},
|
||||
{"help", OPT_HELP, '-', "Display this summary"},
|
||||
{"in", OPT_IN, '<', "Input file"},
|
||||
{"inform", OPT_INFORM, 'F', "Input format, DER or PEM"},
|
||||
{"outform", OPT_OUTFORM, 'F', "Output format, DER or PEM"},
|
||||
{"out", OPT_OUT, '>', "Output file"},
|
||||
{"check", OPT_CHECK, '-', "Check the DH parameters"},
|
||||
{"text", OPT_TEXT, '-', "Print a text form of the DH parameters"},
|
||||
{"noout", OPT_NOOUT, '-', "Don't output any DH parameters"},
|
||||
OPT_R_OPTIONS,
|
||||
{"C", OPT_C, '-', "Print C code"},
|
||||
{"2", OPT_2, '-', "Generate parameters using 2 as the generator value"},
|
||||
{"5", OPT_5, '-', "Generate parameters using 5 as the generator value"},
|
||||
# ifndef OPENSSL_NO_DSA
|
||||
{"dsaparam", OPT_DSAPARAM, '-',
|
||||
"Read or generate DSA parameters, convert to DH"},
|
||||
# endif
|
||||
# ifndef OPENSSL_NO_ENGINE
|
||||
{"engine", OPT_ENGINE, 's', "Use engine e, possibly a hardware device"},
|
||||
# endif
|
||||
{NULL}
|
||||
};
|
||||
|
||||
int MAIN(int argc, char **argv)
|
||||
int dhparam_main(int argc, char **argv)
|
||||
{
|
||||
DH *dh = NULL;
|
||||
int i, badops = 0, text = 0;
|
||||
# ifndef OPENSSL_NO_DSA
|
||||
int dsaparam = 0;
|
||||
# endif
|
||||
BIO *in = NULL, *out = NULL;
|
||||
int informat, outformat, check = 0, noout = 0, C = 0, ret = 1;
|
||||
char *infile, *outfile, *prog;
|
||||
char *inrand = NULL;
|
||||
char *engine = NULL;
|
||||
DH *dh = NULL;
|
||||
char *infile = NULL, *outfile = NULL, *prog;
|
||||
ENGINE *e = NULL;
|
||||
int num = 0, g = 0;
|
||||
#ifndef OPENSSL_NO_DSA
|
||||
int dsaparam = 0;
|
||||
#endif
|
||||
int i, text = 0, C = 0, ret = 1, num = 0, g = 0;
|
||||
int informat = FORMAT_PEM, outformat = FORMAT_PEM, check = 0, noout = 0;
|
||||
OPTION_CHOICE o;
|
||||
|
||||
apps_startup();
|
||||
|
||||
if (bio_err == NULL)
|
||||
if ((bio_err = BIO_new(BIO_s_file())) != NULL)
|
||||
BIO_set_fp(bio_err, stderr, BIO_NOCLOSE | BIO_FP_TEXT);
|
||||
|
||||
if (!load_config(bio_err, NULL))
|
||||
goto end;
|
||||
|
||||
infile = NULL;
|
||||
outfile = NULL;
|
||||
informat = FORMAT_PEM;
|
||||
outformat = FORMAT_PEM;
|
||||
|
||||
prog = argv[0];
|
||||
argc--;
|
||||
argv++;
|
||||
while (argc >= 1) {
|
||||
if (strcmp(*argv, "-inform") == 0) {
|
||||
if (--argc < 1)
|
||||
goto bad;
|
||||
informat = str2fmt(*(++argv));
|
||||
} else if (strcmp(*argv, "-outform") == 0) {
|
||||
if (--argc < 1)
|
||||
goto bad;
|
||||
outformat = str2fmt(*(++argv));
|
||||
} else if (strcmp(*argv, "-in") == 0) {
|
||||
if (--argc < 1)
|
||||
goto bad;
|
||||
infile = *(++argv);
|
||||
} else if (strcmp(*argv, "-out") == 0) {
|
||||
if (--argc < 1)
|
||||
goto bad;
|
||||
outfile = *(++argv);
|
||||
}
|
||||
# ifndef OPENSSL_NO_ENGINE
|
||||
else if (strcmp(*argv, "-engine") == 0) {
|
||||
if (--argc < 1)
|
||||
goto bad;
|
||||
engine = *(++argv);
|
||||
}
|
||||
# endif
|
||||
else if (strcmp(*argv, "-check") == 0)
|
||||
prog = opt_init(argc, argv, dhparam_options);
|
||||
while ((o = opt_next()) != OPT_EOF) {
|
||||
switch (o) {
|
||||
case OPT_EOF:
|
||||
case OPT_ERR:
|
||||
opthelp:
|
||||
BIO_printf(bio_err, "%s: Use -help for summary.\n", prog);
|
||||
goto end;
|
||||
case OPT_HELP:
|
||||
opt_help(dhparam_options);
|
||||
ret = 0;
|
||||
goto end;
|
||||
case OPT_INFORM:
|
||||
if (!opt_format(opt_arg(), OPT_FMT_PEMDER, &informat))
|
||||
goto opthelp;
|
||||
break;
|
||||
case OPT_OUTFORM:
|
||||
if (!opt_format(opt_arg(), OPT_FMT_PEMDER, &outformat))
|
||||
goto opthelp;
|
||||
break;
|
||||
case OPT_IN:
|
||||
infile = opt_arg();
|
||||
break;
|
||||
case OPT_OUT:
|
||||
outfile = opt_arg();
|
||||
break;
|
||||
case OPT_ENGINE:
|
||||
e = setup_engine(opt_arg(), 0);
|
||||
break;
|
||||
case OPT_CHECK:
|
||||
check = 1;
|
||||
else if (strcmp(*argv, "-text") == 0)
|
||||
break;
|
||||
case OPT_TEXT:
|
||||
text = 1;
|
||||
# ifndef OPENSSL_NO_DSA
|
||||
else if (strcmp(*argv, "-dsaparam") == 0)
|
||||
break;
|
||||
case OPT_DSAPARAM:
|
||||
#ifndef OPENSSL_NO_DSA
|
||||
dsaparam = 1;
|
||||
# endif
|
||||
else if (strcmp(*argv, "-C") == 0)
|
||||
#endif
|
||||
break;
|
||||
case OPT_C:
|
||||
C = 1;
|
||||
else if (strcmp(*argv, "-noout") == 0)
|
||||
noout = 1;
|
||||
else if (strcmp(*argv, "-2") == 0)
|
||||
break;
|
||||
case OPT_2:
|
||||
g = 2;
|
||||
else if (strcmp(*argv, "-5") == 0)
|
||||
break;
|
||||
case OPT_5:
|
||||
g = 5;
|
||||
else if (strcmp(*argv, "-rand") == 0) {
|
||||
if (--argc < 1)
|
||||
goto bad;
|
||||
inrand = *(++argv);
|
||||
} else if (((sscanf(*argv, "%d", &num) == 0) || (num <= 0)))
|
||||
goto bad;
|
||||
argv++;
|
||||
argc--;
|
||||
break;
|
||||
case OPT_NOOUT:
|
||||
noout = 1;
|
||||
break;
|
||||
case OPT_R_CASES:
|
||||
if (!opt_rand(o))
|
||||
goto end;
|
||||
break;
|
||||
}
|
||||
}
|
||||
argc = opt_num_rest();
|
||||
argv = opt_rest();
|
||||
|
||||
if (badops) {
|
||||
bad:
|
||||
BIO_printf(bio_err, "%s [options] [numbits]\n", prog);
|
||||
BIO_printf(bio_err, "where options are\n");
|
||||
BIO_printf(bio_err, " -inform arg input format - one of DER PEM\n");
|
||||
BIO_printf(bio_err,
|
||||
" -outform arg output format - one of DER PEM\n");
|
||||
BIO_printf(bio_err, " -in arg input file\n");
|
||||
BIO_printf(bio_err, " -out arg output file\n");
|
||||
# ifndef OPENSSL_NO_DSA
|
||||
BIO_printf(bio_err,
|
||||
" -dsaparam read or generate DSA parameters, convert to DH\n");
|
||||
# endif
|
||||
BIO_printf(bio_err, " -check check the DH parameters\n");
|
||||
BIO_printf(bio_err,
|
||||
" -text print a text form of the DH parameters\n");
|
||||
BIO_printf(bio_err, " -C Output C code\n");
|
||||
BIO_printf(bio_err,
|
||||
" -2 generate parameters using 2 as the generator value\n");
|
||||
BIO_printf(bio_err,
|
||||
" -5 generate parameters using 5 as the generator value\n");
|
||||
BIO_printf(bio_err,
|
||||
" numbits number of bits in to generate (default 2048)\n");
|
||||
# ifndef OPENSSL_NO_ENGINE
|
||||
BIO_printf(bio_err,
|
||||
" -engine e use engine e, possibly a hardware device.\n");
|
||||
# endif
|
||||
BIO_printf(bio_err, " -rand file%cfile%c...\n", LIST_SEPARATOR_CHAR,
|
||||
LIST_SEPARATOR_CHAR);
|
||||
BIO_printf(bio_err,
|
||||
" - load the file (or the files in the directory) into\n");
|
||||
BIO_printf(bio_err, " the random number generator\n");
|
||||
BIO_printf(bio_err, " -noout no output\n");
|
||||
if (argv[0] != NULL && (!opt_int(argv[0], &num) || num <= 0))
|
||||
goto end;
|
||||
}
|
||||
|
||||
ERR_load_crypto_strings();
|
||||
|
||||
e = setup_engine(bio_err, engine, 0);
|
||||
|
||||
if (g && !num)
|
||||
num = DEFBITS;
|
||||
|
||||
# ifndef OPENSSL_NO_DSA
|
||||
if (dsaparam) {
|
||||
if (g) {
|
||||
BIO_printf(bio_err,
|
||||
"generator may not be chosen for DSA parameters\n");
|
||||
goto end;
|
||||
}
|
||||
} else
|
||||
# endif
|
||||
{
|
||||
/* DH parameters */
|
||||
if (num && !g)
|
||||
g = 2;
|
||||
if (dsaparam && g) {
|
||||
BIO_printf(bio_err,
|
||||
"generator may not be chosen for DSA parameters\n");
|
||||
goto end;
|
||||
}
|
||||
# endif
|
||||
|
||||
out = bio_open_default(outfile, 'w', outformat);
|
||||
if (out == NULL)
|
||||
goto end;
|
||||
|
||||
/* DH parameters */
|
||||
if (num && !g)
|
||||
g = 2;
|
||||
|
||||
if (num) {
|
||||
|
||||
BN_GENCB cb;
|
||||
BN_GENCB_set(&cb, dh_cb, bio_err);
|
||||
if (!app_RAND_load_file(NULL, bio_err, 1) && inrand == NULL) {
|
||||
BIO_printf(bio_err,
|
||||
"warning, not much extra random data, consider using the -rand option\n");
|
||||
BN_GENCB *cb;
|
||||
cb = BN_GENCB_new();
|
||||
if (cb == NULL) {
|
||||
ERR_print_errors(bio_err);
|
||||
goto end;
|
||||
}
|
||||
if (inrand != NULL)
|
||||
BIO_printf(bio_err, "%ld semi-random bytes loaded\n",
|
||||
app_RAND_load_files(inrand));
|
||||
|
||||
BN_GENCB_set(cb, dh_cb, bio_err);
|
||||
|
||||
# ifndef OPENSSL_NO_DSA
|
||||
if (dsaparam) {
|
||||
@ -307,11 +179,11 @@ int MAIN(int argc, char **argv)
|
||||
|
||||
BIO_printf(bio_err,
|
||||
"Generating DSA parameters, %d bit long prime\n", num);
|
||||
if (!dsa
|
||||
if (dsa == NULL
|
||||
|| !DSA_generate_parameters_ex(dsa, num, NULL, 0, NULL, NULL,
|
||||
&cb)) {
|
||||
if (dsa)
|
||||
DSA_free(dsa);
|
||||
cb)) {
|
||||
DSA_free(dsa);
|
||||
BN_GENCB_free(cb);
|
||||
ERR_print_errors(bio_err);
|
||||
goto end;
|
||||
}
|
||||
@ -319,6 +191,7 @@ int MAIN(int argc, char **argv)
|
||||
dh = DSA_dup_DH(dsa);
|
||||
DSA_free(dsa);
|
||||
if (dh == NULL) {
|
||||
BN_GENCB_free(cb);
|
||||
ERR_print_errors(bio_err);
|
||||
goto end;
|
||||
}
|
||||
@ -330,33 +203,20 @@ int MAIN(int argc, char **argv)
|
||||
"Generating DH parameters, %d bit long safe prime, generator %d\n",
|
||||
num, g);
|
||||
BIO_printf(bio_err, "This is going to take a long time\n");
|
||||
if (!dh || !DH_generate_parameters_ex(dh, num, g, &cb)) {
|
||||
if (dh == NULL || !DH_generate_parameters_ex(dh, num, g, cb)) {
|
||||
BN_GENCB_free(cb);
|
||||
ERR_print_errors(bio_err);
|
||||
goto end;
|
||||
}
|
||||
}
|
||||
|
||||
app_RAND_write_file(NULL, bio_err);
|
||||
BN_GENCB_free(cb);
|
||||
} else {
|
||||
|
||||
in = BIO_new(BIO_s_file());
|
||||
if (in == NULL) {
|
||||
ERR_print_errors(bio_err);
|
||||
in = bio_open_default(infile, 'r', informat);
|
||||
if (in == NULL)
|
||||
goto end;
|
||||
}
|
||||
if (infile == NULL)
|
||||
BIO_set_fp(in, stdin, BIO_NOCLOSE);
|
||||
else {
|
||||
if (BIO_read_filename(in, infile) <= 0) {
|
||||
perror(infile);
|
||||
goto end;
|
||||
}
|
||||
}
|
||||
|
||||
if (informat != FORMAT_ASN1 && informat != FORMAT_PEM) {
|
||||
BIO_printf(bio_err, "bad input format specified\n");
|
||||
goto end;
|
||||
}
|
||||
# ifndef OPENSSL_NO_DSA
|
||||
if (dsaparam) {
|
||||
DSA *dsa;
|
||||
@ -405,26 +265,6 @@ int MAIN(int argc, char **argv)
|
||||
/* dh != NULL */
|
||||
}
|
||||
|
||||
out = BIO_new(BIO_s_file());
|
||||
if (out == NULL) {
|
||||
ERR_print_errors(bio_err);
|
||||
goto end;
|
||||
}
|
||||
if (outfile == NULL) {
|
||||
BIO_set_fp(out, stdout, BIO_NOCLOSE);
|
||||
# ifdef OPENSSL_SYS_VMS
|
||||
{
|
||||
BIO *tmpbio = BIO_new(BIO_f_linebuffer());
|
||||
out = BIO_push(tmpbio, out);
|
||||
}
|
||||
# endif
|
||||
} else {
|
||||
if (BIO_write_filename(out, outfile) <= 0) {
|
||||
perror(outfile);
|
||||
goto end;
|
||||
}
|
||||
}
|
||||
|
||||
if (text) {
|
||||
DHparams_print(out, dh);
|
||||
}
|
||||
@ -435,77 +275,82 @@ int MAIN(int argc, char **argv)
|
||||
goto end;
|
||||
}
|
||||
if (i & DH_CHECK_P_NOT_PRIME)
|
||||
printf("p value is not prime\n");
|
||||
BIO_printf(bio_err, "WARNING: p value is not prime\n");
|
||||
if (i & DH_CHECK_P_NOT_SAFE_PRIME)
|
||||
printf("p value is not a safe prime\n");
|
||||
BIO_printf(bio_err, "WARNING: p value is not a safe prime\n");
|
||||
if (i & DH_CHECK_Q_NOT_PRIME)
|
||||
BIO_printf(bio_err, "WARNING: q value is not a prime\n");
|
||||
if (i & DH_CHECK_INVALID_Q_VALUE)
|
||||
BIO_printf(bio_err, "WARNING: q value is invalid\n");
|
||||
if (i & DH_CHECK_INVALID_J_VALUE)
|
||||
BIO_printf(bio_err, "WARNING: j value is invalid\n");
|
||||
if (i & DH_UNABLE_TO_CHECK_GENERATOR)
|
||||
printf("unable to check the generator value\n");
|
||||
BIO_printf(bio_err,
|
||||
"WARNING: unable to check the generator value\n");
|
||||
if (i & DH_NOT_SUITABLE_GENERATOR)
|
||||
printf("the g value is not a generator\n");
|
||||
BIO_printf(bio_err, "WARNING: the g value is not a generator\n");
|
||||
if (i == 0)
|
||||
printf("DH parameters appear to be ok.\n");
|
||||
BIO_printf(bio_err, "DH parameters appear to be ok.\n");
|
||||
if (num != 0 && i != 0) {
|
||||
/*
|
||||
* We have generated parameters but DH_check() indicates they are
|
||||
* invalid! This should never happen!
|
||||
*/
|
||||
BIO_printf(bio_err, "ERROR: Invalid parameters generated\n");
|
||||
goto end;
|
||||
}
|
||||
}
|
||||
if (C) {
|
||||
unsigned char *data;
|
||||
int len, l, bits;
|
||||
int len, bits;
|
||||
const BIGNUM *pbn, *gbn;
|
||||
|
||||
len = BN_num_bytes(dh->p);
|
||||
bits = BN_num_bits(dh->p);
|
||||
data = (unsigned char *)OPENSSL_malloc(len);
|
||||
if (data == NULL) {
|
||||
perror("OPENSSL_malloc");
|
||||
goto end;
|
||||
}
|
||||
printf("#ifndef HEADER_DH_H\n"
|
||||
"#include <openssl/dh.h>\n" "#endif\n");
|
||||
printf("DH *get_dh%d()\n\t{\n", bits);
|
||||
len = DH_size(dh);
|
||||
bits = DH_bits(dh);
|
||||
DH_get0_pqg(dh, &pbn, NULL, &gbn);
|
||||
data = app_malloc(len, "print a BN");
|
||||
|
||||
l = BN_bn2bin(dh->p, data);
|
||||
printf("\tstatic unsigned char dh%d_p[]={", bits);
|
||||
for (i = 0; i < l; i++) {
|
||||
if ((i % 12) == 0)
|
||||
printf("\n\t\t");
|
||||
printf("0x%02X,", data[i]);
|
||||
}
|
||||
printf("\n\t\t};\n");
|
||||
|
||||
l = BN_bn2bin(dh->g, data);
|
||||
printf("\tstatic unsigned char dh%d_g[]={", bits);
|
||||
for (i = 0; i < l; i++) {
|
||||
if ((i % 12) == 0)
|
||||
printf("\n\t\t");
|
||||
printf("0x%02X,", data[i]);
|
||||
}
|
||||
printf("\n\t\t};\n");
|
||||
|
||||
printf("\tDH *dh;\n\n");
|
||||
printf("\tif ((dh=DH_new()) == NULL) return(NULL);\n");
|
||||
printf("\tdh->p=BN_bin2bn(dh%d_p,sizeof(dh%d_p),NULL);\n",
|
||||
bits, bits);
|
||||
printf("\tdh->g=BN_bin2bn(dh%d_g,sizeof(dh%d_g),NULL);\n",
|
||||
bits, bits);
|
||||
printf("\tif ((dh->p == NULL) || (dh->g == NULL))\n");
|
||||
printf("\t\t{ DH_free(dh); return(NULL); }\n");
|
||||
if (dh->length)
|
||||
printf("\tdh->length = %ld;\n", dh->length);
|
||||
printf("\treturn(dh);\n\t}\n");
|
||||
BIO_printf(out, "static DH *get_dh%d(void)\n{\n", bits);
|
||||
print_bignum_var(out, pbn, "dhp", bits, data);
|
||||
print_bignum_var(out, gbn, "dhg", bits, data);
|
||||
BIO_printf(out, " DH *dh = DH_new();\n"
|
||||
" BIGNUM *p, *g;\n"
|
||||
"\n"
|
||||
" if (dh == NULL)\n"
|
||||
" return NULL;\n");
|
||||
BIO_printf(out, " p = BN_bin2bn(dhp_%d, sizeof(dhp_%d), NULL);\n",
|
||||
bits, bits);
|
||||
BIO_printf(out, " g = BN_bin2bn(dhg_%d, sizeof(dhg_%d), NULL);\n",
|
||||
bits, bits);
|
||||
BIO_printf(out, " if (p == NULL || g == NULL\n"
|
||||
" || !DH_set0_pqg(dh, p, NULL, g)) {\n"
|
||||
" DH_free(dh);\n"
|
||||
" BN_free(p);\n"
|
||||
" BN_free(g);\n"
|
||||
" return NULL;\n"
|
||||
" }\n");
|
||||
if (DH_get_length(dh) > 0)
|
||||
BIO_printf(out,
|
||||
" if (!DH_set_length(dh, %ld)) {\n"
|
||||
" DH_free(dh);\n"
|
||||
" return NULL;\n"
|
||||
" }\n", DH_get_length(dh));
|
||||
BIO_printf(out, " return dh;\n}\n");
|
||||
OPENSSL_free(data);
|
||||
}
|
||||
|
||||
if (!noout) {
|
||||
const BIGNUM *q;
|
||||
DH_get0_pqg(dh, NULL, &q, NULL);
|
||||
if (outformat == FORMAT_ASN1) {
|
||||
if (dh->q != NULL)
|
||||
if (q != NULL)
|
||||
i = i2d_DHxparams_bio(out, dh);
|
||||
else
|
||||
i = i2d_DHparams_bio(out, dh);
|
||||
} else if (outformat == FORMAT_PEM) {
|
||||
if (dh->q != NULL)
|
||||
i = PEM_write_bio_DHxparams(out, dh);
|
||||
else
|
||||
i = PEM_write_bio_DHparams(out, dh);
|
||||
} else if (q != NULL) {
|
||||
i = PEM_write_bio_DHxparams(out, dh);
|
||||
} else {
|
||||
BIO_printf(bio_err, "bad output format specified for outfile\n");
|
||||
goto end;
|
||||
i = PEM_write_bio_DHparams(out, dh);
|
||||
}
|
||||
if (!i) {
|
||||
BIO_printf(bio_err, "unable to write DH parameters\n");
|
||||
@ -515,42 +360,20 @@ int MAIN(int argc, char **argv)
|
||||
}
|
||||
ret = 0;
|
||||
end:
|
||||
if (in != NULL)
|
||||
BIO_free(in);
|
||||
if (out != NULL)
|
||||
BIO_free_all(out);
|
||||
if (dh != NULL)
|
||||
DH_free(dh);
|
||||
BIO_free(in);
|
||||
BIO_free_all(out);
|
||||
DH_free(dh);
|
||||
release_engine(e);
|
||||
apps_shutdown();
|
||||
OPENSSL_EXIT(ret);
|
||||
return ret;
|
||||
}
|
||||
|
||||
/* dh_cb is identical to dsa_cb in apps/dsaparam.c */
|
||||
static int MS_CALLBACK dh_cb(int p, int n, BN_GENCB *cb)
|
||||
static int dh_cb(int p, int n, BN_GENCB *cb)
|
||||
{
|
||||
char c = '*';
|
||||
static const char symbols[] = ".+*\n";
|
||||
char c = (p >= 0 && (size_t)p < sizeof(symbols) - 1) ? symbols[p] : '?';
|
||||
|
||||
if (p == 0)
|
||||
c = '.';
|
||||
if (p == 1)
|
||||
c = '+';
|
||||
if (p == 2)
|
||||
c = '*';
|
||||
if (p == 3)
|
||||
c = '\n';
|
||||
BIO_write(cb->arg, &c, 1);
|
||||
(void)BIO_flush(cb->arg);
|
||||
# ifdef LINT
|
||||
p = n;
|
||||
# endif
|
||||
BIO_write(BN_GENCB_get_arg(cb), &c, 1);
|
||||
(void)BIO_flush(BN_GENCB_get_arg(cb));
|
||||
return 1;
|
||||
}
|
||||
|
||||
#else /* !OPENSSL_NO_DH */
|
||||
|
||||
# if PEDANTIC
|
||||
static void *dummy = &dummy;
|
||||
# endif
|
||||
|
||||
#endif
|
||||
|
@ -11,30 +11,37 @@ tOFDITEAl+YZZariXOD7tdOSOl9RLMPC6+daHKS9e68u3enxhqnDGQIUB78dhW77
|
||||
J6zsFbSEHaQGUmfSeoM=
|
||||
-----END DSA PRIVATE KEY-----
|
||||
-----BEGIN CERTIFICATE REQUEST-----
|
||||
MIICUjCCAhECAQAwUjELMAkGA1UEBhMCQVUxEzARBgNVBAgTClNvbWUtU3RhdGUx
|
||||
ITAfBgNVBAoTGEludGVybmV0IFdpZGdpdHMgUHR5IEx0ZDELMAkGA1UEAxMCQ0Ew
|
||||
ggG0MIIBKQYFKw4DAgwwggEeAoGBAKc/boW/QWopffCfRxkwkJoJHdpqMx7FPYaW
|
||||
sxXgUy6P4FmCc5A+dTGZR3pS+4Xk2aZ7OJtoioSbh8YetX6GS1NbWc9xZRmIbs5m
|
||||
rmuINvvsKNzC16W75Sw5JkvamnAYlTeVEFYj9hXtugRe3jlP/bdDH7WkZW/NgBHk
|
||||
cJVbUM1JAhUA9wcx7fpsBgPVhYocrJxl51BmZW8CgYBN30wDppGK9RlvUEYlmeVo
|
||||
bzDjaeHls12YuyiGSPzemQQ/X4gMnHMkDSBduSqaPxiWJ+Rih8F7dGJT/GEnqHqR
|
||||
CZ228U2cVA9YBu5JdAfOVX4jzhb2ytxaYQF+yXG1TfbcNCmHaPZeIJOz2/XkCWxB
|
||||
F5WS6wG1c6Vqftgy7Q4CuAOBhAACgYAapll6iqz9XrZFlk2GCVcB+KihxWnH7IuH
|
||||
vSLw9YUrJahcBHmbpvt494lF4gC5w3WPM+vXJofbusk4GoQEEsQNMDaah4m49uUq
|
||||
AylOVFJJJXuirVJ+o+0TtOFDITEAl+YZZariXOD7tdOSOl9RLMPC6+daHKS9e68u
|
||||
3enxhqnDGaAAMAkGBSsOAwIbBQADMAAwLQIVAJGVuFsG/0DBuSZ0jF7ypdU0/G0v
|
||||
AhQfeF5BoMMDbX/kidUVpQ6gadPlZA==
|
||||
MIICVjCCAhMCAQAwUjELMAkGA1UEBhMCQVUxEzARBgNVBAgMClNvbWUtU3RhdGUx
|
||||
ITAfBgNVBAoMGEludGVybmV0IFdpZGdpdHMgUHR5IEx0ZDELMAkGA1UEAwwCQ0Ew
|
||||
ggG2MIIBKwYHKoZIzjgEATCCAR4CgYEApz9uhb9Bail98J9HGTCQmgkd2mozHsU9
|
||||
hpazFeBTLo/gWYJzkD51MZlHelL7heTZpns4m2iKhJuHxh61foZLU1tZz3FlGYhu
|
||||
zmaua4g2++wo3MLXpbvlLDkmS9qacBiVN5UQViP2Fe26BF7eOU/9t0MftaRlb82A
|
||||
EeRwlVtQzUkCFQD3BzHt+mwGA9WFihysnGXnUGZlbwKBgE3fTAOmkYr1GW9QRiWZ
|
||||
5WhvMONp4eWzXZi7KIZI/N6ZBD9fiAyccyQNIF25Kpo/GJYn5GKHwXt0YlP8YSeo
|
||||
epEJnbbxTZxUD1gG7kl0B85VfiPOFvbK3FphAX7JcbVN9tw0KYdo9l4gk7Pb9eQJ
|
||||
bEEXlZLrAbVzpWp+2DLtDgK4A4GEAAKBgBqmWXqKrP1etkWWTYYJVwH4qKHFacfs
|
||||
i4e9IvD1hSslqFwEeZum+3j3iUXiALnDdY8z69cmh9u6yTgahAQSxA0wNpqHibj2
|
||||
5SoDKU5UUkkle6KtUn6j7RO04UMhMQCX5hllquJc4Pu105I6X1Esw8Lr51ocpL17
|
||||
ry7d6fGGqcMZoAAwCwYJYIZIAWUDBAMCAzAAMC0CFCp7rUwGJNtxK6Aqo6k6US+S
|
||||
KP8sAhUAyfSi8Zs3QAvkJoFG0IMRaq8M03I=
|
||||
-----END CERTIFICATE REQUEST-----
|
||||
-----BEGIN CERTIFICATE-----
|
||||
MIIBrjCCAWwCAQswCQYFKw4DAhsFADBTMQswCQYDVQQGEwJBVTETMBEGA1UECBMK
|
||||
U29tZS1TdGF0ZTEhMB8GA1UEChMYSW50ZXJuZXQgV2lkZ2l0cyBQdHkgTHRkMQww
|
||||
CgYDVQQDEwNQQ0EwHhcNOTcwNjE1MDIxNDI5WhcNOTcwNzE1MDIxNDI5WjBSMQsw
|
||||
CQYDVQQGEwJBVTETMBEGA1UECBMKU29tZS1TdGF0ZTEhMB8GA1UEChMYSW50ZXJu
|
||||
ZXQgV2lkZ2l0cyBQdHkgTHRkMQswCQYDVQQDEwJDQTCBkjAJBgUrDgMCDAUAA4GE
|
||||
AAKBgBqmWXqKrP1etkWWTYYJVwH4qKHFacfsi4e9IvD1hSslqFwEeZum+3j3iUXi
|
||||
ALnDdY8z69cmh9u6yTgahAQSxA0wNpqHibj25SoDKU5UUkkle6KtUn6j7RO04UMh
|
||||
MQCX5hllquJc4Pu105I6X1Esw8Lr51ocpL17ry7d6fGGqcMZMAkGBSsOAwIbBQAD
|
||||
MQAwLgIVAJ4wtQsANPxHo7Q4IQZYsL12SKdbAhUAjJ9n38zxT+iai2164xS+LIfa
|
||||
C1Q=
|
||||
MIIDMDCCAuygAwIBAgIBAjALBglghkgBZQMEAwIwUzELMAkGA1UEBhMCQVUxEzAR
|
||||
BgNVBAgMClNvbWUtU3RhdGUxITAfBgNVBAoMGEludGVybmV0IFdpZGdpdHMgUHR5
|
||||
IEx0ZDEMMAoGA1UEAwwDUENBMCAXDTE2MDExMzIxNDE0OVoYDzMwMTUwNTE2MjE0
|
||||
MTQ5WjBSMQswCQYDVQQGEwJBVTETMBEGA1UECAwKU29tZS1TdGF0ZTEhMB8GA1UE
|
||||
CgwYSW50ZXJuZXQgV2lkZ2l0cyBQdHkgTHRkMQswCQYDVQQDDAJDQTCCAbYwggEr
|
||||
BgcqhkjOOAQBMIIBHgKBgQCnP26Fv0FqKX3wn0cZMJCaCR3aajMexT2GlrMV4FMu
|
||||
j+BZgnOQPnUxmUd6UvuF5NmmezibaIqEm4fGHrV+hktTW1nPcWUZiG7OZq5riDb7
|
||||
7Cjcwtelu+UsOSZL2ppwGJU3lRBWI/YV7boEXt45T/23Qx+1pGVvzYAR5HCVW1DN
|
||||
SQIVAPcHMe36bAYD1YWKHKycZedQZmVvAoGATd9MA6aRivUZb1BGJZnlaG8w42nh
|
||||
5bNdmLsohkj83pkEP1+IDJxzJA0gXbkqmj8YlifkYofBe3RiU/xhJ6h6kQmdtvFN
|
||||
nFQPWAbuSXQHzlV+I84W9srcWmEBfslxtU323DQph2j2XiCTs9v15AlsQReVkusB
|
||||
tXOlan7YMu0OArgDgYQAAoGAGqZZeoqs/V62RZZNhglXAfioocVpx+yLh70i8PWF
|
||||
KyWoXAR5m6b7ePeJReIAucN1jzPr1yaH27rJOBqEBBLEDTA2moeJuPblKgMpTlRS
|
||||
SSV7oq1SfqPtE7ThQyExAJfmGWWq4lzg+7XTkjpfUSzDwuvnWhykvXuvLt3p8Yap
|
||||
wxmjUDBOMB0GA1UdDgQWBBTMZcORcBEVlqO/CD4pf4V6N1NM1zAfBgNVHSMEGDAW
|
||||
gBTGjwJ33uvjSa20RNrMKWoGptOLdDAMBgNVHRMEBTADAQH/MAsGCWCGSAFlAwQD
|
||||
AgMxADAuAhUA4V6MrHufG8R79E+AtVO02olPxK8CFQDkZyo/TWpavsUBRDJbCeD9
|
||||
jgjIkA==
|
||||
-----END CERTIFICATE-----
|
||||
|
||||
|
@ -11,36 +11,37 @@ umz6tl+iUcNe5EoxdsYV1IXSddjOi08LOLsZq7AQlNnKvbtlmMDULpqkZJD0bO7A
|
||||
6TicfImU7UFRn9h00j0lJQ==
|
||||
-----END DSA PRIVATE KEY-----
|
||||
-----BEGIN CERTIFICATE REQUEST-----
|
||||
MIICVTCCAhMCAQAwUzELMAkGA1UEBhMCQVUxEzARBgNVBAgTClNvbWUtU3RhdGUx
|
||||
ITAfBgNVBAoTGEludGVybmV0IFdpZGdpdHMgUHR5IEx0ZDEMMAoGA1UEAxMDUENB
|
||||
MIIBtTCCASkGBSsOAwIMMIIBHgKBgQCnP26Fv0FqKX3wn0cZMJCaCR3aajMexT2G
|
||||
lrMV4FMuj+BZgnOQPnUxmUd6UvuF5NmmezibaIqEm4fGHrV+hktTW1nPcWUZiG7O
|
||||
Zq5riDb77Cjcwtelu+UsOSZL2ppwGJU3lRBWI/YV7boEXt45T/23Qx+1pGVvzYAR
|
||||
5HCVW1DNSQIVAPcHMe36bAYD1YWKHKycZedQZmVvAoGATd9MA6aRivUZb1BGJZnl
|
||||
aG8w42nh5bNdmLsohkj83pkEP1+IDJxzJA0gXbkqmj8YlifkYofBe3RiU/xhJ6h6
|
||||
kQmdtvFNnFQPWAbuSXQHzlV+I84W9srcWmEBfslxtU323DQph2j2XiCTs9v15Als
|
||||
QReVkusBtXOlan7YMu0OArgDgYUAAoGBAKbtuR5AdW+ICjCFe2ixjUiJJzM2IKwe
|
||||
6NZEMXg39+HQ1UTPTmfLZLps+rZfolHDXuRKMXbGFdSF0nXYzotPCzi7GauwEJTZ
|
||||
yr27ZZjA1C6apGSQ9GzuwNvZ4rCXystVEagAS8OQ4H3D4dWS17Zg31ICb5o4E5r0
|
||||
z09o/Uz46u0VoAAwCQYFKw4DAhsFAAMxADAuAhUArRubTxsbIXy3AhtjQ943AbNB
|
||||
nSICFQCu+g1iW3jwF+gOcbroD4S/ZcvB3w==
|
||||
MIICWDCCAhUCAQAwUzELMAkGA1UEBhMCQVUxEzARBgNVBAgMClNvbWUtU3RhdGUx
|
||||
ITAfBgNVBAoMGEludGVybmV0IFdpZGdpdHMgUHR5IEx0ZDEMMAoGA1UEAwwDUENB
|
||||
MIIBtzCCASsGByqGSM44BAEwggEeAoGBAKc/boW/QWopffCfRxkwkJoJHdpqMx7F
|
||||
PYaWsxXgUy6P4FmCc5A+dTGZR3pS+4Xk2aZ7OJtoioSbh8YetX6GS1NbWc9xZRmI
|
||||
bs5mrmuINvvsKNzC16W75Sw5JkvamnAYlTeVEFYj9hXtugRe3jlP/bdDH7WkZW/N
|
||||
gBHkcJVbUM1JAhUA9wcx7fpsBgPVhYocrJxl51BmZW8CgYBN30wDppGK9RlvUEYl
|
||||
meVobzDjaeHls12YuyiGSPzemQQ/X4gMnHMkDSBduSqaPxiWJ+Rih8F7dGJT/GEn
|
||||
qHqRCZ228U2cVA9YBu5JdAfOVX4jzhb2ytxaYQF+yXG1TfbcNCmHaPZeIJOz2/Xk
|
||||
CWxBF5WS6wG1c6Vqftgy7Q4CuAOBhQACgYEApu25HkB1b4gKMIV7aLGNSIknMzYg
|
||||
rB7o1kQxeDf34dDVRM9OZ8tkumz6tl+iUcNe5EoxdsYV1IXSddjOi08LOLsZq7AQ
|
||||
lNnKvbtlmMDULpqkZJD0bO7A29nisJfKy1URqABLw5DgfcPh1ZLXtmDfUgJvmjgT
|
||||
mvTPT2j9TPjq7RWgADALBglghkgBZQMEAwIDMAAwLQIVAPA6/jxCT1D2HgzE4iZR
|
||||
AEup/C7YAhRPLTQvQnAiS5FRrA+8SwBLvDAsaw==
|
||||
-----END CERTIFICATE REQUEST-----
|
||||
-----BEGIN CERTIFICATE-----
|
||||
MIIC0zCCApECAQAwCQYFKw4DAhsFADBTMQswCQYDVQQGEwJBVTETMBEGA1UECBMK
|
||||
U29tZS1TdGF0ZTEhMB8GA1UEChMYSW50ZXJuZXQgV2lkZ2l0cyBQdHkgTHRkMQww
|
||||
CgYDVQQDEwNQQ0EwHhcNOTcwNjE0MjI1NDQ1WhcNOTcwNzE0MjI1NDQ1WjBTMQsw
|
||||
CQYDVQQGEwJBVTETMBEGA1UECBMKU29tZS1TdGF0ZTEhMB8GA1UEChMYSW50ZXJu
|
||||
ZXQgV2lkZ2l0cyBQdHkgTHRkMQwwCgYDVQQDEwNQQ0EwggG1MIIBKQYFKw4DAgww
|
||||
ggEeAoGBAKc/boW/QWopffCfRxkwkJoJHdpqMx7FPYaWsxXgUy6P4FmCc5A+dTGZ
|
||||
R3pS+4Xk2aZ7OJtoioSbh8YetX6GS1NbWc9xZRmIbs5mrmuINvvsKNzC16W75Sw5
|
||||
JkvamnAYlTeVEFYj9hXtugRe3jlP/bdDH7WkZW/NgBHkcJVbUM1JAhUA9wcx7fps
|
||||
BgPVhYocrJxl51BmZW8CgYBN30wDppGK9RlvUEYlmeVobzDjaeHls12YuyiGSPze
|
||||
mQQ/X4gMnHMkDSBduSqaPxiWJ+Rih8F7dGJT/GEnqHqRCZ228U2cVA9YBu5JdAfO
|
||||
VX4jzhb2ytxaYQF+yXG1TfbcNCmHaPZeIJOz2/XkCWxBF5WS6wG1c6Vqftgy7Q4C
|
||||
uAOBhQACgYEApu25HkB1b4gKMIV7aLGNSIknMzYgrB7o1kQxeDf34dDVRM9OZ8tk
|
||||
umz6tl+iUcNe5EoxdsYV1IXSddjOi08LOLsZq7AQlNnKvbtlmMDULpqkZJD0bO7A
|
||||
29nisJfKy1URqABLw5DgfcPh1ZLXtmDfUgJvmjgTmvTPT2j9TPjq7RUwCQYFKw4D
|
||||
AhsFAAMxADAuAhUAvtv6AkMolix1Jvy3UnVEIUqdCUICFQC+jq8P49mwrY9oJ24n
|
||||
5rKUjNBhSg==
|
||||
MIIDMDCCAu6gAwIBAgIBATALBglghkgBZQMEAwIwUzELMAkGA1UEBhMCQVUxEzAR
|
||||
BgNVBAgMClNvbWUtU3RhdGUxITAfBgNVBAoMGEludGVybmV0IFdpZGdpdHMgUHR5
|
||||
IEx0ZDEMMAoGA1UEAwwDUENBMCAXDTE2MDExMzIxNDE0OVoYDzMwMTUwNTE2MjE0
|
||||
MTQ5WjBTMQswCQYDVQQGEwJBVTETMBEGA1UECAwKU29tZS1TdGF0ZTEhMB8GA1UE
|
||||
CgwYSW50ZXJuZXQgV2lkZ2l0cyBQdHkgTHRkMQwwCgYDVQQDDANQQ0EwggG3MIIB
|
||||
KwYHKoZIzjgEATCCAR4CgYEApz9uhb9Bail98J9HGTCQmgkd2mozHsU9hpazFeBT
|
||||
Lo/gWYJzkD51MZlHelL7heTZpns4m2iKhJuHxh61foZLU1tZz3FlGYhuzmaua4g2
|
||||
++wo3MLXpbvlLDkmS9qacBiVN5UQViP2Fe26BF7eOU/9t0MftaRlb82AEeRwlVtQ
|
||||
zUkCFQD3BzHt+mwGA9WFihysnGXnUGZlbwKBgE3fTAOmkYr1GW9QRiWZ5WhvMONp
|
||||
4eWzXZi7KIZI/N6ZBD9fiAyccyQNIF25Kpo/GJYn5GKHwXt0YlP8YSeoepEJnbbx
|
||||
TZxUD1gG7kl0B85VfiPOFvbK3FphAX7JcbVN9tw0KYdo9l4gk7Pb9eQJbEEXlZLr
|
||||
AbVzpWp+2DLtDgK4A4GFAAKBgQCm7bkeQHVviAowhXtosY1IiSczNiCsHujWRDF4
|
||||
N/fh0NVEz05ny2S6bPq2X6JRw17kSjF2xhXUhdJ12M6LTws4uxmrsBCU2cq9u2WY
|
||||
wNQumqRkkPRs7sDb2eKwl8rLVRGoAEvDkOB9w+HVkte2YN9SAm+aOBOa9M9PaP1M
|
||||
+OrtFaNQME4wHQYDVR0OBBYEFMaPAnfe6+NJrbRE2swpagam04t0MB8GA1UdIwQY
|
||||
MBaAFMaPAnfe6+NJrbRE2swpagam04t0MAwGA1UdEwQFMAMBAf8wCwYJYIZIAWUD
|
||||
BAMCAy8AMCwCFFhdz4fzQo9BBF20U1CHldYTi/D7AhQydDnDMj21y+U1UhDZJrvh
|
||||
lnt88g==
|
||||
-----END CERTIFICATE-----
|
||||
|
||||
|
@ -1,68 +1,23 @@
|
||||
/* apps/dsa.c */
|
||||
/* Copyright (C) 1995-1998 Eric Young (eay@cryptsoft.com)
|
||||
* All rights reserved.
|
||||
/*
|
||||
* Copyright 1995-2018 The OpenSSL Project Authors. All Rights Reserved.
|
||||
*
|
||||
* This package is an SSL implementation written
|
||||
* by Eric Young (eay@cryptsoft.com).
|
||||
* The implementation was written so as to conform with Netscapes SSL.
|
||||
*
|
||||
* This library is free for commercial and non-commercial use as long as
|
||||
* the following conditions are aheared to. The following conditions
|
||||
* apply to all code found in this distribution, be it the RC4, RSA,
|
||||
* lhash, DES, etc., code; not just the SSL code. The SSL documentation
|
||||
* included with this distribution is covered by the same copyright terms
|
||||
* except that the holder is Tim Hudson (tjh@cryptsoft.com).
|
||||
*
|
||||
* Copyright remains Eric Young's, and as such any Copyright notices in
|
||||
* the code are not to be removed.
|
||||
* If this package is used in a product, Eric Young should be given attribution
|
||||
* as the author of the parts of the library used.
|
||||
* This can be in the form of a textual message at program startup or
|
||||
* in documentation (online or textual) provided with the package.
|
||||
*
|
||||
* Redistribution and use in source and binary forms, with or without
|
||||
* modification, are permitted provided that the following conditions
|
||||
* are met:
|
||||
* 1. Redistributions of source code must retain the copyright
|
||||
* notice, this list of conditions and the following disclaimer.
|
||||
* 2. Redistributions in binary form must reproduce the above copyright
|
||||
* notice, this list of conditions and the following disclaimer in the
|
||||
* documentation and/or other materials provided with the distribution.
|
||||
* 3. All advertising materials mentioning features or use of this software
|
||||
* must display the following acknowledgement:
|
||||
* "This product includes cryptographic software written by
|
||||
* Eric Young (eay@cryptsoft.com)"
|
||||
* The word 'cryptographic' can be left out if the rouines from the library
|
||||
* being used are not cryptographic related :-).
|
||||
* 4. If you include any Windows specific code (or a derivative thereof) from
|
||||
* the apps directory (application code) you must include an acknowledgement:
|
||||
* "This product includes software written by Tim Hudson (tjh@cryptsoft.com)"
|
||||
*
|
||||
* THIS SOFTWARE IS PROVIDED BY ERIC YOUNG ``AS IS'' AND
|
||||
* ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
|
||||
* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
|
||||
* ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE
|
||||
* FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
|
||||
* DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
|
||||
* OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
|
||||
* HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
|
||||
* LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
|
||||
* OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
|
||||
* SUCH DAMAGE.
|
||||
*
|
||||
* The licence and distribution terms for any publically available version or
|
||||
* derivative of this code cannot be changed. i.e. this code cannot simply be
|
||||
* copied and put under another distribution licence
|
||||
* [including the GNU Public Licence.]
|
||||
* Licensed under the OpenSSL license (the "License"). You may not use
|
||||
* this file except in compliance with the License. You can obtain a copy
|
||||
* in the file LICENSE in the source distribution or at
|
||||
* https://www.openssl.org/source/license.html
|
||||
*/
|
||||
|
||||
#include <openssl/opensslconf.h> /* for OPENSSL_NO_DSA */
|
||||
#ifndef OPENSSL_NO_DSA
|
||||
#include <openssl/opensslconf.h>
|
||||
#ifdef OPENSSL_NO_DSA
|
||||
NON_EMPTY_TRANSLATION_UNIT
|
||||
#else
|
||||
|
||||
# include <stdio.h>
|
||||
# include <stdlib.h>
|
||||
# include <string.h>
|
||||
# include <time.h>
|
||||
# include "apps.h"
|
||||
# include "progs.h"
|
||||
# include <openssl/bio.h>
|
||||
# include <openssl/err.h>
|
||||
# include <openssl/dsa.h>
|
||||
@ -71,206 +26,143 @@
|
||||
# include <openssl/pem.h>
|
||||
# include <openssl/bn.h>
|
||||
|
||||
# undef PROG
|
||||
# define PROG dsa_main
|
||||
typedef enum OPTION_choice {
|
||||
OPT_ERR = -1, OPT_EOF = 0, OPT_HELP,
|
||||
OPT_INFORM, OPT_OUTFORM, OPT_IN, OPT_OUT, OPT_ENGINE,
|
||||
/* Do not change the order here; see case statements below */
|
||||
OPT_PVK_NONE, OPT_PVK_WEAK, OPT_PVK_STRONG,
|
||||
OPT_NOOUT, OPT_TEXT, OPT_MODULUS, OPT_PUBIN,
|
||||
OPT_PUBOUT, OPT_CIPHER, OPT_PASSIN, OPT_PASSOUT
|
||||
} OPTION_CHOICE;
|
||||
|
||||
/*-
|
||||
* -inform arg - input format - default PEM (one of DER, NET or PEM)
|
||||
* -outform arg - output format - default PEM
|
||||
* -in arg - input file - default stdin
|
||||
* -out arg - output file - default stdout
|
||||
* -des - encrypt output if PEM format with DES in cbc mode
|
||||
* -des3 - encrypt output if PEM format
|
||||
* -idea - encrypt output if PEM format
|
||||
* -aes128 - encrypt output if PEM format
|
||||
* -aes192 - encrypt output if PEM format
|
||||
* -aes256 - encrypt output if PEM format
|
||||
* -camellia128 - encrypt output if PEM format
|
||||
* -camellia192 - encrypt output if PEM format
|
||||
* -camellia256 - encrypt output if PEM format
|
||||
* -seed - encrypt output if PEM format
|
||||
* -text - print a text version
|
||||
* -modulus - print the DSA public key
|
||||
*/
|
||||
|
||||
int MAIN(int, char **);
|
||||
|
||||
int MAIN(int argc, char **argv)
|
||||
{
|
||||
ENGINE *e = NULL;
|
||||
int ret = 1;
|
||||
DSA *dsa = NULL;
|
||||
int i, badops = 0;
|
||||
const EVP_CIPHER *enc = NULL;
|
||||
BIO *in = NULL, *out = NULL;
|
||||
int informat, outformat, text = 0, noout = 0;
|
||||
int pubin = 0, pubout = 0;
|
||||
char *infile, *outfile, *prog;
|
||||
char *engine;
|
||||
char *passargin = NULL, *passargout = NULL;
|
||||
char *passin = NULL, *passout = NULL;
|
||||
int modulus = 0;
|
||||
|
||||
int pvk_encr = 2;
|
||||
|
||||
apps_startup();
|
||||
|
||||
if (bio_err == NULL)
|
||||
if ((bio_err = BIO_new(BIO_s_file())) != NULL)
|
||||
BIO_set_fp(bio_err, stderr, BIO_NOCLOSE | BIO_FP_TEXT);
|
||||
|
||||
if (!load_config(bio_err, NULL))
|
||||
goto end;
|
||||
|
||||
engine = NULL;
|
||||
infile = NULL;
|
||||
outfile = NULL;
|
||||
informat = FORMAT_PEM;
|
||||
outformat = FORMAT_PEM;
|
||||
|
||||
prog = argv[0];
|
||||
argc--;
|
||||
argv++;
|
||||
while (argc >= 1) {
|
||||
if (strcmp(*argv, "-inform") == 0) {
|
||||
if (--argc < 1)
|
||||
goto bad;
|
||||
informat = str2fmt(*(++argv));
|
||||
} else if (strcmp(*argv, "-outform") == 0) {
|
||||
if (--argc < 1)
|
||||
goto bad;
|
||||
outformat = str2fmt(*(++argv));
|
||||
} else if (strcmp(*argv, "-in") == 0) {
|
||||
if (--argc < 1)
|
||||
goto bad;
|
||||
infile = *(++argv);
|
||||
} else if (strcmp(*argv, "-out") == 0) {
|
||||
if (--argc < 1)
|
||||
goto bad;
|
||||
outfile = *(++argv);
|
||||
} else if (strcmp(*argv, "-passin") == 0) {
|
||||
if (--argc < 1)
|
||||
goto bad;
|
||||
passargin = *(++argv);
|
||||
} else if (strcmp(*argv, "-passout") == 0) {
|
||||
if (--argc < 1)
|
||||
goto bad;
|
||||
passargout = *(++argv);
|
||||
}
|
||||
# ifndef OPENSSL_NO_ENGINE
|
||||
else if (strcmp(*argv, "-engine") == 0) {
|
||||
if (--argc < 1)
|
||||
goto bad;
|
||||
engine = *(++argv);
|
||||
}
|
||||
const OPTIONS dsa_options[] = {
|
||||
{"help", OPT_HELP, '-', "Display this summary"},
|
||||
{"inform", OPT_INFORM, 'f', "Input format, DER PEM PVK"},
|
||||
{"outform", OPT_OUTFORM, 'f', "Output format, DER PEM PVK"},
|
||||
{"in", OPT_IN, 's', "Input key"},
|
||||
{"out", OPT_OUT, '>', "Output file"},
|
||||
{"noout", OPT_NOOUT, '-', "Don't print key out"},
|
||||
{"text", OPT_TEXT, '-', "Print the key in text"},
|
||||
{"modulus", OPT_MODULUS, '-', "Print the DSA public value"},
|
||||
{"pubin", OPT_PUBIN, '-', "Expect a public key in input file"},
|
||||
{"pubout", OPT_PUBOUT, '-', "Output public key, not private"},
|
||||
{"passin", OPT_PASSIN, 's', "Input file pass phrase source"},
|
||||
{"passout", OPT_PASSOUT, 's', "Output file pass phrase source"},
|
||||
{"", OPT_CIPHER, '-', "Any supported cipher"},
|
||||
# ifndef OPENSSL_NO_RC4
|
||||
{"pvk-strong", OPT_PVK_STRONG, '-', "Enable 'Strong' PVK encoding level (default)"},
|
||||
{"pvk-weak", OPT_PVK_WEAK, '-', "Enable 'Weak' PVK encoding level"},
|
||||
{"pvk-none", OPT_PVK_NONE, '-', "Don't enforce PVK encoding"},
|
||||
# endif
|
||||
else if (strcmp(*argv, "-pvk-strong") == 0)
|
||||
pvk_encr = 2;
|
||||
else if (strcmp(*argv, "-pvk-weak") == 0)
|
||||
pvk_encr = 1;
|
||||
else if (strcmp(*argv, "-pvk-none") == 0)
|
||||
pvk_encr = 0;
|
||||
else if (strcmp(*argv, "-noout") == 0)
|
||||
# ifndef OPENSSL_NO_ENGINE
|
||||
{"engine", OPT_ENGINE, 's', "Use engine e, possibly a hardware device"},
|
||||
# endif
|
||||
{NULL}
|
||||
};
|
||||
|
||||
int dsa_main(int argc, char **argv)
|
||||
{
|
||||
BIO *out = NULL;
|
||||
DSA *dsa = NULL;
|
||||
ENGINE *e = NULL;
|
||||
const EVP_CIPHER *enc = NULL;
|
||||
char *infile = NULL, *outfile = NULL, *prog;
|
||||
char *passin = NULL, *passout = NULL, *passinarg = NULL, *passoutarg = NULL;
|
||||
OPTION_CHOICE o;
|
||||
int informat = FORMAT_PEM, outformat = FORMAT_PEM, text = 0, noout = 0;
|
||||
int i, modulus = 0, pubin = 0, pubout = 0, ret = 1;
|
||||
# ifndef OPENSSL_NO_RC4
|
||||
int pvk_encr = 2;
|
||||
# endif
|
||||
int private = 0;
|
||||
|
||||
prog = opt_init(argc, argv, dsa_options);
|
||||
while ((o = opt_next()) != OPT_EOF) {
|
||||
switch (o) {
|
||||
case OPT_EOF:
|
||||
case OPT_ERR:
|
||||
opthelp:
|
||||
ret = 0;
|
||||
BIO_printf(bio_err, "%s: Use -help for summary.\n", prog);
|
||||
goto end;
|
||||
case OPT_HELP:
|
||||
opt_help(dsa_options);
|
||||
ret = 0;
|
||||
goto end;
|
||||
case OPT_INFORM:
|
||||
if (!opt_format(opt_arg(), OPT_FMT_ANY, &informat))
|
||||
goto opthelp;
|
||||
break;
|
||||
case OPT_IN:
|
||||
infile = opt_arg();
|
||||
break;
|
||||
case OPT_OUTFORM:
|
||||
if (!opt_format(opt_arg(), OPT_FMT_ANY, &outformat))
|
||||
goto opthelp;
|
||||
break;
|
||||
case OPT_OUT:
|
||||
outfile = opt_arg();
|
||||
break;
|
||||
case OPT_ENGINE:
|
||||
e = setup_engine(opt_arg(), 0);
|
||||
break;
|
||||
case OPT_PASSIN:
|
||||
passinarg = opt_arg();
|
||||
break;
|
||||
case OPT_PASSOUT:
|
||||
passoutarg = opt_arg();
|
||||
break;
|
||||
case OPT_PVK_STRONG: /* pvk_encr:= 2 */
|
||||
case OPT_PVK_WEAK: /* pvk_encr:= 1 */
|
||||
case OPT_PVK_NONE: /* pvk_encr:= 0 */
|
||||
#ifndef OPENSSL_NO_RC4
|
||||
pvk_encr = (o - OPT_PVK_NONE);
|
||||
#endif
|
||||
break;
|
||||
case OPT_NOOUT:
|
||||
noout = 1;
|
||||
else if (strcmp(*argv, "-text") == 0)
|
||||
break;
|
||||
case OPT_TEXT:
|
||||
text = 1;
|
||||
else if (strcmp(*argv, "-modulus") == 0)
|
||||
break;
|
||||
case OPT_MODULUS:
|
||||
modulus = 1;
|
||||
else if (strcmp(*argv, "-pubin") == 0)
|
||||
break;
|
||||
case OPT_PUBIN:
|
||||
pubin = 1;
|
||||
else if (strcmp(*argv, "-pubout") == 0)
|
||||
break;
|
||||
case OPT_PUBOUT:
|
||||
pubout = 1;
|
||||
else if ((enc = EVP_get_cipherbyname(&(argv[0][1]))) == NULL) {
|
||||
BIO_printf(bio_err, "unknown option %s\n", *argv);
|
||||
badops = 1;
|
||||
break;
|
||||
case OPT_CIPHER:
|
||||
if (!opt_cipher(opt_unknown(), &enc))
|
||||
goto end;
|
||||
break;
|
||||
}
|
||||
argc--;
|
||||
argv++;
|
||||
}
|
||||
argc = opt_num_rest();
|
||||
if (argc != 0)
|
||||
goto opthelp;
|
||||
|
||||
if (badops) {
|
||||
bad:
|
||||
BIO_printf(bio_err, "%s [options] <infile >outfile\n", prog);
|
||||
BIO_printf(bio_err, "where options are\n");
|
||||
BIO_printf(bio_err, " -inform arg input format - DER or PEM\n");
|
||||
BIO_printf(bio_err, " -outform arg output format - DER or PEM\n");
|
||||
BIO_printf(bio_err, " -in arg input file\n");
|
||||
BIO_printf(bio_err,
|
||||
" -passin arg input file pass phrase source\n");
|
||||
BIO_printf(bio_err, " -out arg output file\n");
|
||||
BIO_printf(bio_err,
|
||||
" -passout arg output file pass phrase source\n");
|
||||
# ifndef OPENSSL_NO_ENGINE
|
||||
BIO_printf(bio_err,
|
||||
" -engine e use engine e, possibly a hardware device.\n");
|
||||
# endif
|
||||
BIO_printf(bio_err,
|
||||
" -des encrypt PEM output with cbc des\n");
|
||||
BIO_printf(bio_err,
|
||||
" -des3 encrypt PEM output with ede cbc des using 168 bit key\n");
|
||||
# ifndef OPENSSL_NO_IDEA
|
||||
BIO_printf(bio_err,
|
||||
" -idea encrypt PEM output with cbc idea\n");
|
||||
# endif
|
||||
# ifndef OPENSSL_NO_AES
|
||||
BIO_printf(bio_err, " -aes128, -aes192, -aes256\n");
|
||||
BIO_printf(bio_err,
|
||||
" encrypt PEM output with cbc aes\n");
|
||||
# endif
|
||||
# ifndef OPENSSL_NO_CAMELLIA
|
||||
BIO_printf(bio_err, " -camellia128, -camellia192, -camellia256\n");
|
||||
BIO_printf(bio_err,
|
||||
" encrypt PEM output with cbc camellia\n");
|
||||
# endif
|
||||
# ifndef OPENSSL_NO_SEED
|
||||
BIO_printf(bio_err,
|
||||
" -seed encrypt PEM output with cbc seed\n");
|
||||
# endif
|
||||
BIO_printf(bio_err, " -text print the key in text\n");
|
||||
BIO_printf(bio_err, " -noout don't print key out\n");
|
||||
BIO_printf(bio_err, " -modulus print the DSA public value\n");
|
||||
goto end;
|
||||
}
|
||||
private = pubin || pubout ? 0 : 1;
|
||||
if (text && !pubin)
|
||||
private = 1;
|
||||
|
||||
ERR_load_crypto_strings();
|
||||
|
||||
e = setup_engine(bio_err, engine, 0);
|
||||
|
||||
if (!app_passwd(bio_err, passargin, passargout, &passin, &passout)) {
|
||||
if (!app_passwd(passinarg, passoutarg, &passin, &passout)) {
|
||||
BIO_printf(bio_err, "Error getting passwords\n");
|
||||
goto end;
|
||||
}
|
||||
|
||||
in = BIO_new(BIO_s_file());
|
||||
out = BIO_new(BIO_s_file());
|
||||
if ((in == NULL) || (out == NULL)) {
|
||||
ERR_print_errors(bio_err);
|
||||
goto end;
|
||||
}
|
||||
|
||||
if (infile == NULL)
|
||||
BIO_set_fp(in, stdin, BIO_NOCLOSE);
|
||||
else {
|
||||
if (BIO_read_filename(in, infile) <= 0) {
|
||||
perror(infile);
|
||||
goto end;
|
||||
}
|
||||
}
|
||||
|
||||
BIO_printf(bio_err, "read DSA key\n");
|
||||
|
||||
{
|
||||
EVP_PKEY *pkey;
|
||||
|
||||
if (pubin)
|
||||
pkey = load_pubkey(bio_err, infile, informat, 1,
|
||||
passin, e, "Public Key");
|
||||
pkey = load_pubkey(infile, informat, 1, passin, e, "Public Key");
|
||||
else
|
||||
pkey = load_key(bio_err, infile, informat, 1,
|
||||
passin, e, "Private Key");
|
||||
pkey = load_key(infile, informat, 1, passin, e, "Private Key");
|
||||
|
||||
if (pkey) {
|
||||
if (pkey != NULL) {
|
||||
dsa = EVP_PKEY_get1_DSA(pkey);
|
||||
EVP_PKEY_free(pkey);
|
||||
}
|
||||
@ -281,49 +173,48 @@ int MAIN(int argc, char **argv)
|
||||
goto end;
|
||||
}
|
||||
|
||||
if (outfile == NULL) {
|
||||
BIO_set_fp(out, stdout, BIO_NOCLOSE);
|
||||
# ifdef OPENSSL_SYS_VMS
|
||||
{
|
||||
BIO *tmpbio = BIO_new(BIO_f_linebuffer());
|
||||
out = BIO_push(tmpbio, out);
|
||||
}
|
||||
# endif
|
||||
} else {
|
||||
if (BIO_write_filename(out, outfile) <= 0) {
|
||||
perror(outfile);
|
||||
goto end;
|
||||
}
|
||||
}
|
||||
out = bio_open_owner(outfile, outformat, private);
|
||||
if (out == NULL)
|
||||
goto end;
|
||||
|
||||
if (text)
|
||||
if (text) {
|
||||
assert(pubin || private);
|
||||
if (!DSA_print(out, dsa, 0)) {
|
||||
perror(outfile);
|
||||
ERR_print_errors(bio_err);
|
||||
goto end;
|
||||
}
|
||||
|
||||
if (modulus) {
|
||||
fprintf(stdout, "Public Key=");
|
||||
BN_print(out, dsa->pub_key);
|
||||
fprintf(stdout, "\n");
|
||||
}
|
||||
|
||||
if (noout)
|
||||
if (modulus) {
|
||||
const BIGNUM *pub_key = NULL;
|
||||
DSA_get0_key(dsa, &pub_key, NULL);
|
||||
BIO_printf(out, "Public Key=");
|
||||
BN_print(out, pub_key);
|
||||
BIO_printf(out, "\n");
|
||||
}
|
||||
|
||||
if (noout) {
|
||||
ret = 0;
|
||||
goto end;
|
||||
}
|
||||
BIO_printf(bio_err, "writing DSA key\n");
|
||||
if (outformat == FORMAT_ASN1) {
|
||||
if (pubin || pubout)
|
||||
if (pubin || pubout) {
|
||||
i = i2d_DSA_PUBKEY_bio(out, dsa);
|
||||
else
|
||||
} else {
|
||||
assert(private);
|
||||
i = i2d_DSAPrivateKey_bio(out, dsa);
|
||||
}
|
||||
} else if (outformat == FORMAT_PEM) {
|
||||
if (pubin || pubout)
|
||||
if (pubin || pubout) {
|
||||
i = PEM_write_bio_DSA_PUBKEY(out, dsa);
|
||||
else
|
||||
} else {
|
||||
assert(private);
|
||||
i = PEM_write_bio_DSAPrivateKey(out, dsa, enc,
|
||||
NULL, 0, NULL, passout);
|
||||
# if !defined(OPENSSL_NO_RSA) && !defined(OPENSSL_NO_RC4)
|
||||
}
|
||||
# ifndef OPENSSL_NO_RSA
|
||||
} else if (outformat == FORMAT_MSBLOB || outformat == FORMAT_PVK) {
|
||||
EVP_PKEY *pk;
|
||||
pk = EVP_PKEY_new();
|
||||
@ -331,12 +222,26 @@ int MAIN(int argc, char **argv)
|
||||
goto end;
|
||||
|
||||
EVP_PKEY_set1_DSA(pk, dsa);
|
||||
if (outformat == FORMAT_PVK)
|
||||
if (outformat == FORMAT_PVK) {
|
||||
if (pubin) {
|
||||
BIO_printf(bio_err, "PVK form impossible with public key input\n");
|
||||
EVP_PKEY_free(pk);
|
||||
goto end;
|
||||
}
|
||||
assert(private);
|
||||
# ifdef OPENSSL_NO_RC4
|
||||
BIO_printf(bio_err, "PVK format not supported\n");
|
||||
EVP_PKEY_free(pk);
|
||||
goto end;
|
||||
# else
|
||||
i = i2b_PVK_bio(out, pk, pvk_encr, 0, passout);
|
||||
else if (pubin || pubout)
|
||||
# endif
|
||||
} else if (pubin || pubout) {
|
||||
i = i2b_PublicKey_bio(out, pk);
|
||||
else
|
||||
} else {
|
||||
assert(private);
|
||||
i = i2b_PrivateKey_bio(out, pk);
|
||||
}
|
||||
EVP_PKEY_free(pk);
|
||||
# endif
|
||||
} else {
|
||||
@ -346,27 +251,15 @@ int MAIN(int argc, char **argv)
|
||||
if (i <= 0) {
|
||||
BIO_printf(bio_err, "unable to write private key\n");
|
||||
ERR_print_errors(bio_err);
|
||||
} else
|
||||
ret = 0;
|
||||
goto end;
|
||||
}
|
||||
ret = 0;
|
||||
end:
|
||||
if (in != NULL)
|
||||
BIO_free(in);
|
||||
if (out != NULL)
|
||||
BIO_free_all(out);
|
||||
if (dsa != NULL)
|
||||
DSA_free(dsa);
|
||||
BIO_free_all(out);
|
||||
DSA_free(dsa);
|
||||
release_engine(e);
|
||||
if (passin)
|
||||
OPENSSL_free(passin);
|
||||
if (passout)
|
||||
OPENSSL_free(passout);
|
||||
apps_shutdown();
|
||||
OPENSSL_EXIT(ret);
|
||||
OPENSSL_free(passin);
|
||||
OPENSSL_free(passout);
|
||||
return ret;
|
||||
}
|
||||
#else /* !OPENSSL_NO_DSA */
|
||||
|
||||
# if PEDANTIC
|
||||
static void *dummy = &dummy;
|
||||
# endif
|
||||
|
||||
#endif
|
||||
|
@ -1,77 +1,23 @@
|
||||
/* apps/dsaparam.c */
|
||||
/* Copyright (C) 1995-1998 Eric Young (eay@cryptsoft.com)
|
||||
* All rights reserved.
|
||||
*
|
||||
* This package is an SSL implementation written
|
||||
* by Eric Young (eay@cryptsoft.com).
|
||||
* The implementation was written so as to conform with Netscapes SSL.
|
||||
*
|
||||
* This library is free for commercial and non-commercial use as long as
|
||||
* the following conditions are aheared to. The following conditions
|
||||
* apply to all code found in this distribution, be it the RC4, RSA,
|
||||
* lhash, DES, etc., code; not just the SSL code. The SSL documentation
|
||||
* included with this distribution is covered by the same copyright terms
|
||||
* except that the holder is Tim Hudson (tjh@cryptsoft.com).
|
||||
*
|
||||
* Copyright remains Eric Young's, and as such any Copyright notices in
|
||||
* the code are not to be removed.
|
||||
* If this package is used in a product, Eric Young should be given attribution
|
||||
* as the author of the parts of the library used.
|
||||
* This can be in the form of a textual message at program startup or
|
||||
* in documentation (online or textual) provided with the package.
|
||||
*
|
||||
* Redistribution and use in source and binary forms, with or without
|
||||
* modification, are permitted provided that the following conditions
|
||||
* are met:
|
||||
* 1. Redistributions of source code must retain the copyright
|
||||
* notice, this list of conditions and the following disclaimer.
|
||||
* 2. Redistributions in binary form must reproduce the above copyright
|
||||
* notice, this list of conditions and the following disclaimer in the
|
||||
* documentation and/or other materials provided with the distribution.
|
||||
* 3. All advertising materials mentioning features or use of this software
|
||||
* must display the following acknowledgement:
|
||||
* "This product includes cryptographic software written by
|
||||
* Eric Young (eay@cryptsoft.com)"
|
||||
* The word 'cryptographic' can be left out if the rouines from the library
|
||||
* being used are not cryptographic related :-).
|
||||
* 4. If you include any Windows specific code (or a derivative thereof) from
|
||||
* the apps directory (application code) you must include an acknowledgement:
|
||||
* "This product includes software written by Tim Hudson (tjh@cryptsoft.com)"
|
||||
*
|
||||
* THIS SOFTWARE IS PROVIDED BY ERIC YOUNG ``AS IS'' AND
|
||||
* ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
|
||||
* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
|
||||
* ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE
|
||||
* FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
|
||||
* DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
|
||||
* OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
|
||||
* HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
|
||||
* LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
|
||||
* OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
|
||||
* SUCH DAMAGE.
|
||||
*
|
||||
* The licence and distribution terms for any publically available version or
|
||||
* derivative of this code cannot be changed. i.e. this code cannot simply be
|
||||
* copied and put under another distribution licence
|
||||
* [including the GNU Public Licence.]
|
||||
*/
|
||||
|
||||
#include <openssl/opensslconf.h> /* for OPENSSL_NO_DSA */
|
||||
/*
|
||||
* Until the key-gen callbacks are modified to use newer prototypes, we allow
|
||||
* deprecated functions for openssl-internal code
|
||||
* Copyright 1995-2018 The OpenSSL Project Authors. All Rights Reserved.
|
||||
*
|
||||
* Licensed under the OpenSSL license (the "License"). You may not use
|
||||
* this file except in compliance with the License. You can obtain a copy
|
||||
* in the file LICENSE in the source distribution or at
|
||||
* https://www.openssl.org/source/license.html
|
||||
*/
|
||||
#ifdef OPENSSL_NO_DEPRECATED
|
||||
# undef OPENSSL_NO_DEPRECATED
|
||||
#endif
|
||||
|
||||
#ifndef OPENSSL_NO_DSA
|
||||
# include <assert.h>
|
||||
#include <openssl/opensslconf.h>
|
||||
#ifdef OPENSSL_NO_DSA
|
||||
NON_EMPTY_TRANSLATION_UNIT
|
||||
#else
|
||||
|
||||
# include <stdio.h>
|
||||
# include <stdlib.h>
|
||||
# include <time.h>
|
||||
# include <string.h>
|
||||
# include "apps.h"
|
||||
# include "progs.h"
|
||||
# include <openssl/bio.h>
|
||||
# include <openssl/err.h>
|
||||
# include <openssl/bn.h>
|
||||
@ -79,245 +25,138 @@
|
||||
# include <openssl/x509.h>
|
||||
# include <openssl/pem.h>
|
||||
|
||||
# undef PROG
|
||||
# define PROG dsaparam_main
|
||||
static int dsa_cb(int p, int n, BN_GENCB *cb);
|
||||
|
||||
/*-
|
||||
* -inform arg - input format - default PEM (DER or PEM)
|
||||
* -outform arg - output format - default PEM
|
||||
* -in arg - input file - default stdin
|
||||
* -out arg - output file - default stdout
|
||||
* -noout
|
||||
* -text
|
||||
* -C
|
||||
* -noout
|
||||
* -genkey
|
||||
* #ifdef GENCB_TEST
|
||||
* -timebomb n - interrupt keygen after <n> seconds
|
||||
* #endif
|
||||
*/
|
||||
typedef enum OPTION_choice {
|
||||
OPT_ERR = -1, OPT_EOF = 0, OPT_HELP,
|
||||
OPT_INFORM, OPT_OUTFORM, OPT_IN, OPT_OUT, OPT_TEXT, OPT_C,
|
||||
OPT_NOOUT, OPT_GENKEY, OPT_ENGINE, OPT_R_ENUM
|
||||
} OPTION_CHOICE;
|
||||
|
||||
# ifdef GENCB_TEST
|
||||
|
||||
static int stop_keygen_flag = 0;
|
||||
|
||||
static void timebomb_sigalarm(int foo)
|
||||
{
|
||||
stop_keygen_flag = 1;
|
||||
}
|
||||
|
||||
# endif
|
||||
|
||||
static int MS_CALLBACK dsa_cb(int p, int n, BN_GENCB *cb);
|
||||
|
||||
int MAIN(int, char **);
|
||||
|
||||
int MAIN(int argc, char **argv)
|
||||
{
|
||||
DSA *dsa = NULL;
|
||||
int i, badops = 0, text = 0;
|
||||
BIO *in = NULL, *out = NULL;
|
||||
int informat, outformat, noout = 0, C = 0, ret = 1;
|
||||
char *infile, *outfile, *prog, *inrand = NULL;
|
||||
int numbits = -1, num, genkey = 0;
|
||||
int need_rand = 0;
|
||||
char *engine = NULL;
|
||||
ENGINE *e = NULL;
|
||||
# ifdef GENCB_TEST
|
||||
int timebomb = 0;
|
||||
# endif
|
||||
|
||||
apps_startup();
|
||||
|
||||
if (bio_err == NULL)
|
||||
if ((bio_err = BIO_new(BIO_s_file())) != NULL)
|
||||
BIO_set_fp(bio_err, stderr, BIO_NOCLOSE | BIO_FP_TEXT);
|
||||
|
||||
if (!load_config(bio_err, NULL))
|
||||
goto end;
|
||||
|
||||
infile = NULL;
|
||||
outfile = NULL;
|
||||
informat = FORMAT_PEM;
|
||||
outformat = FORMAT_PEM;
|
||||
|
||||
prog = argv[0];
|
||||
argc--;
|
||||
argv++;
|
||||
while (argc >= 1) {
|
||||
if (strcmp(*argv, "-inform") == 0) {
|
||||
if (--argc < 1)
|
||||
goto bad;
|
||||
informat = str2fmt(*(++argv));
|
||||
} else if (strcmp(*argv, "-outform") == 0) {
|
||||
if (--argc < 1)
|
||||
goto bad;
|
||||
outformat = str2fmt(*(++argv));
|
||||
} else if (strcmp(*argv, "-in") == 0) {
|
||||
if (--argc < 1)
|
||||
goto bad;
|
||||
infile = *(++argv);
|
||||
} else if (strcmp(*argv, "-out") == 0) {
|
||||
if (--argc < 1)
|
||||
goto bad;
|
||||
outfile = *(++argv);
|
||||
}
|
||||
const OPTIONS dsaparam_options[] = {
|
||||
{"help", OPT_HELP, '-', "Display this summary"},
|
||||
{"inform", OPT_INFORM, 'F', "Input format - DER or PEM"},
|
||||
{"in", OPT_IN, '<', "Input file"},
|
||||
{"outform", OPT_OUTFORM, 'F', "Output format - DER or PEM"},
|
||||
{"out", OPT_OUT, '>', "Output file"},
|
||||
{"text", OPT_TEXT, '-', "Print as text"},
|
||||
{"C", OPT_C, '-', "Output C code"},
|
||||
{"noout", OPT_NOOUT, '-', "No output"},
|
||||
{"genkey", OPT_GENKEY, '-', "Generate a DSA key"},
|
||||
OPT_R_OPTIONS,
|
||||
# ifndef OPENSSL_NO_ENGINE
|
||||
else if (strcmp(*argv, "-engine") == 0) {
|
||||
if (--argc < 1)
|
||||
goto bad;
|
||||
engine = *(++argv);
|
||||
}
|
||||
{"engine", OPT_ENGINE, 's', "Use engine e, possibly a hardware device"},
|
||||
# endif
|
||||
# ifdef GENCB_TEST
|
||||
else if (strcmp(*argv, "-timebomb") == 0) {
|
||||
if (--argc < 1)
|
||||
goto bad;
|
||||
timebomb = atoi(*(++argv));
|
||||
}
|
||||
# endif
|
||||
else if (strcmp(*argv, "-text") == 0)
|
||||
{NULL}
|
||||
};
|
||||
|
||||
int dsaparam_main(int argc, char **argv)
|
||||
{
|
||||
ENGINE *e = NULL;
|
||||
DSA *dsa = NULL;
|
||||
BIO *in = NULL, *out = NULL;
|
||||
BN_GENCB *cb = NULL;
|
||||
int numbits = -1, num = 0, genkey = 0;
|
||||
int informat = FORMAT_PEM, outformat = FORMAT_PEM, noout = 0, C = 0;
|
||||
int ret = 1, i, text = 0, private = 0;
|
||||
char *infile = NULL, *outfile = NULL, *prog;
|
||||
OPTION_CHOICE o;
|
||||
|
||||
prog = opt_init(argc, argv, dsaparam_options);
|
||||
while ((o = opt_next()) != OPT_EOF) {
|
||||
switch (o) {
|
||||
case OPT_EOF:
|
||||
case OPT_ERR:
|
||||
opthelp:
|
||||
BIO_printf(bio_err, "%s: Use -help for summary.\n", prog);
|
||||
goto end;
|
||||
case OPT_HELP:
|
||||
opt_help(dsaparam_options);
|
||||
ret = 0;
|
||||
goto end;
|
||||
case OPT_INFORM:
|
||||
if (!opt_format(opt_arg(), OPT_FMT_PEMDER, &informat))
|
||||
goto opthelp;
|
||||
break;
|
||||
case OPT_IN:
|
||||
infile = opt_arg();
|
||||
break;
|
||||
case OPT_OUTFORM:
|
||||
if (!opt_format(opt_arg(), OPT_FMT_PEMDER, &outformat))
|
||||
goto opthelp;
|
||||
break;
|
||||
case OPT_OUT:
|
||||
outfile = opt_arg();
|
||||
break;
|
||||
case OPT_ENGINE:
|
||||
e = setup_engine(opt_arg(), 0);
|
||||
break;
|
||||
case OPT_TEXT:
|
||||
text = 1;
|
||||
else if (strcmp(*argv, "-C") == 0)
|
||||
break;
|
||||
case OPT_C:
|
||||
C = 1;
|
||||
else if (strcmp(*argv, "-genkey") == 0) {
|
||||
break;
|
||||
case OPT_GENKEY:
|
||||
genkey = 1;
|
||||
need_rand = 1;
|
||||
} else if (strcmp(*argv, "-rand") == 0) {
|
||||
if (--argc < 1)
|
||||
goto bad;
|
||||
inrand = *(++argv);
|
||||
need_rand = 1;
|
||||
} else if (strcmp(*argv, "-noout") == 0)
|
||||
break;
|
||||
case OPT_R_CASES:
|
||||
if (!opt_rand(o))
|
||||
goto end;
|
||||
break;
|
||||
case OPT_NOOUT:
|
||||
noout = 1;
|
||||
else if (sscanf(*argv, "%d", &num) == 1) {
|
||||
/* generate a key */
|
||||
numbits = num;
|
||||
need_rand = 1;
|
||||
} else {
|
||||
BIO_printf(bio_err, "unknown option %s\n", *argv);
|
||||
badops = 1;
|
||||
break;
|
||||
}
|
||||
argc--;
|
||||
argv++;
|
||||
}
|
||||
argc = opt_num_rest();
|
||||
argv = opt_rest();
|
||||
|
||||
if (badops) {
|
||||
bad:
|
||||
BIO_printf(bio_err, "%s [options] [bits] <infile >outfile\n", prog);
|
||||
BIO_printf(bio_err, "where options are\n");
|
||||
BIO_printf(bio_err, " -inform arg input format - DER or PEM\n");
|
||||
BIO_printf(bio_err, " -outform arg output format - DER or PEM\n");
|
||||
BIO_printf(bio_err, " -in arg input file\n");
|
||||
BIO_printf(bio_err, " -out arg output file\n");
|
||||
BIO_printf(bio_err, " -text print as text\n");
|
||||
BIO_printf(bio_err, " -C Output C code\n");
|
||||
BIO_printf(bio_err, " -noout no output\n");
|
||||
BIO_printf(bio_err, " -genkey generate a DSA key\n");
|
||||
BIO_printf(bio_err,
|
||||
" -rand files to use for random number input\n");
|
||||
# ifndef OPENSSL_NO_ENGINE
|
||||
BIO_printf(bio_err,
|
||||
" -engine e use engine e, possibly a hardware device.\n");
|
||||
# endif
|
||||
# ifdef GENCB_TEST
|
||||
BIO_printf(bio_err,
|
||||
" -timebomb n interrupt keygen after <n> seconds\n");
|
||||
# endif
|
||||
BIO_printf(bio_err,
|
||||
" number number of bits to use for generating private key\n");
|
||||
goto end;
|
||||
}
|
||||
|
||||
ERR_load_crypto_strings();
|
||||
|
||||
in = BIO_new(BIO_s_file());
|
||||
out = BIO_new(BIO_s_file());
|
||||
if ((in == NULL) || (out == NULL)) {
|
||||
ERR_print_errors(bio_err);
|
||||
goto end;
|
||||
}
|
||||
|
||||
if (infile == NULL)
|
||||
BIO_set_fp(in, stdin, BIO_NOCLOSE);
|
||||
else {
|
||||
if (BIO_read_filename(in, infile) <= 0) {
|
||||
perror(infile);
|
||||
if (argc == 1) {
|
||||
if (!opt_int(argv[0], &num) || num < 0)
|
||||
goto end;
|
||||
}
|
||||
}
|
||||
if (outfile == NULL) {
|
||||
BIO_set_fp(out, stdout, BIO_NOCLOSE);
|
||||
# ifdef OPENSSL_SYS_VMS
|
||||
{
|
||||
BIO *tmpbio = BIO_new(BIO_f_linebuffer());
|
||||
out = BIO_push(tmpbio, out);
|
||||
}
|
||||
# endif
|
||||
} else {
|
||||
if (BIO_write_filename(out, outfile) <= 0) {
|
||||
perror(outfile);
|
||||
goto end;
|
||||
}
|
||||
/* generate a key */
|
||||
numbits = num;
|
||||
}
|
||||
private = genkey ? 1 : 0;
|
||||
|
||||
e = setup_engine(bio_err, engine, 0);
|
||||
|
||||
if (need_rand) {
|
||||
app_RAND_load_file(NULL, bio_err, (inrand != NULL));
|
||||
if (inrand != NULL)
|
||||
BIO_printf(bio_err, "%ld semi-random bytes loaded\n",
|
||||
app_RAND_load_files(inrand));
|
||||
}
|
||||
in = bio_open_default(infile, 'r', informat);
|
||||
if (in == NULL)
|
||||
goto end;
|
||||
out = bio_open_owner(outfile, outformat, private);
|
||||
if (out == NULL)
|
||||
goto end;
|
||||
|
||||
if (numbits > 0) {
|
||||
BN_GENCB cb;
|
||||
BN_GENCB_set(&cb, dsa_cb, bio_err);
|
||||
assert(need_rand);
|
||||
if (numbits > OPENSSL_DSA_MAX_MODULUS_BITS)
|
||||
BIO_printf(bio_err,
|
||||
"Warning: It is not recommended to use more than %d bit for DSA keys.\n"
|
||||
" Your key size is %d! Larger key size may behave not as expected.\n",
|
||||
OPENSSL_DSA_MAX_MODULUS_BITS, numbits);
|
||||
|
||||
cb = BN_GENCB_new();
|
||||
if (cb == NULL) {
|
||||
BIO_printf(bio_err, "Error allocating BN_GENCB object\n");
|
||||
goto end;
|
||||
}
|
||||
BN_GENCB_set(cb, dsa_cb, bio_err);
|
||||
dsa = DSA_new();
|
||||
if (!dsa) {
|
||||
if (dsa == NULL) {
|
||||
BIO_printf(bio_err, "Error allocating DSA object\n");
|
||||
goto end;
|
||||
}
|
||||
BIO_printf(bio_err, "Generating DSA parameters, %d bit long prime\n",
|
||||
num);
|
||||
BIO_printf(bio_err, "This could take some time\n");
|
||||
# ifdef GENCB_TEST
|
||||
if (timebomb > 0) {
|
||||
struct sigaction act;
|
||||
act.sa_handler = timebomb_sigalarm;
|
||||
act.sa_flags = 0;
|
||||
BIO_printf(bio_err,
|
||||
"(though I'll stop it if not done within %d secs)\n",
|
||||
timebomb);
|
||||
if (sigaction(SIGALRM, &act, NULL) != 0) {
|
||||
BIO_printf(bio_err, "Error, couldn't set SIGALRM handler\n");
|
||||
goto end;
|
||||
}
|
||||
alarm(timebomb);
|
||||
}
|
||||
# endif
|
||||
if (!DSA_generate_parameters_ex(dsa, num, NULL, 0, NULL, NULL, &cb)) {
|
||||
# ifdef GENCB_TEST
|
||||
if (stop_keygen_flag) {
|
||||
BIO_printf(bio_err, "DSA key generation time-stopped\n");
|
||||
/* This is an asked-for behaviour! */
|
||||
ret = 0;
|
||||
goto end;
|
||||
}
|
||||
# endif
|
||||
if (!DSA_generate_parameters_ex(dsa, num, NULL, 0, NULL, NULL, cb)) {
|
||||
ERR_print_errors(bio_err);
|
||||
BIO_printf(bio_err, "Error, DSA key generation failed\n");
|
||||
goto end;
|
||||
}
|
||||
} else if (informat == FORMAT_ASN1)
|
||||
} else if (informat == FORMAT_ASN1) {
|
||||
dsa = d2i_DSAparams_bio(in, NULL);
|
||||
else if (informat == FORMAT_PEM)
|
||||
} else {
|
||||
dsa = PEM_read_bio_DSAparams(in, NULL, NULL, NULL);
|
||||
else {
|
||||
BIO_printf(bio_err, "bad input format specified\n");
|
||||
goto end;
|
||||
}
|
||||
if (dsa == NULL) {
|
||||
BIO_printf(bio_err, "unable to load DSA parameters\n");
|
||||
@ -330,56 +169,39 @@ int MAIN(int argc, char **argv)
|
||||
}
|
||||
|
||||
if (C) {
|
||||
const BIGNUM *p = NULL, *q = NULL, *g = NULL;
|
||||
unsigned char *data;
|
||||
int l, len, bits_p;
|
||||
int len, bits_p;
|
||||
|
||||
len = BN_num_bytes(dsa->p);
|
||||
bits_p = BN_num_bits(dsa->p);
|
||||
data = (unsigned char *)OPENSSL_malloc(len + 20);
|
||||
if (data == NULL) {
|
||||
perror("OPENSSL_malloc");
|
||||
goto end;
|
||||
}
|
||||
l = BN_bn2bin(dsa->p, data);
|
||||
printf("static unsigned char dsa%d_p[]={", bits_p);
|
||||
for (i = 0; i < l; i++) {
|
||||
if ((i % 12) == 0)
|
||||
printf("\n\t");
|
||||
printf("0x%02X,", data[i]);
|
||||
}
|
||||
printf("\n\t};\n");
|
||||
DSA_get0_pqg(dsa, &p, &q, &g);
|
||||
len = BN_num_bytes(p);
|
||||
bits_p = BN_num_bits(p);
|
||||
|
||||
l = BN_bn2bin(dsa->q, data);
|
||||
printf("static unsigned char dsa%d_q[]={", bits_p);
|
||||
for (i = 0; i < l; i++) {
|
||||
if ((i % 12) == 0)
|
||||
printf("\n\t");
|
||||
printf("0x%02X,", data[i]);
|
||||
}
|
||||
printf("\n\t};\n");
|
||||
data = app_malloc(len + 20, "BN space");
|
||||
|
||||
l = BN_bn2bin(dsa->g, data);
|
||||
printf("static unsigned char dsa%d_g[]={", bits_p);
|
||||
for (i = 0; i < l; i++) {
|
||||
if ((i % 12) == 0)
|
||||
printf("\n\t");
|
||||
printf("0x%02X,", data[i]);
|
||||
}
|
||||
printf("\n\t};\n\n");
|
||||
|
||||
printf("DSA *get_dsa%d()\n\t{\n", bits_p);
|
||||
printf("\tDSA *dsa;\n\n");
|
||||
printf("\tif ((dsa=DSA_new()) == NULL) return(NULL);\n");
|
||||
printf("\tdsa->p=BN_bin2bn(dsa%d_p,sizeof(dsa%d_p),NULL);\n",
|
||||
bits_p, bits_p);
|
||||
printf("\tdsa->q=BN_bin2bn(dsa%d_q,sizeof(dsa%d_q),NULL);\n",
|
||||
bits_p, bits_p);
|
||||
printf("\tdsa->g=BN_bin2bn(dsa%d_g,sizeof(dsa%d_g),NULL);\n",
|
||||
bits_p, bits_p);
|
||||
printf
|
||||
("\tif ((dsa->p == NULL) || (dsa->q == NULL) || (dsa->g == NULL))\n");
|
||||
printf("\t\t{ DSA_free(dsa); return(NULL); }\n");
|
||||
printf("\treturn(dsa);\n\t}\n");
|
||||
BIO_printf(bio_out, "static DSA *get_dsa%d(void)\n{\n", bits_p);
|
||||
print_bignum_var(bio_out, p, "dsap", bits_p, data);
|
||||
print_bignum_var(bio_out, q, "dsaq", bits_p, data);
|
||||
print_bignum_var(bio_out, g, "dsag", bits_p, data);
|
||||
BIO_printf(bio_out, " DSA *dsa = DSA_new();\n"
|
||||
" BIGNUM *p, *q, *g;\n"
|
||||
"\n");
|
||||
BIO_printf(bio_out, " if (dsa == NULL)\n"
|
||||
" return NULL;\n");
|
||||
BIO_printf(bio_out, " if (!DSA_set0_pqg(dsa, p = BN_bin2bn(dsap_%d, sizeof(dsap_%d), NULL),\n",
|
||||
bits_p, bits_p);
|
||||
BIO_printf(bio_out, " q = BN_bin2bn(dsaq_%d, sizeof(dsaq_%d), NULL),\n",
|
||||
bits_p, bits_p);
|
||||
BIO_printf(bio_out, " g = BN_bin2bn(dsag_%d, sizeof(dsag_%d), NULL))) {\n",
|
||||
bits_p, bits_p);
|
||||
BIO_printf(bio_out, " DSA_free(dsa);\n"
|
||||
" BN_free(p);\n"
|
||||
" BN_free(q);\n"
|
||||
" BN_free(g);\n"
|
||||
" return NULL;\n"
|
||||
" }\n"
|
||||
" return dsa;\n}\n");
|
||||
OPENSSL_free(data);
|
||||
}
|
||||
|
||||
if (outformat == FORMAT_ASN1 && genkey)
|
||||
@ -388,12 +210,8 @@ int MAIN(int argc, char **argv)
|
||||
if (!noout) {
|
||||
if (outformat == FORMAT_ASN1)
|
||||
i = i2d_DSAparams_bio(out, dsa);
|
||||
else if (outformat == FORMAT_PEM)
|
||||
else
|
||||
i = PEM_write_bio_DSAparams(out, dsa);
|
||||
else {
|
||||
BIO_printf(bio_err, "bad output format specified for outfile\n");
|
||||
goto end;
|
||||
}
|
||||
if (!i) {
|
||||
BIO_printf(bio_err, "unable to write DSA parameters\n");
|
||||
ERR_print_errors(bio_err);
|
||||
@ -403,7 +221,6 @@ int MAIN(int argc, char **argv)
|
||||
if (genkey) {
|
||||
DSA *dsakey;
|
||||
|
||||
assert(need_rand);
|
||||
if ((dsakey = DSAparams_dup(dsa)) == NULL)
|
||||
goto end;
|
||||
if (!DSA_generate_key(dsakey)) {
|
||||
@ -411,60 +228,31 @@ int MAIN(int argc, char **argv)
|
||||
DSA_free(dsakey);
|
||||
goto end;
|
||||
}
|
||||
assert(private);
|
||||
if (outformat == FORMAT_ASN1)
|
||||
i = i2d_DSAPrivateKey_bio(out, dsakey);
|
||||
else if (outformat == FORMAT_PEM)
|
||||
else
|
||||
i = PEM_write_bio_DSAPrivateKey(out, dsakey, NULL, NULL, 0, NULL,
|
||||
NULL);
|
||||
else {
|
||||
BIO_printf(bio_err, "bad output format specified for outfile\n");
|
||||
DSA_free(dsakey);
|
||||
goto end;
|
||||
}
|
||||
DSA_free(dsakey);
|
||||
}
|
||||
if (need_rand)
|
||||
app_RAND_write_file(NULL, bio_err);
|
||||
ret = 0;
|
||||
end:
|
||||
if (in != NULL)
|
||||
BIO_free(in);
|
||||
if (out != NULL)
|
||||
BIO_free_all(out);
|
||||
if (dsa != NULL)
|
||||
DSA_free(dsa);
|
||||
BN_GENCB_free(cb);
|
||||
BIO_free(in);
|
||||
BIO_free_all(out);
|
||||
DSA_free(dsa);
|
||||
release_engine(e);
|
||||
apps_shutdown();
|
||||
OPENSSL_EXIT(ret);
|
||||
return ret;
|
||||
}
|
||||
|
||||
static int MS_CALLBACK dsa_cb(int p, int n, BN_GENCB *cb)
|
||||
static int dsa_cb(int p, int n, BN_GENCB *cb)
|
||||
{
|
||||
char c = '*';
|
||||
static const char symbols[] = ".+*\n";
|
||||
char c = (p >= 0 && (size_t)p < sizeof(symbols) - 1) ? symbols[p] : '?';
|
||||
|
||||
if (p == 0)
|
||||
c = '.';
|
||||
if (p == 1)
|
||||
c = '+';
|
||||
if (p == 2)
|
||||
c = '*';
|
||||
if (p == 3)
|
||||
c = '\n';
|
||||
BIO_write(cb->arg, &c, 1);
|
||||
(void)BIO_flush(cb->arg);
|
||||
# ifdef LINT
|
||||
p = n;
|
||||
# endif
|
||||
# ifdef GENCB_TEST
|
||||
if (stop_keygen_flag)
|
||||
return 0;
|
||||
# endif
|
||||
BIO_write(BN_GENCB_get_arg(cb), &c, 1);
|
||||
(void)BIO_flush(BN_GENCB_get_arg(cb));
|
||||
return 1;
|
||||
}
|
||||
#else /* !OPENSSL_NO_DSA */
|
||||
|
||||
# if PEDANTIC
|
||||
static void *dummy = &dummy;
|
||||
# endif
|
||||
|
||||
#endif
|
||||
|
@ -1,262 +1,180 @@
|
||||
/* apps/ec.c */
|
||||
/*
|
||||
* Written by Nils Larsch for the OpenSSL project.
|
||||
*/
|
||||
/* ====================================================================
|
||||
* Copyright (c) 1998-2005 The OpenSSL Project. All rights reserved.
|
||||
*
|
||||
* Redistribution and use in source and binary forms, with or without
|
||||
* modification, are permitted provided that the following conditions
|
||||
* are met:
|
||||
*
|
||||
* 1. Redistributions of source code must retain the above copyright
|
||||
* notice, this list of conditions and the following disclaimer.
|
||||
*
|
||||
* 2. Redistributions in binary form must reproduce the above copyright
|
||||
* notice, this list of conditions and the following disclaimer in
|
||||
* the documentation and/or other materials provided with the
|
||||
* distribution.
|
||||
*
|
||||
* 3. All advertising materials mentioning features or use of this
|
||||
* software must display the following acknowledgment:
|
||||
* "This product includes software developed by the OpenSSL Project
|
||||
* for use in the OpenSSL Toolkit. (http://www.openssl.org/)"
|
||||
*
|
||||
* 4. The names "OpenSSL Toolkit" and "OpenSSL Project" must not be used to
|
||||
* endorse or promote products derived from this software without
|
||||
* prior written permission. For written permission, please contact
|
||||
* openssl-core@openssl.org.
|
||||
*
|
||||
* 5. Products derived from this software may not be called "OpenSSL"
|
||||
* nor may "OpenSSL" appear in their names without prior written
|
||||
* permission of the OpenSSL Project.
|
||||
*
|
||||
* 6. Redistributions of any form whatsoever must retain the following
|
||||
* acknowledgment:
|
||||
* "This product includes software developed by the OpenSSL Project
|
||||
* for use in the OpenSSL Toolkit (http://www.openssl.org/)"
|
||||
*
|
||||
* THIS SOFTWARE IS PROVIDED BY THE OpenSSL PROJECT ``AS IS'' AND ANY
|
||||
* EXPRESSED OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
|
||||
* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
|
||||
* PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE OpenSSL PROJECT OR
|
||||
* ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
|
||||
* SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
|
||||
* NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
|
||||
* LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
|
||||
* HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT,
|
||||
* STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
|
||||
* ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED
|
||||
* OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
* ====================================================================
|
||||
*
|
||||
* This product includes cryptographic software written by Eric Young
|
||||
* (eay@cryptsoft.com). This product includes software written by Tim
|
||||
* Hudson (tjh@cryptsoft.com).
|
||||
* Copyright 2002-2018 The OpenSSL Project Authors. All Rights Reserved.
|
||||
*
|
||||
* Licensed under the OpenSSL license (the "License"). You may not use
|
||||
* this file except in compliance with the License. You can obtain a copy
|
||||
* in the file LICENSE in the source distribution or at
|
||||
* https://www.openssl.org/source/license.html
|
||||
*/
|
||||
|
||||
#include <openssl/opensslconf.h>
|
||||
#ifndef OPENSSL_NO_EC
|
||||
#ifdef OPENSSL_NO_EC
|
||||
NON_EMPTY_TRANSLATION_UNIT
|
||||
#else
|
||||
|
||||
# include <stdio.h>
|
||||
# include <stdlib.h>
|
||||
# include <string.h>
|
||||
# include "apps.h"
|
||||
# include "progs.h"
|
||||
# include <openssl/bio.h>
|
||||
# include <openssl/err.h>
|
||||
# include <openssl/evp.h>
|
||||
# include <openssl/pem.h>
|
||||
|
||||
# undef PROG
|
||||
# define PROG ec_main
|
||||
static OPT_PAIR conv_forms[] = {
|
||||
{"compressed", POINT_CONVERSION_COMPRESSED},
|
||||
{"uncompressed", POINT_CONVERSION_UNCOMPRESSED},
|
||||
{"hybrid", POINT_CONVERSION_HYBRID},
|
||||
{NULL}
|
||||
};
|
||||
|
||||
/*-
|
||||
* -inform arg - input format - default PEM (one of DER, NET or PEM)
|
||||
* -outform arg - output format - default PEM
|
||||
* -in arg - input file - default stdin
|
||||
* -out arg - output file - default stdout
|
||||
* -des - encrypt output if PEM format with DES in cbc mode
|
||||
* -text - print a text version
|
||||
* -param_out - print the elliptic curve parameters
|
||||
* -conv_form arg - specifies the point encoding form
|
||||
* -param_enc arg - specifies the parameter encoding
|
||||
*/
|
||||
static OPT_PAIR param_enc[] = {
|
||||
{"named_curve", OPENSSL_EC_NAMED_CURVE},
|
||||
{"explicit", 0},
|
||||
{NULL}
|
||||
};
|
||||
|
||||
int MAIN(int, char **);
|
||||
typedef enum OPTION_choice {
|
||||
OPT_ERR = -1, OPT_EOF = 0, OPT_HELP,
|
||||
OPT_INFORM, OPT_OUTFORM, OPT_ENGINE, OPT_IN, OPT_OUT,
|
||||
OPT_NOOUT, OPT_TEXT, OPT_PARAM_OUT, OPT_PUBIN, OPT_PUBOUT,
|
||||
OPT_PASSIN, OPT_PASSOUT, OPT_PARAM_ENC, OPT_CONV_FORM, OPT_CIPHER,
|
||||
OPT_NO_PUBLIC, OPT_CHECK
|
||||
} OPTION_CHOICE;
|
||||
|
||||
int MAIN(int argc, char **argv)
|
||||
const OPTIONS ec_options[] = {
|
||||
{"help", OPT_HELP, '-', "Display this summary"},
|
||||
{"in", OPT_IN, 's', "Input file"},
|
||||
{"inform", OPT_INFORM, 'f', "Input format - DER or PEM"},
|
||||
{"out", OPT_OUT, '>', "Output file"},
|
||||
{"outform", OPT_OUTFORM, 'F', "Output format - DER or PEM"},
|
||||
{"noout", OPT_NOOUT, '-', "Don't print key out"},
|
||||
{"text", OPT_TEXT, '-', "Print the key"},
|
||||
{"param_out", OPT_PARAM_OUT, '-', "Print the elliptic curve parameters"},
|
||||
{"pubin", OPT_PUBIN, '-', "Expect a public key in input file"},
|
||||
{"pubout", OPT_PUBOUT, '-', "Output public key, not private"},
|
||||
{"no_public", OPT_NO_PUBLIC, '-', "exclude public key from private key"},
|
||||
{"check", OPT_CHECK, '-', "check key consistency"},
|
||||
{"passin", OPT_PASSIN, 's', "Input file pass phrase source"},
|
||||
{"passout", OPT_PASSOUT, 's', "Output file pass phrase source"},
|
||||
{"param_enc", OPT_PARAM_ENC, 's',
|
||||
"Specifies the way the ec parameters are encoded"},
|
||||
{"conv_form", OPT_CONV_FORM, 's', "Specifies the point conversion form "},
|
||||
{"", OPT_CIPHER, '-', "Any supported cipher"},
|
||||
# ifndef OPENSSL_NO_ENGINE
|
||||
{"engine", OPT_ENGINE, 's', "Use engine, possibly a hardware device"},
|
||||
# endif
|
||||
{NULL}
|
||||
};
|
||||
|
||||
int ec_main(int argc, char **argv)
|
||||
{
|
||||
int ret = 1;
|
||||
BIO *in = NULL, *out = NULL;
|
||||
ENGINE *e = NULL;
|
||||
EC_KEY *eckey = NULL;
|
||||
const EC_GROUP *group;
|
||||
int i, badops = 0;
|
||||
const EVP_CIPHER *enc = NULL;
|
||||
BIO *in = NULL, *out = NULL;
|
||||
int informat, outformat, text = 0, noout = 0;
|
||||
int pubin = 0, pubout = 0, param_out = 0;
|
||||
char *infile, *outfile, *prog, *engine;
|
||||
ENGINE *e = NULL;
|
||||
char *passargin = NULL, *passargout = NULL;
|
||||
char *passin = NULL, *passout = NULL;
|
||||
point_conversion_form_t form = POINT_CONVERSION_UNCOMPRESSED;
|
||||
int new_form = 0;
|
||||
int asn1_flag = OPENSSL_EC_NAMED_CURVE;
|
||||
int new_asn1_flag = 0;
|
||||
char *infile = NULL, *outfile = NULL, *prog;
|
||||
char *passin = NULL, *passout = NULL, *passinarg = NULL, *passoutarg = NULL;
|
||||
OPTION_CHOICE o;
|
||||
int asn1_flag = OPENSSL_EC_NAMED_CURVE, new_form = 0, new_asn1_flag = 0;
|
||||
int informat = FORMAT_PEM, outformat = FORMAT_PEM, text = 0, noout = 0;
|
||||
int pubin = 0, pubout = 0, param_out = 0, i, ret = 1, private = 0;
|
||||
int no_public = 0, check = 0;
|
||||
|
||||
apps_startup();
|
||||
|
||||
if (bio_err == NULL)
|
||||
if ((bio_err = BIO_new(BIO_s_file())) != NULL)
|
||||
BIO_set_fp(bio_err, stderr, BIO_NOCLOSE | BIO_FP_TEXT);
|
||||
|
||||
if (!load_config(bio_err, NULL))
|
||||
goto end;
|
||||
|
||||
engine = NULL;
|
||||
infile = NULL;
|
||||
outfile = NULL;
|
||||
informat = FORMAT_PEM;
|
||||
outformat = FORMAT_PEM;
|
||||
|
||||
prog = argv[0];
|
||||
argc--;
|
||||
argv++;
|
||||
while (argc >= 1) {
|
||||
if (strcmp(*argv, "-inform") == 0) {
|
||||
if (--argc < 1)
|
||||
goto bad;
|
||||
informat = str2fmt(*(++argv));
|
||||
} else if (strcmp(*argv, "-outform") == 0) {
|
||||
if (--argc < 1)
|
||||
goto bad;
|
||||
outformat = str2fmt(*(++argv));
|
||||
} else if (strcmp(*argv, "-in") == 0) {
|
||||
if (--argc < 1)
|
||||
goto bad;
|
||||
infile = *(++argv);
|
||||
} else if (strcmp(*argv, "-out") == 0) {
|
||||
if (--argc < 1)
|
||||
goto bad;
|
||||
outfile = *(++argv);
|
||||
} else if (strcmp(*argv, "-passin") == 0) {
|
||||
if (--argc < 1)
|
||||
goto bad;
|
||||
passargin = *(++argv);
|
||||
} else if (strcmp(*argv, "-passout") == 0) {
|
||||
if (--argc < 1)
|
||||
goto bad;
|
||||
passargout = *(++argv);
|
||||
} else if (strcmp(*argv, "-engine") == 0) {
|
||||
if (--argc < 1)
|
||||
goto bad;
|
||||
engine = *(++argv);
|
||||
} else if (strcmp(*argv, "-noout") == 0)
|
||||
prog = opt_init(argc, argv, ec_options);
|
||||
while ((o = opt_next()) != OPT_EOF) {
|
||||
switch (o) {
|
||||
case OPT_EOF:
|
||||
case OPT_ERR:
|
||||
opthelp:
|
||||
BIO_printf(bio_err, "%s: Use -help for summary.\n", prog);
|
||||
goto end;
|
||||
case OPT_HELP:
|
||||
opt_help(ec_options);
|
||||
ret = 0;
|
||||
goto end;
|
||||
case OPT_INFORM:
|
||||
if (!opt_format(opt_arg(), OPT_FMT_ANY, &informat))
|
||||
goto opthelp;
|
||||
break;
|
||||
case OPT_IN:
|
||||
infile = opt_arg();
|
||||
break;
|
||||
case OPT_OUTFORM:
|
||||
if (!opt_format(opt_arg(), OPT_FMT_PEMDER, &outformat))
|
||||
goto opthelp;
|
||||
break;
|
||||
case OPT_OUT:
|
||||
outfile = opt_arg();
|
||||
break;
|
||||
case OPT_NOOUT:
|
||||
noout = 1;
|
||||
else if (strcmp(*argv, "-text") == 0)
|
||||
break;
|
||||
case OPT_TEXT:
|
||||
text = 1;
|
||||
else if (strcmp(*argv, "-conv_form") == 0) {
|
||||
if (--argc < 1)
|
||||
goto bad;
|
||||
++argv;
|
||||
new_form = 1;
|
||||
if (strcmp(*argv, "compressed") == 0)
|
||||
form = POINT_CONVERSION_COMPRESSED;
|
||||
else if (strcmp(*argv, "uncompressed") == 0)
|
||||
form = POINT_CONVERSION_UNCOMPRESSED;
|
||||
else if (strcmp(*argv, "hybrid") == 0)
|
||||
form = POINT_CONVERSION_HYBRID;
|
||||
else
|
||||
goto bad;
|
||||
} else if (strcmp(*argv, "-param_enc") == 0) {
|
||||
if (--argc < 1)
|
||||
goto bad;
|
||||
++argv;
|
||||
new_asn1_flag = 1;
|
||||
if (strcmp(*argv, "named_curve") == 0)
|
||||
asn1_flag = OPENSSL_EC_NAMED_CURVE;
|
||||
else if (strcmp(*argv, "explicit") == 0)
|
||||
asn1_flag = 0;
|
||||
else
|
||||
goto bad;
|
||||
} else if (strcmp(*argv, "-param_out") == 0)
|
||||
break;
|
||||
case OPT_PARAM_OUT:
|
||||
param_out = 1;
|
||||
else if (strcmp(*argv, "-pubin") == 0)
|
||||
break;
|
||||
case OPT_PUBIN:
|
||||
pubin = 1;
|
||||
else if (strcmp(*argv, "-pubout") == 0)
|
||||
break;
|
||||
case OPT_PUBOUT:
|
||||
pubout = 1;
|
||||
else if ((enc = EVP_get_cipherbyname(&(argv[0][1]))) == NULL) {
|
||||
BIO_printf(bio_err, "unknown option %s\n", *argv);
|
||||
badops = 1;
|
||||
break;
|
||||
case OPT_PASSIN:
|
||||
passinarg = opt_arg();
|
||||
break;
|
||||
case OPT_PASSOUT:
|
||||
passoutarg = opt_arg();
|
||||
break;
|
||||
case OPT_ENGINE:
|
||||
e = setup_engine(opt_arg(), 0);
|
||||
break;
|
||||
case OPT_CIPHER:
|
||||
if (!opt_cipher(opt_unknown(), &enc))
|
||||
goto opthelp;
|
||||
break;
|
||||
case OPT_CONV_FORM:
|
||||
if (!opt_pair(opt_arg(), conv_forms, &i))
|
||||
goto opthelp;
|
||||
new_form = 1;
|
||||
form = i;
|
||||
break;
|
||||
case OPT_PARAM_ENC:
|
||||
if (!opt_pair(opt_arg(), param_enc, &i))
|
||||
goto opthelp;
|
||||
new_asn1_flag = 1;
|
||||
asn1_flag = i;
|
||||
break;
|
||||
case OPT_NO_PUBLIC:
|
||||
no_public = 1;
|
||||
break;
|
||||
case OPT_CHECK:
|
||||
check = 1;
|
||||
break;
|
||||
}
|
||||
argc--;
|
||||
argv++;
|
||||
}
|
||||
argc = opt_num_rest();
|
||||
if (argc != 0)
|
||||
goto opthelp;
|
||||
|
||||
if (badops) {
|
||||
bad:
|
||||
BIO_printf(bio_err, "%s [options] <infile >outfile\n", prog);
|
||||
BIO_printf(bio_err, "where options are\n");
|
||||
BIO_printf(bio_err, " -inform arg input format - "
|
||||
"DER or PEM\n");
|
||||
BIO_printf(bio_err, " -outform arg output format - "
|
||||
"DER or PEM\n");
|
||||
BIO_printf(bio_err, " -in arg input file\n");
|
||||
BIO_printf(bio_err, " -passin arg input file pass "
|
||||
"phrase source\n");
|
||||
BIO_printf(bio_err, " -out arg output file\n");
|
||||
BIO_printf(bio_err, " -passout arg output file pass "
|
||||
"phrase source\n");
|
||||
BIO_printf(bio_err, " -engine e use engine e, "
|
||||
"possibly a hardware device.\n");
|
||||
BIO_printf(bio_err, " -des encrypt PEM output, "
|
||||
"instead of 'des' every other \n"
|
||||
" cipher "
|
||||
"supported by OpenSSL can be used\n");
|
||||
BIO_printf(bio_err, " -text print the key\n");
|
||||
BIO_printf(bio_err, " -noout don't print key out\n");
|
||||
BIO_printf(bio_err, " -param_out print the elliptic "
|
||||
"curve parameters\n");
|
||||
BIO_printf(bio_err, " -conv_form arg specifies the "
|
||||
"point conversion form \n");
|
||||
BIO_printf(bio_err, " possible values:"
|
||||
" compressed\n");
|
||||
BIO_printf(bio_err, " "
|
||||
" uncompressed (default)\n");
|
||||
BIO_printf(bio_err, " " " hybrid\n");
|
||||
BIO_printf(bio_err, " -param_enc arg specifies the way"
|
||||
" the ec parameters are encoded\n");
|
||||
BIO_printf(bio_err, " in the asn1 der " "encoding\n");
|
||||
BIO_printf(bio_err, " possible values:"
|
||||
" named_curve (default)\n");
|
||||
BIO_printf(bio_err, " "
|
||||
"explicit\n");
|
||||
goto end;
|
||||
}
|
||||
private = param_out || pubin || pubout ? 0 : 1;
|
||||
if (text && !pubin)
|
||||
private = 1;
|
||||
|
||||
ERR_load_crypto_strings();
|
||||
|
||||
e = setup_engine(bio_err, engine, 0);
|
||||
|
||||
if (!app_passwd(bio_err, passargin, passargout, &passin, &passout)) {
|
||||
if (!app_passwd(passinarg, passoutarg, &passin, &passout)) {
|
||||
BIO_printf(bio_err, "Error getting passwords\n");
|
||||
goto end;
|
||||
}
|
||||
|
||||
in = BIO_new(BIO_s_file());
|
||||
out = BIO_new(BIO_s_file());
|
||||
if ((in == NULL) || (out == NULL)) {
|
||||
ERR_print_errors(bio_err);
|
||||
goto end;
|
||||
}
|
||||
|
||||
if (infile == NULL)
|
||||
BIO_set_fp(in, stdin, BIO_NOCLOSE);
|
||||
else {
|
||||
if (BIO_read_filename(in, infile) <= 0) {
|
||||
perror(infile);
|
||||
if (informat != FORMAT_ENGINE) {
|
||||
in = bio_open_default(infile, 'r', informat);
|
||||
if (in == NULL)
|
||||
goto end;
|
||||
}
|
||||
}
|
||||
|
||||
BIO_printf(bio_err, "read EC key\n");
|
||||
@ -265,14 +183,21 @@ int MAIN(int argc, char **argv)
|
||||
eckey = d2i_EC_PUBKEY_bio(in, NULL);
|
||||
else
|
||||
eckey = d2i_ECPrivateKey_bio(in, NULL);
|
||||
} else if (informat == FORMAT_PEM) {
|
||||
} else if (informat == FORMAT_ENGINE) {
|
||||
EVP_PKEY *pkey;
|
||||
if (pubin)
|
||||
pkey = load_pubkey(infile, informat, 1, passin, e, "Public Key");
|
||||
else
|
||||
pkey = load_key(infile, informat, 1, passin, e, "Private Key");
|
||||
if (pkey != NULL) {
|
||||
eckey = EVP_PKEY_get1_EC_KEY(pkey);
|
||||
EVP_PKEY_free(pkey);
|
||||
}
|
||||
} else {
|
||||
if (pubin)
|
||||
eckey = PEM_read_bio_EC_PUBKEY(in, NULL, NULL, NULL);
|
||||
else
|
||||
eckey = PEM_read_bio_ECPrivateKey(in, NULL, NULL, passin);
|
||||
} else {
|
||||
BIO_printf(bio_err, "bad input format specified for key\n");
|
||||
goto end;
|
||||
}
|
||||
if (eckey == NULL) {
|
||||
BIO_printf(bio_err, "unable to load Key\n");
|
||||
@ -280,20 +205,9 @@ int MAIN(int argc, char **argv)
|
||||
goto end;
|
||||
}
|
||||
|
||||
if (outfile == NULL) {
|
||||
BIO_set_fp(out, stdout, BIO_NOCLOSE);
|
||||
# ifdef OPENSSL_SYS_VMS
|
||||
{
|
||||
BIO *tmpbio = BIO_new(BIO_f_linebuffer());
|
||||
out = BIO_push(tmpbio, out);
|
||||
}
|
||||
# endif
|
||||
} else {
|
||||
if (BIO_write_filename(out, outfile) <= 0) {
|
||||
perror(outfile);
|
||||
goto end;
|
||||
}
|
||||
}
|
||||
out = bio_open_owner(outfile, outformat, private);
|
||||
if (out == NULL)
|
||||
goto end;
|
||||
|
||||
group = EC_KEY_get0_group(eckey);
|
||||
|
||||
@ -303,12 +217,26 @@ int MAIN(int argc, char **argv)
|
||||
if (new_asn1_flag)
|
||||
EC_KEY_set_asn1_flag(eckey, asn1_flag);
|
||||
|
||||
if (text)
|
||||
if (no_public)
|
||||
EC_KEY_set_enc_flags(eckey, EC_PKEY_NO_PUBKEY);
|
||||
|
||||
if (text) {
|
||||
assert(pubin || private);
|
||||
if (!EC_KEY_print(out, eckey, 0)) {
|
||||
perror(outfile);
|
||||
ERR_print_errors(bio_err);
|
||||
goto end;
|
||||
}
|
||||
}
|
||||
|
||||
if (check) {
|
||||
if (EC_KEY_check_key(eckey) == 1) {
|
||||
BIO_printf(bio_err, "EC Key valid.\n");
|
||||
} else {
|
||||
BIO_printf(bio_err, "EC Key Invalid!\n");
|
||||
ERR_print_errors(bio_err);
|
||||
}
|
||||
}
|
||||
|
||||
if (noout) {
|
||||
ret = 0;
|
||||
@ -317,49 +245,39 @@ int MAIN(int argc, char **argv)
|
||||
|
||||
BIO_printf(bio_err, "writing EC key\n");
|
||||
if (outformat == FORMAT_ASN1) {
|
||||
if (param_out)
|
||||
if (param_out) {
|
||||
i = i2d_ECPKParameters_bio(out, group);
|
||||
else if (pubin || pubout)
|
||||
} else if (pubin || pubout) {
|
||||
i = i2d_EC_PUBKEY_bio(out, eckey);
|
||||
else
|
||||
} else {
|
||||
assert(private);
|
||||
i = i2d_ECPrivateKey_bio(out, eckey);
|
||||
} else if (outformat == FORMAT_PEM) {
|
||||
if (param_out)
|
||||
}
|
||||
} else {
|
||||
if (param_out) {
|
||||
i = PEM_write_bio_ECPKParameters(out, group);
|
||||
else if (pubin || pubout)
|
||||
} else if (pubin || pubout) {
|
||||
i = PEM_write_bio_EC_PUBKEY(out, eckey);
|
||||
else
|
||||
} else {
|
||||
assert(private);
|
||||
i = PEM_write_bio_ECPrivateKey(out, eckey, enc,
|
||||
NULL, 0, NULL, passout);
|
||||
} else {
|
||||
BIO_printf(bio_err, "bad output format specified for " "outfile\n");
|
||||
goto end;
|
||||
}
|
||||
}
|
||||
|
||||
if (!i) {
|
||||
BIO_printf(bio_err, "unable to write private key\n");
|
||||
ERR_print_errors(bio_err);
|
||||
} else
|
||||
} else {
|
||||
ret = 0;
|
||||
}
|
||||
end:
|
||||
if (in)
|
||||
BIO_free(in);
|
||||
if (out)
|
||||
BIO_free_all(out);
|
||||
if (eckey)
|
||||
EC_KEY_free(eckey);
|
||||
BIO_free(in);
|
||||
BIO_free_all(out);
|
||||
EC_KEY_free(eckey);
|
||||
release_engine(e);
|
||||
if (passin)
|
||||
OPENSSL_free(passin);
|
||||
if (passout)
|
||||
OPENSSL_free(passout);
|
||||
apps_shutdown();
|
||||
OPENSSL_EXIT(ret);
|
||||
OPENSSL_free(passin);
|
||||
OPENSSL_free(passout);
|
||||
return ret;
|
||||
}
|
||||
#else /* !OPENSSL_NO_EC */
|
||||
|
||||
# if PEDANTIC
|
||||
static void *dummy = &dummy;
|
||||
# endif
|
||||
|
||||
#endif
|
||||
|
@ -1,82 +1,24 @@
|
||||
/* apps/ecparam.c */
|
||||
/*
|
||||
* Written by Nils Larsch for the OpenSSL project.
|
||||
*/
|
||||
/* ====================================================================
|
||||
* Copyright (c) 1998-2018 The OpenSSL Project. All rights reserved.
|
||||
*
|
||||
* Redistribution and use in source and binary forms, with or without
|
||||
* modification, are permitted provided that the following conditions
|
||||
* are met:
|
||||
*
|
||||
* 1. Redistributions of source code must retain the above copyright
|
||||
* notice, this list of conditions and the following disclaimer.
|
||||
*
|
||||
* 2. Redistributions in binary form must reproduce the above copyright
|
||||
* notice, this list of conditions and the following disclaimer in
|
||||
* the documentation and/or other materials provided with the
|
||||
* distribution.
|
||||
*
|
||||
* 3. All advertising materials mentioning features or use of this
|
||||
* software must display the following acknowledgment:
|
||||
* "This product includes software developed by the OpenSSL Project
|
||||
* for use in the OpenSSL Toolkit. (http://www.openssl.org/)"
|
||||
*
|
||||
* 4. The names "OpenSSL Toolkit" and "OpenSSL Project" must not be used to
|
||||
* endorse or promote products derived from this software without
|
||||
* prior written permission. For written permission, please contact
|
||||
* openssl-core@openssl.org.
|
||||
*
|
||||
* 5. Products derived from this software may not be called "OpenSSL"
|
||||
* nor may "OpenSSL" appear in their names without prior written
|
||||
* permission of the OpenSSL Project.
|
||||
*
|
||||
* 6. Redistributions of any form whatsoever must retain the following
|
||||
* acknowledgment:
|
||||
* "This product includes software developed by the OpenSSL Project
|
||||
* for use in the OpenSSL Toolkit (http://www.openssl.org/)"
|
||||
*
|
||||
* THIS SOFTWARE IS PROVIDED BY THE OpenSSL PROJECT ``AS IS'' AND ANY
|
||||
* EXPRESSED OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
|
||||
* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
|
||||
* PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE OpenSSL PROJECT OR
|
||||
* ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
|
||||
* SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
|
||||
* NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
|
||||
* LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
|
||||
* HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT,
|
||||
* STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
|
||||
* ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED
|
||||
* OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
* ====================================================================
|
||||
*
|
||||
* This product includes cryptographic software written by Eric Young
|
||||
* (eay@cryptsoft.com). This product includes software written by Tim
|
||||
* Hudson (tjh@cryptsoft.com).
|
||||
*
|
||||
*/
|
||||
/* ====================================================================
|
||||
* Copyright 2002 Sun Microsystems, Inc. ALL RIGHTS RESERVED.
|
||||
*
|
||||
* Portions of the attached software ("Contribution") are developed by
|
||||
* SUN MICROSYSTEMS, INC., and are contributed to the OpenSSL project.
|
||||
*
|
||||
* The Contribution is licensed pursuant to the OpenSSL open source
|
||||
* license provided above.
|
||||
*
|
||||
* The elliptic curve binary polynomial software is originally written by
|
||||
* Sheueling Chang Shantz and Douglas Stebila of Sun Microsystems Laboratories.
|
||||
* Copyright 2002-2018 The OpenSSL Project Authors. All Rights Reserved.
|
||||
* Copyright (c) 2002, Oracle and/or its affiliates. All rights reserved
|
||||
*
|
||||
* Licensed under the OpenSSL license (the "License"). You may not use
|
||||
* this file except in compliance with the License. You can obtain a copy
|
||||
* in the file LICENSE in the source distribution or at
|
||||
* https://www.openssl.org/source/license.html
|
||||
*/
|
||||
|
||||
#include <openssl/opensslconf.h>
|
||||
#ifndef OPENSSL_NO_EC
|
||||
# include <assert.h>
|
||||
#ifdef OPENSSL_NO_EC
|
||||
NON_EMPTY_TRANSLATION_UNIT
|
||||
#else
|
||||
|
||||
# include <stdio.h>
|
||||
# include <stdlib.h>
|
||||
# include <time.h>
|
||||
# include <string.h>
|
||||
# include "apps.h"
|
||||
# include "progs.h"
|
||||
# include <openssl/bio.h>
|
||||
# include <openssl/err.h>
|
||||
# include <openssl/bn.h>
|
||||
@ -84,248 +26,161 @@
|
||||
# include <openssl/x509.h>
|
||||
# include <openssl/pem.h>
|
||||
|
||||
# undef PROG
|
||||
# define PROG ecparam_main
|
||||
typedef enum OPTION_choice {
|
||||
OPT_ERR = -1, OPT_EOF = 0, OPT_HELP,
|
||||
OPT_INFORM, OPT_OUTFORM, OPT_IN, OPT_OUT, OPT_TEXT, OPT_C,
|
||||
OPT_CHECK, OPT_LIST_CURVES, OPT_NO_SEED, OPT_NOOUT, OPT_NAME,
|
||||
OPT_CONV_FORM, OPT_PARAM_ENC, OPT_GENKEY, OPT_ENGINE,
|
||||
OPT_R_ENUM
|
||||
} OPTION_CHOICE;
|
||||
|
||||
/*-
|
||||
* -inform arg - input format - default PEM (DER or PEM)
|
||||
* -outform arg - output format - default PEM
|
||||
* -in arg - input file - default stdin
|
||||
* -out arg - output file - default stdout
|
||||
* -noout - do not print the ec parameter
|
||||
* -text - print the ec parameters in text form
|
||||
* -check - validate the ec parameters
|
||||
* -C - print a 'C' function creating the parameters
|
||||
* -name arg - use the ec parameters with 'short name' name
|
||||
* -list_curves - prints a list of all currently available curve 'short names'
|
||||
* -conv_form arg - specifies the point conversion form
|
||||
* - possible values: compressed
|
||||
* uncompressed (default)
|
||||
* hybrid
|
||||
* -param_enc arg - specifies the way the ec parameters are encoded
|
||||
* in the asn1 der encoding
|
||||
* possible values: named_curve (default)
|
||||
* explicit
|
||||
* -no_seed - if 'explicit' parameters are chosen do not use the seed
|
||||
* -genkey - generate ec key
|
||||
* -rand file - files to use for random number input
|
||||
* -engine e - use engine e, possibly a hardware device
|
||||
*/
|
||||
const OPTIONS ecparam_options[] = {
|
||||
{"help", OPT_HELP, '-', "Display this summary"},
|
||||
{"inform", OPT_INFORM, 'F', "Input format - default PEM (DER or PEM)"},
|
||||
{"outform", OPT_OUTFORM, 'F', "Output format - default PEM"},
|
||||
{"in", OPT_IN, '<', "Input file - default stdin"},
|
||||
{"out", OPT_OUT, '>', "Output file - default stdout"},
|
||||
{"text", OPT_TEXT, '-', "Print the ec parameters in text form"},
|
||||
{"C", OPT_C, '-', "Print a 'C' function creating the parameters"},
|
||||
{"check", OPT_CHECK, '-', "Validate the ec parameters"},
|
||||
{"list_curves", OPT_LIST_CURVES, '-',
|
||||
"Prints a list of all curve 'short names'"},
|
||||
{"no_seed", OPT_NO_SEED, '-',
|
||||
"If 'explicit' parameters are chosen do not use the seed"},
|
||||
{"noout", OPT_NOOUT, '-', "Do not print the ec parameter"},
|
||||
{"name", OPT_NAME, 's',
|
||||
"Use the ec parameters with specified 'short name'"},
|
||||
{"conv_form", OPT_CONV_FORM, 's', "Specifies the point conversion form "},
|
||||
{"param_enc", OPT_PARAM_ENC, 's',
|
||||
"Specifies the way the ec parameters are encoded"},
|
||||
{"genkey", OPT_GENKEY, '-', "Generate ec key"},
|
||||
OPT_R_OPTIONS,
|
||||
# ifndef OPENSSL_NO_ENGINE
|
||||
{"engine", OPT_ENGINE, 's', "Use engine, possibly a hardware device"},
|
||||
# endif
|
||||
{NULL}
|
||||
};
|
||||
|
||||
static int ecparam_print_var(BIO *, BIGNUM *, const char *, int,
|
||||
unsigned char *);
|
||||
static OPT_PAIR forms[] = {
|
||||
{"compressed", POINT_CONVERSION_COMPRESSED},
|
||||
{"uncompressed", POINT_CONVERSION_UNCOMPRESSED},
|
||||
{"hybrid", POINT_CONVERSION_HYBRID},
|
||||
{NULL}
|
||||
};
|
||||
|
||||
int MAIN(int, char **);
|
||||
static OPT_PAIR encodings[] = {
|
||||
{"named_curve", OPENSSL_EC_NAMED_CURVE},
|
||||
{"explicit", 0},
|
||||
{NULL}
|
||||
};
|
||||
|
||||
int MAIN(int argc, char **argv)
|
||||
int ecparam_main(int argc, char **argv)
|
||||
{
|
||||
ENGINE *e = NULL;
|
||||
BIGNUM *ec_gen = NULL, *ec_order = NULL, *ec_cofactor = NULL;
|
||||
BIGNUM *ec_p = NULL, *ec_a = NULL, *ec_b = NULL;
|
||||
BIO *in = NULL, *out = NULL;
|
||||
EC_GROUP *group = NULL;
|
||||
point_conversion_form_t form = POINT_CONVERSION_UNCOMPRESSED;
|
||||
int new_form = 0;
|
||||
int asn1_flag = OPENSSL_EC_NAMED_CURVE;
|
||||
int new_asn1_flag = 0;
|
||||
char *curve_name = NULL, *inrand = NULL;
|
||||
int list_curves = 0, no_seed = 0, check = 0,
|
||||
badops = 0, text = 0, i, need_rand = 0, genkey = 0;
|
||||
char *curve_name = NULL;
|
||||
char *infile = NULL, *outfile = NULL, *prog;
|
||||
BIO *in = NULL, *out = NULL;
|
||||
int informat, outformat, noout = 0, C = 0, ret = 1;
|
||||
char *engine = NULL;
|
||||
ENGINE *e = NULL;
|
||||
|
||||
BIGNUM *ec_p = NULL, *ec_a = NULL, *ec_b = NULL,
|
||||
*ec_gen = NULL, *ec_order = NULL, *ec_cofactor = NULL;
|
||||
unsigned char *buffer = NULL;
|
||||
OPTION_CHOICE o;
|
||||
int asn1_flag = OPENSSL_EC_NAMED_CURVE, new_asn1_flag = 0;
|
||||
int informat = FORMAT_PEM, outformat = FORMAT_PEM, noout = 0, C = 0;
|
||||
int ret = 1, private = 0;
|
||||
int list_curves = 0, no_seed = 0, check = 0, new_form = 0;
|
||||
int text = 0, i, genkey = 0;
|
||||
|
||||
apps_startup();
|
||||
|
||||
if (bio_err == NULL)
|
||||
if ((bio_err = BIO_new(BIO_s_file())) != NULL)
|
||||
BIO_set_fp(bio_err, stderr, BIO_NOCLOSE | BIO_FP_TEXT);
|
||||
|
||||
if (!load_config(bio_err, NULL))
|
||||
goto end;
|
||||
|
||||
informat = FORMAT_PEM;
|
||||
outformat = FORMAT_PEM;
|
||||
|
||||
prog = argv[0];
|
||||
argc--;
|
||||
argv++;
|
||||
while (argc >= 1) {
|
||||
if (strcmp(*argv, "-inform") == 0) {
|
||||
if (--argc < 1)
|
||||
goto bad;
|
||||
informat = str2fmt(*(++argv));
|
||||
} else if (strcmp(*argv, "-outform") == 0) {
|
||||
if (--argc < 1)
|
||||
goto bad;
|
||||
outformat = str2fmt(*(++argv));
|
||||
} else if (strcmp(*argv, "-in") == 0) {
|
||||
if (--argc < 1)
|
||||
goto bad;
|
||||
infile = *(++argv);
|
||||
} else if (strcmp(*argv, "-out") == 0) {
|
||||
if (--argc < 1)
|
||||
goto bad;
|
||||
outfile = *(++argv);
|
||||
} else if (strcmp(*argv, "-text") == 0)
|
||||
prog = opt_init(argc, argv, ecparam_options);
|
||||
while ((o = opt_next()) != OPT_EOF) {
|
||||
switch (o) {
|
||||
case OPT_EOF:
|
||||
case OPT_ERR:
|
||||
opthelp:
|
||||
BIO_printf(bio_err, "%s: Use -help for summary.\n", prog);
|
||||
goto end;
|
||||
case OPT_HELP:
|
||||
opt_help(ecparam_options);
|
||||
ret = 0;
|
||||
goto end;
|
||||
case OPT_INFORM:
|
||||
if (!opt_format(opt_arg(), OPT_FMT_PEMDER, &informat))
|
||||
goto opthelp;
|
||||
break;
|
||||
case OPT_IN:
|
||||
infile = opt_arg();
|
||||
break;
|
||||
case OPT_OUTFORM:
|
||||
if (!opt_format(opt_arg(), OPT_FMT_PEMDER, &outformat))
|
||||
goto opthelp;
|
||||
break;
|
||||
case OPT_OUT:
|
||||
outfile = opt_arg();
|
||||
break;
|
||||
case OPT_TEXT:
|
||||
text = 1;
|
||||
else if (strcmp(*argv, "-C") == 0)
|
||||
break;
|
||||
case OPT_C:
|
||||
C = 1;
|
||||
else if (strcmp(*argv, "-check") == 0)
|
||||
break;
|
||||
case OPT_CHECK:
|
||||
check = 1;
|
||||
else if (strcmp(*argv, "-name") == 0) {
|
||||
if (--argc < 1)
|
||||
goto bad;
|
||||
curve_name = *(++argv);
|
||||
} else if (strcmp(*argv, "-list_curves") == 0)
|
||||
break;
|
||||
case OPT_LIST_CURVES:
|
||||
list_curves = 1;
|
||||
else if (strcmp(*argv, "-conv_form") == 0) {
|
||||
if (--argc < 1)
|
||||
goto bad;
|
||||
++argv;
|
||||
new_form = 1;
|
||||
if (strcmp(*argv, "compressed") == 0)
|
||||
form = POINT_CONVERSION_COMPRESSED;
|
||||
else if (strcmp(*argv, "uncompressed") == 0)
|
||||
form = POINT_CONVERSION_UNCOMPRESSED;
|
||||
else if (strcmp(*argv, "hybrid") == 0)
|
||||
form = POINT_CONVERSION_HYBRID;
|
||||
else
|
||||
goto bad;
|
||||
} else if (strcmp(*argv, "-param_enc") == 0) {
|
||||
if (--argc < 1)
|
||||
goto bad;
|
||||
++argv;
|
||||
new_asn1_flag = 1;
|
||||
if (strcmp(*argv, "named_curve") == 0)
|
||||
asn1_flag = OPENSSL_EC_NAMED_CURVE;
|
||||
else if (strcmp(*argv, "explicit") == 0)
|
||||
asn1_flag = 0;
|
||||
else
|
||||
goto bad;
|
||||
} else if (strcmp(*argv, "-no_seed") == 0)
|
||||
break;
|
||||
case OPT_NO_SEED:
|
||||
no_seed = 1;
|
||||
else if (strcmp(*argv, "-noout") == 0)
|
||||
break;
|
||||
case OPT_NOOUT:
|
||||
noout = 1;
|
||||
else if (strcmp(*argv, "-genkey") == 0) {
|
||||
break;
|
||||
case OPT_NAME:
|
||||
curve_name = opt_arg();
|
||||
break;
|
||||
case OPT_CONV_FORM:
|
||||
if (!opt_pair(opt_arg(), forms, &new_form))
|
||||
goto opthelp;
|
||||
form = new_form;
|
||||
new_form = 1;
|
||||
break;
|
||||
case OPT_PARAM_ENC:
|
||||
if (!opt_pair(opt_arg(), encodings, &asn1_flag))
|
||||
goto opthelp;
|
||||
new_asn1_flag = 1;
|
||||
break;
|
||||
case OPT_GENKEY:
|
||||
genkey = 1;
|
||||
need_rand = 1;
|
||||
} else if (strcmp(*argv, "-rand") == 0) {
|
||||
if (--argc < 1)
|
||||
goto bad;
|
||||
inrand = *(++argv);
|
||||
need_rand = 1;
|
||||
} else if (strcmp(*argv, "-engine") == 0) {
|
||||
if (--argc < 1)
|
||||
goto bad;
|
||||
engine = *(++argv);
|
||||
} else {
|
||||
BIO_printf(bio_err, "unknown option %s\n", *argv);
|
||||
badops = 1;
|
||||
break;
|
||||
case OPT_R_CASES:
|
||||
if (!opt_rand(o))
|
||||
goto end;
|
||||
break;
|
||||
case OPT_ENGINE:
|
||||
e = setup_engine(opt_arg(), 0);
|
||||
break;
|
||||
}
|
||||
argc--;
|
||||
argv++;
|
||||
}
|
||||
argc = opt_num_rest();
|
||||
if (argc != 0)
|
||||
goto opthelp;
|
||||
|
||||
if (badops) {
|
||||
bad:
|
||||
BIO_printf(bio_err, "%s [options] <infile >outfile\n", prog);
|
||||
BIO_printf(bio_err, "where options are\n");
|
||||
BIO_printf(bio_err, " -inform arg input format - "
|
||||
"default PEM (DER or PEM)\n");
|
||||
BIO_printf(bio_err, " -outform arg output format - "
|
||||
"default PEM\n");
|
||||
BIO_printf(bio_err, " -in arg input file - "
|
||||
"default stdin\n");
|
||||
BIO_printf(bio_err, " -out arg output file - "
|
||||
"default stdout\n");
|
||||
BIO_printf(bio_err, " -noout do not print the "
|
||||
"ec parameter\n");
|
||||
BIO_printf(bio_err, " -text print the ec "
|
||||
"parameters in text form\n");
|
||||
BIO_printf(bio_err, " -check validate the ec "
|
||||
"parameters\n");
|
||||
BIO_printf(bio_err, " -C print a 'C' "
|
||||
"function creating the parameters\n");
|
||||
BIO_printf(bio_err, " -name arg use the "
|
||||
"ec parameters with 'short name' name\n");
|
||||
BIO_printf(bio_err, " -list_curves prints a list of "
|
||||
"all currently available curve 'short names'\n");
|
||||
BIO_printf(bio_err, " -conv_form arg specifies the "
|
||||
"point conversion form \n");
|
||||
BIO_printf(bio_err, " possible values:"
|
||||
" compressed\n");
|
||||
BIO_printf(bio_err, " "
|
||||
" uncompressed (default)\n");
|
||||
BIO_printf(bio_err, " "
|
||||
" hybrid\n");
|
||||
BIO_printf(bio_err, " -param_enc arg specifies the way"
|
||||
" the ec parameters are encoded\n");
|
||||
BIO_printf(bio_err, " in the asn1 der "
|
||||
"encoding\n");
|
||||
BIO_printf(bio_err, " possible values:"
|
||||
" named_curve (default)\n");
|
||||
BIO_printf(bio_err, " "
|
||||
" explicit\n");
|
||||
BIO_printf(bio_err, " -no_seed if 'explicit'"
|
||||
" parameters are chosen do not" " use the seed\n");
|
||||
BIO_printf(bio_err, " -genkey generate ec" " key\n");
|
||||
BIO_printf(bio_err, " -rand file files to use for"
|
||||
" random number input\n");
|
||||
BIO_printf(bio_err, " -engine e use engine e, "
|
||||
"possibly a hardware device\n");
|
||||
private = genkey ? 1 : 0;
|
||||
|
||||
in = bio_open_default(infile, 'r', informat);
|
||||
if (in == NULL)
|
||||
goto end;
|
||||
}
|
||||
|
||||
ERR_load_crypto_strings();
|
||||
|
||||
in = BIO_new(BIO_s_file());
|
||||
out = BIO_new(BIO_s_file());
|
||||
if ((in == NULL) || (out == NULL)) {
|
||||
ERR_print_errors(bio_err);
|
||||
out = bio_open_owner(outfile, outformat, private);
|
||||
if (out == NULL)
|
||||
goto end;
|
||||
}
|
||||
|
||||
if (infile == NULL)
|
||||
BIO_set_fp(in, stdin, BIO_NOCLOSE);
|
||||
else {
|
||||
if (BIO_read_filename(in, infile) <= 0) {
|
||||
perror(infile);
|
||||
goto end;
|
||||
}
|
||||
}
|
||||
if (outfile == NULL) {
|
||||
BIO_set_fp(out, stdout, BIO_NOCLOSE);
|
||||
# ifdef OPENSSL_SYS_VMS
|
||||
{
|
||||
BIO *tmpbio = BIO_new(BIO_f_linebuffer());
|
||||
out = BIO_push(tmpbio, out);
|
||||
}
|
||||
# endif
|
||||
} else {
|
||||
if (BIO_write_filename(out, outfile) <= 0) {
|
||||
perror(outfile);
|
||||
goto end;
|
||||
}
|
||||
}
|
||||
|
||||
e = setup_engine(bio_err, engine, 0);
|
||||
|
||||
if (list_curves) {
|
||||
EC_builtin_curve *curves = NULL;
|
||||
size_t crv_len = 0;
|
||||
size_t n = 0;
|
||||
|
||||
crv_len = EC_get_builtin_curves(NULL, 0);
|
||||
|
||||
curves = OPENSSL_malloc((int)(sizeof(EC_builtin_curve) * crv_len));
|
||||
|
||||
if (curves == NULL)
|
||||
goto end;
|
||||
size_t crv_len = EC_get_builtin_curves(NULL, 0);
|
||||
size_t n;
|
||||
|
||||
curves = app_malloc((int)sizeof(*curves) * crv_len, "list curves");
|
||||
if (!EC_get_builtin_curves(curves, crv_len)) {
|
||||
OPENSSL_free(curves);
|
||||
goto end;
|
||||
@ -358,16 +213,17 @@ int MAIN(int argc, char **argv)
|
||||
* are the same as the curves prime192v1 and prime256v1 defined in
|
||||
* X9.62)
|
||||
*/
|
||||
if (!strcmp(curve_name, "secp192r1")) {
|
||||
if (strcmp(curve_name, "secp192r1") == 0) {
|
||||
BIO_printf(bio_err, "using curve name prime192v1 "
|
||||
"instead of secp192r1\n");
|
||||
nid = NID_X9_62_prime192v1;
|
||||
} else if (!strcmp(curve_name, "secp256r1")) {
|
||||
} else if (strcmp(curve_name, "secp256r1") == 0) {
|
||||
BIO_printf(bio_err, "using curve name prime256v1 "
|
||||
"instead of secp256r1\n");
|
||||
nid = NID_X9_62_prime256v1;
|
||||
} else
|
||||
} else {
|
||||
nid = OBJ_sn2nid(curve_name);
|
||||
}
|
||||
|
||||
if (nid == 0)
|
||||
nid = EC_curve_nist2nid(curve_name);
|
||||
@ -386,13 +242,9 @@ int MAIN(int argc, char **argv)
|
||||
EC_GROUP_set_point_conversion_form(group, form);
|
||||
} else if (informat == FORMAT_ASN1) {
|
||||
group = d2i_ECPKParameters_bio(in, NULL);
|
||||
} else if (informat == FORMAT_PEM) {
|
||||
group = PEM_read_bio_ECPKParameters(in, NULL, NULL, NULL);
|
||||
} else {
|
||||
BIO_printf(bio_err, "bad input format specified\n");
|
||||
goto end;
|
||||
group = PEM_read_bio_ECPKParameters(in, NULL, NULL, NULL);
|
||||
}
|
||||
|
||||
if (group == NULL) {
|
||||
BIO_printf(bio_err, "unable to load elliptic curve parameters\n");
|
||||
ERR_print_errors(bio_err);
|
||||
@ -431,24 +283,25 @@ int MAIN(int argc, char **argv)
|
||||
int is_prime, len = 0;
|
||||
const EC_METHOD *meth = EC_GROUP_method_of(group);
|
||||
|
||||
if ((ec_p = BN_new()) == NULL || (ec_a = BN_new()) == NULL ||
|
||||
(ec_b = BN_new()) == NULL || (ec_gen = BN_new()) == NULL ||
|
||||
(ec_order = BN_new()) == NULL ||
|
||||
(ec_cofactor = BN_new()) == NULL) {
|
||||
perror("OPENSSL_malloc");
|
||||
if ((ec_p = BN_new()) == NULL
|
||||
|| (ec_a = BN_new()) == NULL
|
||||
|| (ec_b = BN_new()) == NULL
|
||||
|| (ec_gen = BN_new()) == NULL
|
||||
|| (ec_order = BN_new()) == NULL
|
||||
|| (ec_cofactor = BN_new()) == NULL) {
|
||||
perror("Can't allocate BN");
|
||||
goto end;
|
||||
}
|
||||
|
||||
is_prime = (EC_METHOD_get_field_type(meth) == NID_X9_62_prime_field);
|
||||
|
||||
if (is_prime) {
|
||||
if (!EC_GROUP_get_curve_GFp(group, ec_p, ec_a, ec_b, NULL))
|
||||
goto end;
|
||||
} else {
|
||||
/* TODO */
|
||||
if (!is_prime) {
|
||||
BIO_printf(bio_err, "Can only handle X9.62 prime fields\n");
|
||||
goto end;
|
||||
}
|
||||
|
||||
if (!EC_GROUP_get_curve(group, ec_p, ec_a, ec_b, NULL))
|
||||
goto end;
|
||||
|
||||
if ((point = EC_GROUP_get0_generator(group)) == NULL)
|
||||
goto end;
|
||||
if (!EC_POINT_point2bn(group, point,
|
||||
@ -478,72 +331,57 @@ int MAIN(int argc, char **argv)
|
||||
if ((tmp_len = (size_t)BN_num_bytes(ec_cofactor)) > buf_len)
|
||||
buf_len = tmp_len;
|
||||
|
||||
buffer = (unsigned char *)OPENSSL_malloc(buf_len);
|
||||
buffer = app_malloc(buf_len, "BN buffer");
|
||||
|
||||
if (buffer == NULL) {
|
||||
perror("OPENSSL_malloc");
|
||||
goto end;
|
||||
}
|
||||
BIO_printf(out, "EC_GROUP *get_ec_group_%d(void)\n{\n", len);
|
||||
print_bignum_var(out, ec_p, "ec_p", len, buffer);
|
||||
print_bignum_var(out, ec_a, "ec_a", len, buffer);
|
||||
print_bignum_var(out, ec_b, "ec_b", len, buffer);
|
||||
print_bignum_var(out, ec_gen, "ec_gen", len, buffer);
|
||||
print_bignum_var(out, ec_order, "ec_order", len, buffer);
|
||||
print_bignum_var(out, ec_cofactor, "ec_cofactor", len, buffer);
|
||||
BIO_printf(out, " int ok = 0;\n"
|
||||
" EC_GROUP *group = NULL;\n"
|
||||
" EC_POINT *point = NULL;\n"
|
||||
" BIGNUM *tmp_1 = NULL;\n"
|
||||
" BIGNUM *tmp_2 = NULL;\n"
|
||||
" BIGNUM *tmp_3 = NULL;\n"
|
||||
"\n");
|
||||
|
||||
ecparam_print_var(out, ec_p, "ec_p", len, buffer);
|
||||
ecparam_print_var(out, ec_a, "ec_a", len, buffer);
|
||||
ecparam_print_var(out, ec_b, "ec_b", len, buffer);
|
||||
ecparam_print_var(out, ec_gen, "ec_gen", len, buffer);
|
||||
ecparam_print_var(out, ec_order, "ec_order", len, buffer);
|
||||
ecparam_print_var(out, ec_cofactor, "ec_cofactor", len, buffer);
|
||||
|
||||
BIO_printf(out, "\n\n");
|
||||
|
||||
BIO_printf(out, "EC_GROUP *get_ec_group_%d(void)\n\t{\n", len);
|
||||
BIO_printf(out, "\tint ok=0;\n");
|
||||
BIO_printf(out, "\tEC_GROUP *group = NULL;\n");
|
||||
BIO_printf(out, "\tEC_POINT *point = NULL;\n");
|
||||
BIO_printf(out, "\tBIGNUM *tmp_1 = NULL, *tmp_2 = NULL, "
|
||||
"*tmp_3 = NULL;\n\n");
|
||||
BIO_printf(out, "\tif ((tmp_1 = BN_bin2bn(ec_p_%d, "
|
||||
"sizeof(ec_p_%d), NULL)) == NULL)\n\t\t"
|
||||
"goto err;\n", len, len);
|
||||
BIO_printf(out, "\tif ((tmp_2 = BN_bin2bn(ec_a_%d, "
|
||||
"sizeof(ec_a_%d), NULL)) == NULL)\n\t\t"
|
||||
"goto err;\n", len, len);
|
||||
BIO_printf(out, "\tif ((tmp_3 = BN_bin2bn(ec_b_%d, "
|
||||
"sizeof(ec_b_%d), NULL)) == NULL)\n\t\t"
|
||||
"goto err;\n", len, len);
|
||||
if (is_prime) {
|
||||
BIO_printf(out, "\tif ((group = EC_GROUP_new_curve_"
|
||||
"GFp(tmp_1, tmp_2, tmp_3, NULL)) == NULL)"
|
||||
"\n\t\tgoto err;\n\n");
|
||||
} else {
|
||||
/* TODO */
|
||||
goto end;
|
||||
}
|
||||
BIO_printf(out, "\t/* build generator */\n");
|
||||
BIO_printf(out, "\tif ((tmp_1 = BN_bin2bn(ec_gen_%d, "
|
||||
"sizeof(ec_gen_%d), tmp_1)) == NULL)"
|
||||
"\n\t\tgoto err;\n", len, len);
|
||||
BIO_printf(out, "\tpoint = EC_POINT_bn2point(group, tmp_1, "
|
||||
"NULL, NULL);\n");
|
||||
BIO_printf(out, "\tif (point == NULL)\n\t\tgoto err;\n");
|
||||
BIO_printf(out, "\tif ((tmp_2 = BN_bin2bn(ec_order_%d, "
|
||||
"sizeof(ec_order_%d), tmp_2)) == NULL)"
|
||||
"\n\t\tgoto err;\n", len, len);
|
||||
BIO_printf(out, "\tif ((tmp_3 = BN_bin2bn(ec_cofactor_%d, "
|
||||
"sizeof(ec_cofactor_%d), tmp_3)) == NULL)"
|
||||
"\n\t\tgoto err;\n", len, len);
|
||||
BIO_printf(out, "\tif (!EC_GROUP_set_generator(group, point,"
|
||||
" tmp_2, tmp_3))\n\t\tgoto err;\n");
|
||||
BIO_printf(out, "\n\tok=1;\n");
|
||||
BIO_printf(out, "err:\n");
|
||||
BIO_printf(out, "\tif (tmp_1)\n\t\tBN_free(tmp_1);\n");
|
||||
BIO_printf(out, "\tif (tmp_2)\n\t\tBN_free(tmp_2);\n");
|
||||
BIO_printf(out, "\tif (tmp_3)\n\t\tBN_free(tmp_3);\n");
|
||||
BIO_printf(out, "\tif (point)\n\t\tEC_POINT_free(point);\n");
|
||||
BIO_printf(out, "\tif (!ok)\n");
|
||||
BIO_printf(out, "\t\t{\n");
|
||||
BIO_printf(out, "\t\tEC_GROUP_free(group);\n");
|
||||
BIO_printf(out, "\t\tgroup = NULL;\n");
|
||||
BIO_printf(out, "\t\t}\n");
|
||||
BIO_printf(out, "\treturn(group);\n\t}\n");
|
||||
BIO_printf(out, " if ((tmp_1 = BN_bin2bn(ec_p_%d, sizeof(ec_p_%d), NULL)) == NULL)\n"
|
||||
" goto err;\n", len, len);
|
||||
BIO_printf(out, " if ((tmp_2 = BN_bin2bn(ec_a_%d, sizeof(ec_a_%d), NULL)) == NULL)\n"
|
||||
" goto err;\n", len, len);
|
||||
BIO_printf(out, " if ((tmp_3 = BN_bin2bn(ec_b_%d, sizeof(ec_b_%d), NULL)) == NULL)\n"
|
||||
" goto err;\n", len, len);
|
||||
BIO_printf(out, " if ((group = EC_GROUP_new_curve_GFp(tmp_1, tmp_2, tmp_3, NULL)) == NULL)\n"
|
||||
" goto err;\n"
|
||||
"\n");
|
||||
BIO_printf(out, " /* build generator */\n");
|
||||
BIO_printf(out, " if ((tmp_1 = BN_bin2bn(ec_gen_%d, sizeof(ec_gen_%d), tmp_1)) == NULL)\n"
|
||||
" goto err;\n", len, len);
|
||||
BIO_printf(out, " point = EC_POINT_bn2point(group, tmp_1, NULL, NULL);\n");
|
||||
BIO_printf(out, " if (point == NULL)\n"
|
||||
" goto err;\n");
|
||||
BIO_printf(out, " if ((tmp_2 = BN_bin2bn(ec_order_%d, sizeof(ec_order_%d), tmp_2)) == NULL)\n"
|
||||
" goto err;\n", len, len);
|
||||
BIO_printf(out, " if ((tmp_3 = BN_bin2bn(ec_cofactor_%d, sizeof(ec_cofactor_%d), tmp_3)) == NULL)\n"
|
||||
" goto err;\n", len, len);
|
||||
BIO_printf(out, " if (!EC_GROUP_set_generator(group, point, tmp_2, tmp_3))\n"
|
||||
" goto err;\n"
|
||||
"ok = 1;"
|
||||
"\n");
|
||||
BIO_printf(out, "err:\n"
|
||||
" BN_free(tmp_1);\n"
|
||||
" BN_free(tmp_2);\n"
|
||||
" BN_free(tmp_3);\n"
|
||||
" EC_POINT_free(point);\n"
|
||||
" if (!ok) {\n"
|
||||
" EC_GROUP_free(group);\n"
|
||||
" return NULL;\n"
|
||||
" }\n"
|
||||
" return (group);\n"
|
||||
"}\n");
|
||||
}
|
||||
|
||||
if (outformat == FORMAT_ASN1 && genkey)
|
||||
@ -552,13 +390,8 @@ int MAIN(int argc, char **argv)
|
||||
if (!noout) {
|
||||
if (outformat == FORMAT_ASN1)
|
||||
i = i2d_ECPKParameters_bio(out, group);
|
||||
else if (outformat == FORMAT_PEM)
|
||||
else
|
||||
i = PEM_write_bio_ECPKParameters(out, group);
|
||||
else {
|
||||
BIO_printf(bio_err, "bad output format specified for"
|
||||
" outfile\n");
|
||||
goto end;
|
||||
}
|
||||
if (!i) {
|
||||
BIO_printf(bio_err, "unable to write elliptic "
|
||||
"curve parameters\n");
|
||||
@ -567,101 +400,51 @@ int MAIN(int argc, char **argv)
|
||||
}
|
||||
}
|
||||
|
||||
if (need_rand) {
|
||||
app_RAND_load_file(NULL, bio_err, (inrand != NULL));
|
||||
if (inrand != NULL)
|
||||
BIO_printf(bio_err, "%ld semi-random bytes loaded\n",
|
||||
app_RAND_load_files(inrand));
|
||||
}
|
||||
|
||||
if (genkey) {
|
||||
EC_KEY *eckey = EC_KEY_new();
|
||||
|
||||
if (eckey == NULL)
|
||||
goto end;
|
||||
|
||||
assert(need_rand);
|
||||
|
||||
if (EC_KEY_set_group(eckey, group) == 0)
|
||||
if (EC_KEY_set_group(eckey, group) == 0) {
|
||||
BIO_printf(bio_err, "unable to set group when generating key\n");
|
||||
EC_KEY_free(eckey);
|
||||
ERR_print_errors(bio_err);
|
||||
goto end;
|
||||
}
|
||||
|
||||
if (new_form)
|
||||
EC_KEY_set_conv_form(eckey, form);
|
||||
|
||||
if (!EC_KEY_generate_key(eckey)) {
|
||||
BIO_printf(bio_err, "unable to generate key\n");
|
||||
EC_KEY_free(eckey);
|
||||
ERR_print_errors(bio_err);
|
||||
goto end;
|
||||
}
|
||||
assert(private);
|
||||
if (outformat == FORMAT_ASN1)
|
||||
i = i2d_ECPrivateKey_bio(out, eckey);
|
||||
else if (outformat == FORMAT_PEM)
|
||||
else
|
||||
i = PEM_write_bio_ECPrivateKey(out, eckey, NULL,
|
||||
NULL, 0, NULL, NULL);
|
||||
else {
|
||||
BIO_printf(bio_err, "bad output format specified "
|
||||
"for outfile\n");
|
||||
EC_KEY_free(eckey);
|
||||
goto end;
|
||||
}
|
||||
EC_KEY_free(eckey);
|
||||
}
|
||||
|
||||
if (need_rand)
|
||||
app_RAND_write_file(NULL, bio_err);
|
||||
|
||||
ret = 0;
|
||||
end:
|
||||
if (ec_p)
|
||||
BN_free(ec_p);
|
||||
if (ec_a)
|
||||
BN_free(ec_a);
|
||||
if (ec_b)
|
||||
BN_free(ec_b);
|
||||
if (ec_gen)
|
||||
BN_free(ec_gen);
|
||||
if (ec_order)
|
||||
BN_free(ec_order);
|
||||
if (ec_cofactor)
|
||||
BN_free(ec_cofactor);
|
||||
if (buffer)
|
||||
OPENSSL_free(buffer);
|
||||
if (group != NULL)
|
||||
EC_GROUP_free(group);
|
||||
BN_free(ec_p);
|
||||
BN_free(ec_a);
|
||||
BN_free(ec_b);
|
||||
BN_free(ec_gen);
|
||||
BN_free(ec_order);
|
||||
BN_free(ec_cofactor);
|
||||
OPENSSL_free(buffer);
|
||||
EC_GROUP_free(group);
|
||||
release_engine(e);
|
||||
if (in != NULL)
|
||||
BIO_free(in);
|
||||
if (out != NULL)
|
||||
BIO_free_all(out);
|
||||
apps_shutdown();
|
||||
OPENSSL_EXIT(ret);
|
||||
BIO_free(in);
|
||||
BIO_free_all(out);
|
||||
return ret;
|
||||
}
|
||||
|
||||
static int ecparam_print_var(BIO *out, BIGNUM *in, const char *var,
|
||||
int len, unsigned char *buffer)
|
||||
{
|
||||
BIO_printf(out, "static unsigned char %s_%d[] = {", var, len);
|
||||
if (BN_is_zero(in))
|
||||
BIO_printf(out, "\n\t0x00");
|
||||
else {
|
||||
int i, l;
|
||||
|
||||
l = BN_bn2bin(in, buffer);
|
||||
for (i = 0; i < l - 1; i++) {
|
||||
if ((i % 12) == 0)
|
||||
BIO_printf(out, "\n\t");
|
||||
BIO_printf(out, "0x%02X,", buffer[i]);
|
||||
}
|
||||
if ((i % 12) == 0)
|
||||
BIO_printf(out, "\n\t");
|
||||
BIO_printf(out, "0x%02X", buffer[i]);
|
||||
}
|
||||
BIO_printf(out, "\n\t};\n\n");
|
||||
return 1;
|
||||
}
|
||||
#else /* !OPENSSL_NO_EC */
|
||||
|
||||
# if PEDANTIC
|
||||
static void *dummy = &dummy;
|
||||
# endif
|
||||
|
||||
#endif
|
||||
|
File diff suppressed because it is too large
Load Diff
@ -1,137 +1,96 @@
|
||||
/* apps/engine.c */
|
||||
/*
|
||||
* Written by Richard Levitte <richard@levitte.org> for the OpenSSL project
|
||||
* 2000.
|
||||
*/
|
||||
/* ====================================================================
|
||||
* Copyright (c) 2000 The OpenSSL Project. All rights reserved.
|
||||
*
|
||||
* Redistribution and use in source and binary forms, with or without
|
||||
* modification, are permitted provided that the following conditions
|
||||
* are met:
|
||||
*
|
||||
* 1. Redistributions of source code must retain the above copyright
|
||||
* notice, this list of conditions and the following disclaimer.
|
||||
*
|
||||
* 2. Redistributions in binary form must reproduce the above copyright
|
||||
* notice, this list of conditions and the following disclaimer in
|
||||
* the documentation and/or other materials provided with the
|
||||
* distribution.
|
||||
*
|
||||
* 3. All advertising materials mentioning features or use of this
|
||||
* software must display the following acknowledgment:
|
||||
* "This product includes software developed by the OpenSSL Project
|
||||
* for use in the OpenSSL Toolkit. (http://www.OpenSSL.org/)"
|
||||
*
|
||||
* 4. The names "OpenSSL Toolkit" and "OpenSSL Project" must not be used to
|
||||
* endorse or promote products derived from this software without
|
||||
* prior written permission. For written permission, please contact
|
||||
* licensing@OpenSSL.org.
|
||||
*
|
||||
* 5. Products derived from this software may not be called "OpenSSL"
|
||||
* nor may "OpenSSL" appear in their names without prior written
|
||||
* permission of the OpenSSL Project.
|
||||
*
|
||||
* 6. Redistributions of any form whatsoever must retain the following
|
||||
* acknowledgment:
|
||||
* "This product includes software developed by the OpenSSL Project
|
||||
* for use in the OpenSSL Toolkit (http://www.OpenSSL.org/)"
|
||||
*
|
||||
* THIS SOFTWARE IS PROVIDED BY THE OpenSSL PROJECT ``AS IS'' AND ANY
|
||||
* EXPRESSED OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
|
||||
* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
|
||||
* PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE OpenSSL PROJECT OR
|
||||
* ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
|
||||
* SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
|
||||
* NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
|
||||
* LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
|
||||
* HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT,
|
||||
* STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
|
||||
* ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED
|
||||
* OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
* ====================================================================
|
||||
*
|
||||
* This product includes cryptographic software written by Eric Young
|
||||
* (eay@cryptsoft.com). This product includes software written by Tim
|
||||
* Hudson (tjh@cryptsoft.com).
|
||||
* Copyright 2000-2018 The OpenSSL Project Authors. All Rights Reserved.
|
||||
*
|
||||
* Licensed under the OpenSSL license (the "License"). You may not use
|
||||
* this file except in compliance with the License. You can obtain a copy
|
||||
* in the file LICENSE in the source distribution or at
|
||||
* https://www.openssl.org/source/license.html
|
||||
*/
|
||||
|
||||
#include <stdio.h>
|
||||
#include <stdlib.h>
|
||||
#include <string.h>
|
||||
#ifdef OPENSSL_NO_STDIO
|
||||
# define APPS_WIN16
|
||||
#endif
|
||||
#include "apps.h"
|
||||
#include <openssl/err.h>
|
||||
#ifndef OPENSSL_NO_ENGINE
|
||||
#include <openssl/opensslconf.h>
|
||||
#ifdef OPENSSL_NO_ENGINE
|
||||
NON_EMPTY_TRANSLATION_UNIT
|
||||
#else
|
||||
|
||||
# include "apps.h"
|
||||
# include "progs.h"
|
||||
# include <stdio.h>
|
||||
# include <stdlib.h>
|
||||
# include <string.h>
|
||||
# include <openssl/err.h>
|
||||
# include <openssl/engine.h>
|
||||
# include <openssl/ssl.h>
|
||||
# include <openssl/store.h>
|
||||
|
||||
# undef PROG
|
||||
# define PROG engine_main
|
||||
typedef enum OPTION_choice {
|
||||
OPT_ERR = -1, OPT_EOF = 0, OPT_HELP,
|
||||
OPT_C, OPT_T, OPT_TT, OPT_PRE, OPT_POST,
|
||||
OPT_V = 100, OPT_VV, OPT_VVV, OPT_VVVV
|
||||
} OPTION_CHOICE;
|
||||
|
||||
static const char *engine_usage[] = {
|
||||
"usage: engine opts [engine ...]\n",
|
||||
" -v[v[v[v]]] - verbose mode, for each engine, list its 'control commands'\n",
|
||||
" -vv will additionally display each command's description\n",
|
||||
" -vvv will also add the input flags for each command\n",
|
||||
" -vvvv will also show internal input flags\n",
|
||||
" -c - for each engine, also list the capabilities\n",
|
||||
" -t[t] - for each engine, check that they are really available\n",
|
||||
" -tt will display error trace for unavailable engines\n",
|
||||
" -pre <cmd> - runs command 'cmd' against the ENGINE before any attempts\n",
|
||||
" to load it (if -t is used)\n",
|
||||
" -post <cmd> - runs command 'cmd' against the ENGINE after loading it\n",
|
||||
" (only used if -t is also provided)\n",
|
||||
" NB: -pre and -post will be applied to all ENGINEs supplied on the command\n",
|
||||
" line, or all supported ENGINEs if none are specified.\n",
|
||||
" Eg. '-pre \"SO_PATH:/lib/libdriver.so\"' calls command \"SO_PATH\" with\n",
|
||||
" argument \"/lib/libdriver.so\".\n",
|
||||
NULL
|
||||
const OPTIONS engine_options[] = {
|
||||
{OPT_HELP_STR, 1, '-', "Usage: %s [options] engine...\n"},
|
||||
{OPT_HELP_STR, 1, '-',
|
||||
" engine... Engines to load\n"},
|
||||
{"help", OPT_HELP, '-', "Display this summary"},
|
||||
{"v", OPT_V, '-', "List 'control commands' For each specified engine"},
|
||||
{"vv", OPT_VV, '-', "Also display each command's description"},
|
||||
{"vvv", OPT_VVV, '-', "Also add the input flags for each command"},
|
||||
{"vvvv", OPT_VVVV, '-', "Also show internal input flags"},
|
||||
{"c", OPT_C, '-', "List the capabilities of specified engine"},
|
||||
{"t", OPT_T, '-', "Check that specified engine is available"},
|
||||
{"tt", OPT_TT, '-', "Display error trace for unavailable engines"},
|
||||
{"pre", OPT_PRE, 's', "Run command against the ENGINE before loading it"},
|
||||
{"post", OPT_POST, 's', "Run command against the ENGINE after loading it"},
|
||||
{OPT_MORE_STR, OPT_EOF, 1,
|
||||
"Commands are like \"SO_PATH:/lib/libdriver.so\""},
|
||||
{NULL}
|
||||
};
|
||||
|
||||
static void identity(char *ptr)
|
||||
static int append_buf(char **buf, int *size, const char *s)
|
||||
{
|
||||
return;
|
||||
}
|
||||
const int expand = 256;
|
||||
int len = strlen(s) + 1;
|
||||
char *p = *buf;
|
||||
|
||||
static int append_buf(char **buf, const char *s, int *size, int step)
|
||||
{
|
||||
if (*buf == NULL) {
|
||||
*size = step;
|
||||
*buf = OPENSSL_malloc(*size);
|
||||
if (*buf == NULL)
|
||||
return 0;
|
||||
**buf = '\0';
|
||||
}
|
||||
if (p == NULL) {
|
||||
*size = ((len + expand - 1) / expand) * expand;
|
||||
p = *buf = app_malloc(*size, "engine buffer");
|
||||
} else {
|
||||
const int blen = strlen(p);
|
||||
|
||||
if (strlen(*buf) + strlen(s) >= (unsigned int)*size) {
|
||||
char *p = *buf;
|
||||
if (blen > 0)
|
||||
len += 2 + blen;
|
||||
|
||||
*size += step;
|
||||
*buf = OPENSSL_realloc(*buf, *size);
|
||||
if (*buf == NULL) {
|
||||
OPENSSL_free(p);
|
||||
return 0;
|
||||
if (len > *size) {
|
||||
*size = ((len + expand - 1) / expand) * expand;
|
||||
p = OPENSSL_realloc(p, *size);
|
||||
if (p == NULL) {
|
||||
OPENSSL_free(*buf);
|
||||
*buf = NULL;
|
||||
return 0;
|
||||
}
|
||||
*buf = p;
|
||||
}
|
||||
|
||||
if (blen > 0) {
|
||||
p += blen;
|
||||
*p++ = ',';
|
||||
*p++ = ' ';
|
||||
}
|
||||
}
|
||||
|
||||
if (**buf != '\0')
|
||||
BUF_strlcat(*buf, ", ", *size);
|
||||
BUF_strlcat(*buf, s, *size);
|
||||
|
||||
strcpy(p, s);
|
||||
return 1;
|
||||
}
|
||||
|
||||
static int util_flags(BIO *bio_out, unsigned int flags, const char *indent)
|
||||
static int util_flags(BIO *out, unsigned int flags, const char *indent)
|
||||
{
|
||||
int started = 0, err = 0;
|
||||
/* Indent before displaying input flags */
|
||||
BIO_printf(bio_out, "%s%s(input flags): ", indent, indent);
|
||||
BIO_printf(out, "%s%s(input flags): ", indent, indent);
|
||||
if (flags == 0) {
|
||||
BIO_printf(bio_out, "<no flags>\n");
|
||||
BIO_printf(out, "<no flags>\n");
|
||||
return 1;
|
||||
}
|
||||
/*
|
||||
@ -139,11 +98,11 @@ static int util_flags(BIO *bio_out, unsigned int flags, const char *indent)
|
||||
* having it part of all the other flags, even if it really is.
|
||||
*/
|
||||
if (flags & ENGINE_CMD_FLAG_INTERNAL) {
|
||||
BIO_printf(bio_out, "[Internal] ");
|
||||
BIO_printf(out, "[Internal] ");
|
||||
}
|
||||
|
||||
if (flags & ENGINE_CMD_FLAG_NUMERIC) {
|
||||
BIO_printf(bio_out, "NUMERIC");
|
||||
BIO_printf(out, "NUMERIC");
|
||||
started = 1;
|
||||
}
|
||||
/*
|
||||
@ -154,18 +113,18 @@ static int util_flags(BIO *bio_out, unsigned int flags, const char *indent)
|
||||
*/
|
||||
if (flags & ENGINE_CMD_FLAG_STRING) {
|
||||
if (started) {
|
||||
BIO_printf(bio_out, "|");
|
||||
BIO_printf(out, "|");
|
||||
err = 1;
|
||||
}
|
||||
BIO_printf(bio_out, "STRING");
|
||||
BIO_printf(out, "STRING");
|
||||
started = 1;
|
||||
}
|
||||
if (flags & ENGINE_CMD_FLAG_NO_INPUT) {
|
||||
if (started) {
|
||||
BIO_printf(bio_out, "|");
|
||||
BIO_printf(out, "|");
|
||||
err = 1;
|
||||
}
|
||||
BIO_printf(bio_out, "NO_INPUT");
|
||||
BIO_printf(out, "NO_INPUT");
|
||||
started = 1;
|
||||
}
|
||||
/* Check for unknown flags */
|
||||
@ -174,17 +133,16 @@ static int util_flags(BIO *bio_out, unsigned int flags, const char *indent)
|
||||
~ENGINE_CMD_FLAG_NO_INPUT & ~ENGINE_CMD_FLAG_INTERNAL;
|
||||
if (flags) {
|
||||
if (started)
|
||||
BIO_printf(bio_out, "|");
|
||||
BIO_printf(bio_out, "<0x%04X>", flags);
|
||||
BIO_printf(out, "|");
|
||||
BIO_printf(out, "<0x%04X>", flags);
|
||||
}
|
||||
if (err)
|
||||
BIO_printf(bio_out, " <illegal flags!>");
|
||||
BIO_printf(bio_out, "\n");
|
||||
BIO_printf(out, " <illegal flags!>");
|
||||
BIO_printf(out, "\n");
|
||||
return 1;
|
||||
}
|
||||
|
||||
static int util_verbose(ENGINE *e, int verbose, BIO *bio_out,
|
||||
const char *indent)
|
||||
static int util_verbose(ENGINE *e, int verbose, BIO *out, const char *indent)
|
||||
{
|
||||
static const int line_wrap = 78;
|
||||
int num;
|
||||
@ -197,16 +155,13 @@ static int util_verbose(ENGINE *e, int verbose, BIO *bio_out,
|
||||
if (!ENGINE_ctrl(e, ENGINE_CTRL_HAS_CTRL_FUNCTION, 0, NULL, NULL) ||
|
||||
((num = ENGINE_ctrl(e, ENGINE_CTRL_GET_FIRST_CMD_TYPE,
|
||||
0, NULL, NULL)) <= 0)) {
|
||||
# if 0
|
||||
BIO_printf(bio_out, "%s<no control commands>\n", indent);
|
||||
# endif
|
||||
return 1;
|
||||
}
|
||||
|
||||
cmds = sk_OPENSSL_STRING_new_null();
|
||||
|
||||
if (!cmds)
|
||||
if (cmds == NULL)
|
||||
goto err;
|
||||
|
||||
do {
|
||||
int len;
|
||||
/* Get the command input flags */
|
||||
@ -218,8 +173,7 @@ static int util_verbose(ENGINE *e, int verbose, BIO *bio_out,
|
||||
if ((len = ENGINE_ctrl(e, ENGINE_CTRL_GET_NAME_LEN_FROM_CMD, num,
|
||||
NULL, NULL)) <= 0)
|
||||
goto err;
|
||||
if ((name = OPENSSL_malloc(len + 1)) == NULL)
|
||||
goto err;
|
||||
name = app_malloc(len + 1, "name buffer");
|
||||
if (ENGINE_ctrl(e, ENGINE_CTRL_GET_NAME_FROM_CMD, num, name,
|
||||
NULL) <= 0)
|
||||
goto err;
|
||||
@ -228,8 +182,7 @@ static int util_verbose(ENGINE *e, int verbose, BIO *bio_out,
|
||||
NULL, NULL)) < 0)
|
||||
goto err;
|
||||
if (len > 0) {
|
||||
if ((desc = OPENSSL_malloc(len + 1)) == NULL)
|
||||
goto err;
|
||||
desc = app_malloc(len + 1, "description buffer");
|
||||
if (ENGINE_ctrl(e, ENGINE_CTRL_GET_DESC_FROM_CMD, num, desc,
|
||||
NULL) <= 0)
|
||||
goto err;
|
||||
@ -237,59 +190,54 @@ static int util_verbose(ENGINE *e, int verbose, BIO *bio_out,
|
||||
/* Now decide on the output */
|
||||
if (xpos == 0)
|
||||
/* Do an indent */
|
||||
xpos = BIO_puts(bio_out, indent);
|
||||
xpos = BIO_puts(out, indent);
|
||||
else
|
||||
/* Otherwise prepend a ", " */
|
||||
xpos += BIO_printf(bio_out, ", ");
|
||||
xpos += BIO_printf(out, ", ");
|
||||
if (verbose == 1) {
|
||||
/*
|
||||
* We're just listing names, comma-delimited
|
||||
*/
|
||||
if ((xpos > (int)strlen(indent)) &&
|
||||
(xpos + (int)strlen(name) > line_wrap)) {
|
||||
BIO_printf(bio_out, "\n");
|
||||
xpos = BIO_puts(bio_out, indent);
|
||||
BIO_printf(out, "\n");
|
||||
xpos = BIO_puts(out, indent);
|
||||
}
|
||||
xpos += BIO_printf(bio_out, "%s", name);
|
||||
xpos += BIO_printf(out, "%s", name);
|
||||
} else {
|
||||
/* We're listing names plus descriptions */
|
||||
BIO_printf(bio_out, "%s: %s\n", name,
|
||||
BIO_printf(out, "%s: %s\n", name,
|
||||
(desc == NULL) ? "<no description>" : desc);
|
||||
/* ... and sometimes input flags */
|
||||
if ((verbose >= 3) && !util_flags(bio_out, flags, indent))
|
||||
if ((verbose >= 3) && !util_flags(out, flags, indent))
|
||||
goto err;
|
||||
xpos = 0;
|
||||
}
|
||||
}
|
||||
OPENSSL_free(name);
|
||||
name = NULL;
|
||||
if (desc) {
|
||||
OPENSSL_free(desc);
|
||||
desc = NULL;
|
||||
}
|
||||
OPENSSL_free(desc);
|
||||
desc = NULL;
|
||||
/* Move to the next command */
|
||||
num = ENGINE_ctrl(e, ENGINE_CTRL_GET_NEXT_CMD_TYPE, num, NULL, NULL);
|
||||
} while (num > 0);
|
||||
if (xpos > 0)
|
||||
BIO_printf(bio_out, "\n");
|
||||
BIO_printf(out, "\n");
|
||||
ret = 1;
|
||||
err:
|
||||
if (cmds)
|
||||
sk_OPENSSL_STRING_pop_free(cmds, identity);
|
||||
if (name)
|
||||
OPENSSL_free(name);
|
||||
if (desc)
|
||||
OPENSSL_free(desc);
|
||||
sk_OPENSSL_STRING_free(cmds);
|
||||
OPENSSL_free(name);
|
||||
OPENSSL_free(desc);
|
||||
return ret;
|
||||
}
|
||||
|
||||
static void util_do_cmds(ENGINE *e, STACK_OF(OPENSSL_STRING) *cmds,
|
||||
BIO *bio_out, const char *indent)
|
||||
BIO *out, const char *indent)
|
||||
{
|
||||
int loop, res, num = sk_OPENSSL_STRING_num(cmds);
|
||||
|
||||
if (num < 0) {
|
||||
BIO_printf(bio_out, "[Error]: internal stack error\n");
|
||||
BIO_printf(out, "[Error]: internal stack error\n");
|
||||
return;
|
||||
}
|
||||
for (loop = 0; loop < num; loop++) {
|
||||
@ -303,7 +251,7 @@ static void util_do_cmds(ENGINE *e, STACK_OF(OPENSSL_STRING) *cmds,
|
||||
res = 0;
|
||||
} else {
|
||||
if ((int)(arg - cmd) > 254) {
|
||||
BIO_printf(bio_out, "[Error]: command name too long\n");
|
||||
BIO_printf(out, "[Error]: command name too long\n");
|
||||
return;
|
||||
}
|
||||
memcpy(buf, cmd, (int)(arg - cmd));
|
||||
@ -313,109 +261,131 @@ static void util_do_cmds(ENGINE *e, STACK_OF(OPENSSL_STRING) *cmds,
|
||||
if (!ENGINE_ctrl_cmd_string(e, buf, arg, 0))
|
||||
res = 0;
|
||||
}
|
||||
if (res)
|
||||
BIO_printf(bio_out, "[Success]: %s\n", cmd);
|
||||
else {
|
||||
BIO_printf(bio_out, "[Failure]: %s\n", cmd);
|
||||
ERR_print_errors(bio_out);
|
||||
if (res) {
|
||||
BIO_printf(out, "[Success]: %s\n", cmd);
|
||||
} else {
|
||||
BIO_printf(out, "[Failure]: %s\n", cmd);
|
||||
ERR_print_errors(out);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
int MAIN(int, char **);
|
||||
struct util_store_cap_data {
|
||||
ENGINE *engine;
|
||||
char **cap_buf;
|
||||
int *cap_size;
|
||||
int ok;
|
||||
};
|
||||
static void util_store_cap(const OSSL_STORE_LOADER *loader, void *arg)
|
||||
{
|
||||
struct util_store_cap_data *ctx = arg;
|
||||
|
||||
int MAIN(int argc, char **argv)
|
||||
if (OSSL_STORE_LOADER_get0_engine(loader) == ctx->engine) {
|
||||
char buf[256];
|
||||
BIO_snprintf(buf, sizeof(buf), "STORE(%s)",
|
||||
OSSL_STORE_LOADER_get0_scheme(loader));
|
||||
if (!append_buf(ctx->cap_buf, ctx->cap_size, buf))
|
||||
ctx->ok = 0;
|
||||
}
|
||||
}
|
||||
|
||||
int engine_main(int argc, char **argv)
|
||||
{
|
||||
int ret = 1, i;
|
||||
const char **pp;
|
||||
int verbose = 0, list_cap = 0, test_avail = 0, test_avail_noise = 0;
|
||||
ENGINE *e;
|
||||
STACK_OF(OPENSSL_STRING) *engines = sk_OPENSSL_STRING_new_null();
|
||||
STACK_OF(OPENSSL_CSTRING) *engines = sk_OPENSSL_CSTRING_new_null();
|
||||
STACK_OF(OPENSSL_STRING) *pre_cmds = sk_OPENSSL_STRING_new_null();
|
||||
STACK_OF(OPENSSL_STRING) *post_cmds = sk_OPENSSL_STRING_new_null();
|
||||
int badops = 1;
|
||||
BIO *bio_out = NULL;
|
||||
BIO *out;
|
||||
const char *indent = " ";
|
||||
OPTION_CHOICE o;
|
||||
char *prog;
|
||||
char *argv1;
|
||||
|
||||
apps_startup();
|
||||
SSL_load_error_strings();
|
||||
|
||||
if (bio_err == NULL)
|
||||
bio_err = BIO_new_fp(stderr, BIO_NOCLOSE);
|
||||
|
||||
if (!load_config(bio_err, NULL))
|
||||
out = dup_bio_out(FORMAT_TEXT);
|
||||
if (engines == NULL || pre_cmds == NULL || post_cmds == NULL)
|
||||
goto end;
|
||||
bio_out = BIO_new_fp(stdout, BIO_NOCLOSE);
|
||||
# ifdef OPENSSL_SYS_VMS
|
||||
{
|
||||
BIO *tmpbio = BIO_new(BIO_f_linebuffer());
|
||||
bio_out = BIO_push(tmpbio, bio_out);
|
||||
}
|
||||
# endif
|
||||
|
||||
argc--;
|
||||
argv++;
|
||||
while (argc >= 1) {
|
||||
if (strncmp(*argv, "-v", 2) == 0) {
|
||||
if (strspn(*argv + 1, "v") < strlen(*argv + 1))
|
||||
goto skip_arg_loop;
|
||||
if ((verbose = strlen(*argv + 1)) > 4)
|
||||
goto skip_arg_loop;
|
||||
} else if (strcmp(*argv, "-c") == 0)
|
||||
list_cap = 1;
|
||||
else if (strncmp(*argv, "-t", 2) == 0) {
|
||||
test_avail = 1;
|
||||
if (strspn(*argv + 1, "t") < strlen(*argv + 1))
|
||||
goto skip_arg_loop;
|
||||
if ((test_avail_noise = strlen(*argv + 1) - 1) > 1)
|
||||
goto skip_arg_loop;
|
||||
} else if (strcmp(*argv, "-pre") == 0) {
|
||||
argc--;
|
||||
argv++;
|
||||
if (argc == 0)
|
||||
goto skip_arg_loop;
|
||||
sk_OPENSSL_STRING_push(pre_cmds, *argv);
|
||||
} else if (strcmp(*argv, "-post") == 0) {
|
||||
argc--;
|
||||
argv++;
|
||||
if (argc == 0)
|
||||
goto skip_arg_loop;
|
||||
sk_OPENSSL_STRING_push(post_cmds, *argv);
|
||||
} else if ((strncmp(*argv, "-h", 2) == 0) ||
|
||||
(strcmp(*argv, "-?") == 0))
|
||||
goto skip_arg_loop;
|
||||
else
|
||||
sk_OPENSSL_STRING_push(engines, *argv);
|
||||
/* Remember the original command name, parse/skip any leading engine
|
||||
* names, and then setup to parse the rest of the line as flags. */
|
||||
prog = argv[0];
|
||||
while ((argv1 = argv[1]) != NULL && *argv1 != '-') {
|
||||
sk_OPENSSL_CSTRING_push(engines, argv1);
|
||||
argc--;
|
||||
argv++;
|
||||
}
|
||||
/* Looks like everything went OK */
|
||||
badops = 0;
|
||||
skip_arg_loop:
|
||||
argv[0] = prog;
|
||||
opt_init(argc, argv, engine_options);
|
||||
|
||||
if (badops) {
|
||||
for (pp = engine_usage; (*pp != NULL); pp++)
|
||||
BIO_printf(bio_err, "%s", *pp);
|
||||
goto end;
|
||||
}
|
||||
|
||||
if (sk_OPENSSL_STRING_num(engines) == 0) {
|
||||
for (e = ENGINE_get_first(); e != NULL; e = ENGINE_get_next(e)) {
|
||||
sk_OPENSSL_STRING_push(engines, (char *)ENGINE_get_id(e));
|
||||
while ((o = opt_next()) != OPT_EOF) {
|
||||
switch (o) {
|
||||
case OPT_EOF:
|
||||
case OPT_ERR:
|
||||
BIO_printf(bio_err, "%s: Use -help for summary.\n", prog);
|
||||
goto end;
|
||||
case OPT_HELP:
|
||||
opt_help(engine_options);
|
||||
ret = 0;
|
||||
goto end;
|
||||
case OPT_VVVV:
|
||||
case OPT_VVV:
|
||||
case OPT_VV:
|
||||
case OPT_V:
|
||||
/* Convert to an integer from one to four. */
|
||||
i = (int)(o - OPT_V) + 1;
|
||||
if (verbose < i)
|
||||
verbose = i;
|
||||
break;
|
||||
case OPT_C:
|
||||
list_cap = 1;
|
||||
break;
|
||||
case OPT_TT:
|
||||
test_avail_noise++;
|
||||
/* fall thru */
|
||||
case OPT_T:
|
||||
test_avail++;
|
||||
break;
|
||||
case OPT_PRE:
|
||||
sk_OPENSSL_STRING_push(pre_cmds, opt_arg());
|
||||
break;
|
||||
case OPT_POST:
|
||||
sk_OPENSSL_STRING_push(post_cmds, opt_arg());
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
for (i = 0; i < sk_OPENSSL_STRING_num(engines); i++) {
|
||||
const char *id = sk_OPENSSL_STRING_value(engines, i);
|
||||
/* Allow any trailing parameters as engine names. */
|
||||
argc = opt_num_rest();
|
||||
argv = opt_rest();
|
||||
for ( ; *argv; argv++) {
|
||||
if (**argv == '-') {
|
||||
BIO_printf(bio_err, "%s: Cannot mix flags and engine names.\n",
|
||||
prog);
|
||||
BIO_printf(bio_err, "%s: Use -help for summary.\n", prog);
|
||||
goto end;
|
||||
}
|
||||
sk_OPENSSL_CSTRING_push(engines, *argv);
|
||||
}
|
||||
|
||||
if (sk_OPENSSL_CSTRING_num(engines) == 0) {
|
||||
for (e = ENGINE_get_first(); e != NULL; e = ENGINE_get_next(e)) {
|
||||
sk_OPENSSL_CSTRING_push(engines, ENGINE_get_id(e));
|
||||
}
|
||||
}
|
||||
|
||||
ret = 0;
|
||||
for (i = 0; i < sk_OPENSSL_CSTRING_num(engines); i++) {
|
||||
const char *id = sk_OPENSSL_CSTRING_value(engines, i);
|
||||
if ((e = ENGINE_by_id(id)) != NULL) {
|
||||
const char *name = ENGINE_get_name(e);
|
||||
/*
|
||||
* Do "id" first, then "name". Easier to auto-parse.
|
||||
*/
|
||||
BIO_printf(bio_out, "(%s) %s\n", id, name);
|
||||
util_do_cmds(e, pre_cmds, bio_out, indent);
|
||||
BIO_printf(out, "(%s) %s\n", id, name);
|
||||
util_do_cmds(e, pre_cmds, out, indent);
|
||||
if (strcmp(ENGINE_get_id(e), id) != 0) {
|
||||
BIO_printf(bio_out, "Loaded: (%s) %s\n",
|
||||
BIO_printf(out, "Loaded: (%s) %s\n",
|
||||
ENGINE_get_id(e), ENGINE_get_name(e));
|
||||
}
|
||||
if (list_cap) {
|
||||
@ -428,88 +398,92 @@ int MAIN(int argc, char **argv)
|
||||
ENGINE_PKEY_METHS_PTR fn_pk;
|
||||
|
||||
if (ENGINE_get_RSA(e) != NULL
|
||||
&& !append_buf(&cap_buf, "RSA", &cap_size, 256))
|
||||
&& !append_buf(&cap_buf, &cap_size, "RSA"))
|
||||
goto end;
|
||||
if (ENGINE_get_DSA(e) != NULL
|
||||
&& !append_buf(&cap_buf, "DSA", &cap_size, 256))
|
||||
&& !append_buf(&cap_buf, &cap_size, "DSA"))
|
||||
goto end;
|
||||
if (ENGINE_get_DH(e) != NULL
|
||||
&& !append_buf(&cap_buf, "DH", &cap_size, 256))
|
||||
&& !append_buf(&cap_buf, &cap_size, "DH"))
|
||||
goto end;
|
||||
if (ENGINE_get_RAND(e) != NULL
|
||||
&& !append_buf(&cap_buf, "RAND", &cap_size, 256))
|
||||
&& !append_buf(&cap_buf, &cap_size, "RAND"))
|
||||
goto end;
|
||||
|
||||
fn_c = ENGINE_get_ciphers(e);
|
||||
if (!fn_c)
|
||||
if (fn_c == NULL)
|
||||
goto skip_ciphers;
|
||||
n = fn_c(e, NULL, &nids, 0);
|
||||
for (k = 0; k < n; ++k)
|
||||
if (!append_buf(&cap_buf,
|
||||
OBJ_nid2sn(nids[k]), &cap_size, 256))
|
||||
if (!append_buf(&cap_buf, &cap_size, OBJ_nid2sn(nids[k])))
|
||||
goto end;
|
||||
|
||||
skip_ciphers:
|
||||
fn_d = ENGINE_get_digests(e);
|
||||
if (!fn_d)
|
||||
if (fn_d == NULL)
|
||||
goto skip_digests;
|
||||
n = fn_d(e, NULL, &nids, 0);
|
||||
for (k = 0; k < n; ++k)
|
||||
if (!append_buf(&cap_buf,
|
||||
OBJ_nid2sn(nids[k]), &cap_size, 256))
|
||||
if (!append_buf(&cap_buf, &cap_size, OBJ_nid2sn(nids[k])))
|
||||
goto end;
|
||||
|
||||
skip_digests:
|
||||
fn_pk = ENGINE_get_pkey_meths(e);
|
||||
if (!fn_pk)
|
||||
if (fn_pk == NULL)
|
||||
goto skip_pmeths;
|
||||
n = fn_pk(e, NULL, &nids, 0);
|
||||
for (k = 0; k < n; ++k)
|
||||
if (!append_buf(&cap_buf,
|
||||
OBJ_nid2sn(nids[k]), &cap_size, 256))
|
||||
if (!append_buf(&cap_buf, &cap_size, OBJ_nid2sn(nids[k])))
|
||||
goto end;
|
||||
skip_pmeths:
|
||||
if (cap_buf && (*cap_buf != '\0'))
|
||||
BIO_printf(bio_out, " [%s]\n", cap_buf);
|
||||
{
|
||||
struct util_store_cap_data store_ctx;
|
||||
|
||||
store_ctx.engine = e;
|
||||
store_ctx.cap_buf = &cap_buf;
|
||||
store_ctx.cap_size = &cap_size;
|
||||
store_ctx.ok = 1;
|
||||
|
||||
OSSL_STORE_do_all_loaders(util_store_cap, &store_ctx);
|
||||
if (!store_ctx.ok)
|
||||
goto end;
|
||||
}
|
||||
if (cap_buf != NULL && (*cap_buf != '\0'))
|
||||
BIO_printf(out, " [%s]\n", cap_buf);
|
||||
|
||||
OPENSSL_free(cap_buf);
|
||||
}
|
||||
if (test_avail) {
|
||||
BIO_printf(bio_out, "%s", indent);
|
||||
BIO_printf(out, "%s", indent);
|
||||
if (ENGINE_init(e)) {
|
||||
BIO_printf(bio_out, "[ available ]\n");
|
||||
util_do_cmds(e, post_cmds, bio_out, indent);
|
||||
BIO_printf(out, "[ available ]\n");
|
||||
util_do_cmds(e, post_cmds, out, indent);
|
||||
ENGINE_finish(e);
|
||||
} else {
|
||||
BIO_printf(bio_out, "[ unavailable ]\n");
|
||||
BIO_printf(out, "[ unavailable ]\n");
|
||||
if (test_avail_noise)
|
||||
ERR_print_errors_fp(stdout);
|
||||
ERR_clear_error();
|
||||
}
|
||||
}
|
||||
if ((verbose > 0) && !util_verbose(e, verbose, bio_out, indent))
|
||||
if ((verbose > 0) && !util_verbose(e, verbose, out, indent))
|
||||
goto end;
|
||||
ENGINE_free(e);
|
||||
} else
|
||||
} else {
|
||||
ERR_print_errors(bio_err);
|
||||
/* because exit codes above 127 have special meaning on Unix */
|
||||
if (++ret > 127)
|
||||
ret = 127;
|
||||
}
|
||||
}
|
||||
|
||||
ret = 0;
|
||||
end:
|
||||
|
||||
ERR_print_errors(bio_err);
|
||||
sk_OPENSSL_STRING_pop_free(engines, identity);
|
||||
sk_OPENSSL_STRING_pop_free(pre_cmds, identity);
|
||||
sk_OPENSSL_STRING_pop_free(post_cmds, identity);
|
||||
if (bio_out != NULL)
|
||||
BIO_free_all(bio_out);
|
||||
apps_shutdown();
|
||||
OPENSSL_EXIT(ret);
|
||||
sk_OPENSSL_CSTRING_free(engines);
|
||||
sk_OPENSSL_STRING_free(pre_cmds);
|
||||
sk_OPENSSL_STRING_free(post_cmds);
|
||||
BIO_free_all(out);
|
||||
return ret;
|
||||
}
|
||||
#else
|
||||
|
||||
# if PEDANTIC
|
||||
static void *dummy = &dummy;
|
||||
# endif
|
||||
|
||||
#endif
|
||||
|
@ -1,121 +1,67 @@
|
||||
/* apps/errstr.c */
|
||||
/* Copyright (C) 1995-1998 Eric Young (eay@cryptsoft.com)
|
||||
* All rights reserved.
|
||||
/*
|
||||
* Copyright 1995-2018 The OpenSSL Project Authors. All Rights Reserved.
|
||||
*
|
||||
* This package is an SSL implementation written
|
||||
* by Eric Young (eay@cryptsoft.com).
|
||||
* The implementation was written so as to conform with Netscapes SSL.
|
||||
*
|
||||
* This library is free for commercial and non-commercial use as long as
|
||||
* the following conditions are aheared to. The following conditions
|
||||
* apply to all code found in this distribution, be it the RC4, RSA,
|
||||
* lhash, DES, etc., code; not just the SSL code. The SSL documentation
|
||||
* included with this distribution is covered by the same copyright terms
|
||||
* except that the holder is Tim Hudson (tjh@cryptsoft.com).
|
||||
*
|
||||
* Copyright remains Eric Young's, and as such any Copyright notices in
|
||||
* the code are not to be removed.
|
||||
* If this package is used in a product, Eric Young should be given attribution
|
||||
* as the author of the parts of the library used.
|
||||
* This can be in the form of a textual message at program startup or
|
||||
* in documentation (online or textual) provided with the package.
|
||||
*
|
||||
* Redistribution and use in source and binary forms, with or without
|
||||
* modification, are permitted provided that the following conditions
|
||||
* are met:
|
||||
* 1. Redistributions of source code must retain the copyright
|
||||
* notice, this list of conditions and the following disclaimer.
|
||||
* 2. Redistributions in binary form must reproduce the above copyright
|
||||
* notice, this list of conditions and the following disclaimer in the
|
||||
* documentation and/or other materials provided with the distribution.
|
||||
* 3. All advertising materials mentioning features or use of this software
|
||||
* must display the following acknowledgement:
|
||||
* "This product includes cryptographic software written by
|
||||
* Eric Young (eay@cryptsoft.com)"
|
||||
* The word 'cryptographic' can be left out if the rouines from the library
|
||||
* being used are not cryptographic related :-).
|
||||
* 4. If you include any Windows specific code (or a derivative thereof) from
|
||||
* the apps directory (application code) you must include an acknowledgement:
|
||||
* "This product includes software written by Tim Hudson (tjh@cryptsoft.com)"
|
||||
*
|
||||
* THIS SOFTWARE IS PROVIDED BY ERIC YOUNG ``AS IS'' AND
|
||||
* ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
|
||||
* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
|
||||
* ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE
|
||||
* FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
|
||||
* DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
|
||||
* OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
|
||||
* HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
|
||||
* LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
|
||||
* OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
|
||||
* SUCH DAMAGE.
|
||||
*
|
||||
* The licence and distribution terms for any publically available version or
|
||||
* derivative of this code cannot be changed. i.e. this code cannot simply be
|
||||
* copied and put under another distribution licence
|
||||
* [including the GNU Public Licence.]
|
||||
* Licensed under the OpenSSL license (the "License"). You may not use
|
||||
* this file except in compliance with the License. You can obtain a copy
|
||||
* in the file LICENSE in the source distribution or at
|
||||
* https://www.openssl.org/source/license.html
|
||||
*/
|
||||
|
||||
#include <stdio.h>
|
||||
#include <stdlib.h>
|
||||
#include <string.h>
|
||||
#include "apps.h"
|
||||
#include "progs.h"
|
||||
#include <openssl/bio.h>
|
||||
#include <openssl/lhash.h>
|
||||
#include <openssl/err.h>
|
||||
#include <openssl/ssl.h>
|
||||
|
||||
#undef PROG
|
||||
#define PROG errstr_main
|
||||
typedef enum OPTION_choice {
|
||||
OPT_ERR = -1, OPT_EOF = 0, OPT_HELP
|
||||
} OPTION_CHOICE;
|
||||
|
||||
int MAIN(int, char **);
|
||||
const OPTIONS errstr_options[] = {
|
||||
{OPT_HELP_STR, 1, '-', "Usage: %s [options] errnum...\n"},
|
||||
{OPT_HELP_STR, 1, '-', " errnum Error number\n"},
|
||||
{"help", OPT_HELP, '-', "Display this summary"},
|
||||
{NULL}
|
||||
};
|
||||
|
||||
int MAIN(int argc, char **argv)
|
||||
int errstr_main(int argc, char **argv)
|
||||
{
|
||||
int i, ret = 0;
|
||||
char buf[256];
|
||||
OPTION_CHOICE o;
|
||||
char buf[256], *prog;
|
||||
int ret = 1;
|
||||
unsigned long l;
|
||||
|
||||
apps_startup();
|
||||
|
||||
if (bio_err == NULL)
|
||||
if ((bio_err = BIO_new(BIO_s_file())) != NULL)
|
||||
BIO_set_fp(bio_err, stderr, BIO_NOCLOSE | BIO_FP_TEXT);
|
||||
|
||||
SSL_load_error_strings();
|
||||
|
||||
if ((argc > 1) && (strcmp(argv[1], "-stats") == 0)) {
|
||||
BIO *out = NULL;
|
||||
|
||||
out = BIO_new(BIO_s_file());
|
||||
if ((out != NULL) && BIO_set_fp(out, stdout, BIO_NOCLOSE)) {
|
||||
#ifdef OPENSSL_SYS_VMS
|
||||
{
|
||||
BIO *tmpbio = BIO_new(BIO_f_linebuffer());
|
||||
out = BIO_push(tmpbio, out);
|
||||
}
|
||||
#endif
|
||||
lh_ERR_STRING_DATA_node_stats_bio(ERR_get_string_table(), out);
|
||||
lh_ERR_STRING_DATA_stats_bio(ERR_get_string_table(), out);
|
||||
lh_ERR_STRING_DATA_node_usage_stats_bio(ERR_get_string_table(),
|
||||
out);
|
||||
prog = opt_init(argc, argv, errstr_options);
|
||||
while ((o = opt_next()) != OPT_EOF) {
|
||||
switch (o) {
|
||||
case OPT_EOF:
|
||||
case OPT_ERR:
|
||||
BIO_printf(bio_err, "%s: Use -help for summary.\n", prog);
|
||||
goto end;
|
||||
case OPT_HELP:
|
||||
opt_help(errstr_options);
|
||||
ret = 0;
|
||||
goto end;
|
||||
}
|
||||
if (out != NULL)
|
||||
BIO_free_all(out);
|
||||
argc--;
|
||||
argv++;
|
||||
}
|
||||
|
||||
for (i = 1; i < argc; i++) {
|
||||
if (sscanf(argv[i], "%lx", &l)) {
|
||||
ERR_error_string_n(l, buf, sizeof(buf));
|
||||
printf("%s\n", buf);
|
||||
} else {
|
||||
printf("%s: bad error code\n", argv[i]);
|
||||
printf("usage: errstr [-stats] <errno> ...\n");
|
||||
ret = 0;
|
||||
for (argv = opt_rest(); *argv; argv++) {
|
||||
if (sscanf(*argv, "%lx", &l) == 0) {
|
||||
ret++;
|
||||
} else {
|
||||
/* We're not really an SSL application so this won't auto-init, but
|
||||
* we're still interested in SSL error strings
|
||||
*/
|
||||
OPENSSL_init_ssl(OPENSSL_INIT_LOAD_SSL_STRINGS
|
||||
| OPENSSL_INIT_LOAD_CRYPTO_STRINGS, NULL);
|
||||
ERR_error_string_n(l, buf, sizeof(buf));
|
||||
BIO_printf(bio_out, "%s\n", buf);
|
||||
}
|
||||
}
|
||||
apps_shutdown();
|
||||
OPENSSL_EXIT(ret);
|
||||
end:
|
||||
return ret;
|
||||
}
|
||||
|
@ -1,244 +0,0 @@
|
||||
/* apps/gendh.c */
|
||||
/* obsoleted by dhparam.c */
|
||||
/* Copyright (C) 1995-1998 Eric Young (eay@cryptsoft.com)
|
||||
* All rights reserved.
|
||||
*
|
||||
* This package is an SSL implementation written
|
||||
* by Eric Young (eay@cryptsoft.com).
|
||||
* The implementation was written so as to conform with Netscapes SSL.
|
||||
*
|
||||
* This library is free for commercial and non-commercial use as long as
|
||||
* the following conditions are aheared to. The following conditions
|
||||
* apply to all code found in this distribution, be it the RC4, RSA,
|
||||
* lhash, DES, etc., code; not just the SSL code. The SSL documentation
|
||||
* included with this distribution is covered by the same copyright terms
|
||||
* except that the holder is Tim Hudson (tjh@cryptsoft.com).
|
||||
*
|
||||
* Copyright remains Eric Young's, and as such any Copyright notices in
|
||||
* the code are not to be removed.
|
||||
* If this package is used in a product, Eric Young should be given attribution
|
||||
* as the author of the parts of the library used.
|
||||
* This can be in the form of a textual message at program startup or
|
||||
* in documentation (online or textual) provided with the package.
|
||||
*
|
||||
* Redistribution and use in source and binary forms, with or without
|
||||
* modification, are permitted provided that the following conditions
|
||||
* are met:
|
||||
* 1. Redistributions of source code must retain the copyright
|
||||
* notice, this list of conditions and the following disclaimer.
|
||||
* 2. Redistributions in binary form must reproduce the above copyright
|
||||
* notice, this list of conditions and the following disclaimer in the
|
||||
* documentation and/or other materials provided with the distribution.
|
||||
* 3. All advertising materials mentioning features or use of this software
|
||||
* must display the following acknowledgement:
|
||||
* "This product includes cryptographic software written by
|
||||
* Eric Young (eay@cryptsoft.com)"
|
||||
* The word 'cryptographic' can be left out if the rouines from the library
|
||||
* being used are not cryptographic related :-).
|
||||
* 4. If you include any Windows specific code (or a derivative thereof) from
|
||||
* the apps directory (application code) you must include an acknowledgement:
|
||||
* "This product includes software written by Tim Hudson (tjh@cryptsoft.com)"
|
||||
*
|
||||
* THIS SOFTWARE IS PROVIDED BY ERIC YOUNG ``AS IS'' AND
|
||||
* ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
|
||||
* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
|
||||
* ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE
|
||||
* FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
|
||||
* DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
|
||||
* OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
|
||||
* HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
|
||||
* LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
|
||||
* OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
|
||||
* SUCH DAMAGE.
|
||||
*
|
||||
* The licence and distribution terms for any publically available version or
|
||||
* derivative of this code cannot be changed. i.e. this code cannot simply be
|
||||
* copied and put under another distribution licence
|
||||
* [including the GNU Public Licence.]
|
||||
*/
|
||||
|
||||
#include <openssl/opensslconf.h>
|
||||
/*
|
||||
* Until the key-gen callbacks are modified to use newer prototypes, we allow
|
||||
* deprecated functions for openssl-internal code
|
||||
*/
|
||||
#ifdef OPENSSL_NO_DEPRECATED
|
||||
# undef OPENSSL_NO_DEPRECATED
|
||||
#endif
|
||||
|
||||
#ifndef OPENSSL_NO_DH
|
||||
# include <stdio.h>
|
||||
# include <string.h>
|
||||
# include <sys/types.h>
|
||||
# include <sys/stat.h>
|
||||
# include "apps.h"
|
||||
# include <openssl/bio.h>
|
||||
# include <openssl/rand.h>
|
||||
# include <openssl/err.h>
|
||||
# include <openssl/bn.h>
|
||||
# include <openssl/dh.h>
|
||||
# include <openssl/x509.h>
|
||||
# include <openssl/pem.h>
|
||||
|
||||
# define DEFBITS 2048
|
||||
# undef PROG
|
||||
# define PROG gendh_main
|
||||
|
||||
static int MS_CALLBACK dh_cb(int p, int n, BN_GENCB *cb);
|
||||
|
||||
int MAIN(int, char **);
|
||||
|
||||
int MAIN(int argc, char **argv)
|
||||
{
|
||||
BN_GENCB cb;
|
||||
DH *dh = NULL;
|
||||
int ret = 1, num = DEFBITS;
|
||||
int g = 2;
|
||||
char *outfile = NULL;
|
||||
char *inrand = NULL;
|
||||
char *engine = NULL;
|
||||
BIO *out = NULL;
|
||||
|
||||
apps_startup();
|
||||
|
||||
BN_GENCB_set(&cb, dh_cb, bio_err);
|
||||
if (bio_err == NULL)
|
||||
if ((bio_err = BIO_new(BIO_s_file())) != NULL)
|
||||
BIO_set_fp(bio_err, stderr, BIO_NOCLOSE | BIO_FP_TEXT);
|
||||
|
||||
if (!load_config(bio_err, NULL))
|
||||
goto end;
|
||||
|
||||
argv++;
|
||||
argc--;
|
||||
for (;;) {
|
||||
if (argc <= 0)
|
||||
break;
|
||||
if (strcmp(*argv, "-out") == 0) {
|
||||
if (--argc < 1)
|
||||
goto bad;
|
||||
outfile = *(++argv);
|
||||
} else if (strcmp(*argv, "-2") == 0)
|
||||
g = 2;
|
||||
/*- else if (strcmp(*argv,"-3") == 0)
|
||||
g=3; */
|
||||
else if (strcmp(*argv, "-5") == 0)
|
||||
g = 5;
|
||||
# ifndef OPENSSL_NO_ENGINE
|
||||
else if (strcmp(*argv, "-engine") == 0) {
|
||||
if (--argc < 1)
|
||||
goto bad;
|
||||
engine = *(++argv);
|
||||
}
|
||||
# endif
|
||||
else if (strcmp(*argv, "-rand") == 0) {
|
||||
if (--argc < 1)
|
||||
goto bad;
|
||||
inrand = *(++argv);
|
||||
} else
|
||||
break;
|
||||
argv++;
|
||||
argc--;
|
||||
}
|
||||
if ((argc >= 1) && ((sscanf(*argv, "%d", &num) == 0) || (num < 0))) {
|
||||
bad:
|
||||
BIO_printf(bio_err, "usage: gendh [args] [numbits]\n");
|
||||
BIO_printf(bio_err, " -out file - output the key to 'file\n");
|
||||
BIO_printf(bio_err, " -2 - use 2 as the generator value\n");
|
||||
/*
|
||||
* BIO_printf(bio_err," -3 - use 3 as the generator value\n");
|
||||
*/
|
||||
BIO_printf(bio_err, " -5 - use 5 as the generator value\n");
|
||||
# ifndef OPENSSL_NO_ENGINE
|
||||
BIO_printf(bio_err,
|
||||
" -engine e - use engine e, possibly a hardware device.\n");
|
||||
# endif
|
||||
BIO_printf(bio_err, " -rand file%cfile%c...\n", LIST_SEPARATOR_CHAR,
|
||||
LIST_SEPARATOR_CHAR);
|
||||
BIO_printf(bio_err,
|
||||
" - load the file (or the files in the directory) into\n");
|
||||
BIO_printf(bio_err, " the random number generator\n");
|
||||
goto end;
|
||||
}
|
||||
setup_engine(bio_err, engine, 0);
|
||||
|
||||
out = BIO_new(BIO_s_file());
|
||||
if (out == NULL) {
|
||||
ERR_print_errors(bio_err);
|
||||
goto end;
|
||||
}
|
||||
|
||||
if (outfile == NULL) {
|
||||
BIO_set_fp(out, stdout, BIO_NOCLOSE);
|
||||
# ifdef OPENSSL_SYS_VMS
|
||||
{
|
||||
BIO *tmpbio = BIO_new(BIO_f_linebuffer());
|
||||
out = BIO_push(tmpbio, out);
|
||||
}
|
||||
# endif
|
||||
} else {
|
||||
if (BIO_write_filename(out, outfile) <= 0) {
|
||||
perror(outfile);
|
||||
goto end;
|
||||
}
|
||||
}
|
||||
|
||||
if (!app_RAND_load_file(NULL, bio_err, 1) && inrand == NULL) {
|
||||
BIO_printf(bio_err,
|
||||
"warning, not much extra random data, consider using the -rand option\n");
|
||||
}
|
||||
if (inrand != NULL)
|
||||
BIO_printf(bio_err, "%ld semi-random bytes loaded\n",
|
||||
app_RAND_load_files(inrand));
|
||||
|
||||
BIO_printf(bio_err,
|
||||
"Generating DH parameters, %d bit long safe prime, generator %d\n",
|
||||
num, g);
|
||||
BIO_printf(bio_err, "This is going to take a long time\n");
|
||||
|
||||
if (((dh = DH_new()) == NULL)
|
||||
|| !DH_generate_parameters_ex(dh, num, g, &cb))
|
||||
goto end;
|
||||
|
||||
app_RAND_write_file(NULL, bio_err);
|
||||
|
||||
if (!PEM_write_bio_DHparams(out, dh))
|
||||
goto end;
|
||||
ret = 0;
|
||||
end:
|
||||
if (ret != 0)
|
||||
ERR_print_errors(bio_err);
|
||||
if (out != NULL)
|
||||
BIO_free_all(out);
|
||||
if (dh != NULL)
|
||||
DH_free(dh);
|
||||
apps_shutdown();
|
||||
OPENSSL_EXIT(ret);
|
||||
}
|
||||
|
||||
static int MS_CALLBACK dh_cb(int p, int n, BN_GENCB *cb)
|
||||
{
|
||||
char c = '*';
|
||||
|
||||
if (p == 0)
|
||||
c = '.';
|
||||
if (p == 1)
|
||||
c = '+';
|
||||
if (p == 2)
|
||||
c = '*';
|
||||
if (p == 3)
|
||||
c = '\n';
|
||||
BIO_write(cb->arg, &c, 1);
|
||||
(void)BIO_flush(cb->arg);
|
||||
# ifdef LINT
|
||||
p = n;
|
||||
# endif
|
||||
return 1;
|
||||
}
|
||||
#else /* !OPENSSL_NO_DH */
|
||||
|
||||
# if PEDANTIC
|
||||
static void *dummy = &dummy;
|
||||
# endif
|
||||
|
||||
#endif
|
@ -1,68 +1,23 @@
|
||||
/* apps/gendsa.c */
|
||||
/* Copyright (C) 1995-1998 Eric Young (eay@cryptsoft.com)
|
||||
* All rights reserved.
|
||||
/*
|
||||
* Copyright 1995-2018 The OpenSSL Project Authors. All Rights Reserved.
|
||||
*
|
||||
* This package is an SSL implementation written
|
||||
* by Eric Young (eay@cryptsoft.com).
|
||||
* The implementation was written so as to conform with Netscapes SSL.
|
||||
*
|
||||
* This library is free for commercial and non-commercial use as long as
|
||||
* the following conditions are aheared to. The following conditions
|
||||
* apply to all code found in this distribution, be it the RC4, RSA,
|
||||
* lhash, DES, etc., code; not just the SSL code. The SSL documentation
|
||||
* included with this distribution is covered by the same copyright terms
|
||||
* except that the holder is Tim Hudson (tjh@cryptsoft.com).
|
||||
*
|
||||
* Copyright remains Eric Young's, and as such any Copyright notices in
|
||||
* the code are not to be removed.
|
||||
* If this package is used in a product, Eric Young should be given attribution
|
||||
* as the author of the parts of the library used.
|
||||
* This can be in the form of a textual message at program startup or
|
||||
* in documentation (online or textual) provided with the package.
|
||||
*
|
||||
* Redistribution and use in source and binary forms, with or without
|
||||
* modification, are permitted provided that the following conditions
|
||||
* are met:
|
||||
* 1. Redistributions of source code must retain the copyright
|
||||
* notice, this list of conditions and the following disclaimer.
|
||||
* 2. Redistributions in binary form must reproduce the above copyright
|
||||
* notice, this list of conditions and the following disclaimer in the
|
||||
* documentation and/or other materials provided with the distribution.
|
||||
* 3. All advertising materials mentioning features or use of this software
|
||||
* must display the following acknowledgement:
|
||||
* "This product includes cryptographic software written by
|
||||
* Eric Young (eay@cryptsoft.com)"
|
||||
* The word 'cryptographic' can be left out if the rouines from the library
|
||||
* being used are not cryptographic related :-).
|
||||
* 4. If you include any Windows specific code (or a derivative thereof) from
|
||||
* the apps directory (application code) you must include an acknowledgement:
|
||||
* "This product includes software written by Tim Hudson (tjh@cryptsoft.com)"
|
||||
*
|
||||
* THIS SOFTWARE IS PROVIDED BY ERIC YOUNG ``AS IS'' AND
|
||||
* ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
|
||||
* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
|
||||
* ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE
|
||||
* FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
|
||||
* DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
|
||||
* OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
|
||||
* HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
|
||||
* LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
|
||||
* OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
|
||||
* SUCH DAMAGE.
|
||||
*
|
||||
* The licence and distribution terms for any publically available version or
|
||||
* derivative of this code cannot be changed. i.e. this code cannot simply be
|
||||
* copied and put under another distribution licence
|
||||
* [including the GNU Public Licence.]
|
||||
* Licensed under the OpenSSL license (the "License"). You may not use
|
||||
* this file except in compliance with the License. You can obtain a copy
|
||||
* in the file LICENSE in the source distribution or at
|
||||
* https://www.openssl.org/source/license.html
|
||||
*/
|
||||
|
||||
#include <openssl/opensslconf.h> /* for OPENSSL_NO_DSA */
|
||||
#ifndef OPENSSL_NO_DSA
|
||||
#include <openssl/opensslconf.h>
|
||||
#ifdef OPENSSL_NO_DSA
|
||||
NON_EMPTY_TRANSLATION_UNIT
|
||||
#else
|
||||
|
||||
# include <stdio.h>
|
||||
# include <string.h>
|
||||
# include <sys/types.h>
|
||||
# include <sys/stat.h>
|
||||
# include "apps.h"
|
||||
# include "progs.h"
|
||||
# include <openssl/bio.h>
|
||||
# include <openssl/err.h>
|
||||
# include <openssl/bn.h>
|
||||
@ -70,153 +25,85 @@
|
||||
# include <openssl/x509.h>
|
||||
# include <openssl/pem.h>
|
||||
|
||||
# define DEFBITS 512
|
||||
# undef PROG
|
||||
# define PROG gendsa_main
|
||||
typedef enum OPTION_choice {
|
||||
OPT_ERR = -1, OPT_EOF = 0, OPT_HELP,
|
||||
OPT_OUT, OPT_PASSOUT, OPT_ENGINE, OPT_CIPHER,
|
||||
OPT_R_ENUM
|
||||
} OPTION_CHOICE;
|
||||
|
||||
int MAIN(int, char **);
|
||||
const OPTIONS gendsa_options[] = {
|
||||
{OPT_HELP_STR, 1, '-', "Usage: %s [args] dsaparam-file\n"},
|
||||
{OPT_HELP_STR, 1, '-', "Valid options are:\n"},
|
||||
{"help", OPT_HELP, '-', "Display this summary"},
|
||||
{"out", OPT_OUT, '>', "Output the key to the specified file"},
|
||||
{"passout", OPT_PASSOUT, 's', "Output file pass phrase source"},
|
||||
OPT_R_OPTIONS,
|
||||
{"", OPT_CIPHER, '-', "Encrypt the output with any supported cipher"},
|
||||
# ifndef OPENSSL_NO_ENGINE
|
||||
{"engine", OPT_ENGINE, 's', "Use engine, possibly a hardware device"},
|
||||
# endif
|
||||
{NULL}
|
||||
};
|
||||
|
||||
int MAIN(int argc, char **argv)
|
||||
int gendsa_main(int argc, char **argv)
|
||||
{
|
||||
DSA *dsa = NULL;
|
||||
int ret = 1;
|
||||
char *outfile = NULL;
|
||||
char *inrand = NULL, *dsaparams = NULL;
|
||||
char *passargout = NULL, *passout = NULL;
|
||||
BIO *out = NULL, *in = NULL;
|
||||
const EVP_CIPHER *enc = NULL;
|
||||
char *engine = NULL;
|
||||
ENGINE *e = NULL;
|
||||
BIO *out = NULL, *in = NULL;
|
||||
DSA *dsa = NULL;
|
||||
const EVP_CIPHER *enc = NULL;
|
||||
char *dsaparams = NULL;
|
||||
char *outfile = NULL, *passoutarg = NULL, *passout = NULL, *prog;
|
||||
OPTION_CHOICE o;
|
||||
int ret = 1, private = 0;
|
||||
const BIGNUM *p = NULL;
|
||||
|
||||
apps_startup();
|
||||
|
||||
if (bio_err == NULL)
|
||||
if ((bio_err = BIO_new(BIO_s_file())) != NULL)
|
||||
BIO_set_fp(bio_err, stderr, BIO_NOCLOSE | BIO_FP_TEXT);
|
||||
|
||||
if (!load_config(bio_err, NULL))
|
||||
goto end;
|
||||
|
||||
argv++;
|
||||
argc--;
|
||||
for (;;) {
|
||||
if (argc <= 0)
|
||||
prog = opt_init(argc, argv, gendsa_options);
|
||||
while ((o = opt_next()) != OPT_EOF) {
|
||||
switch (o) {
|
||||
case OPT_EOF:
|
||||
case OPT_ERR:
|
||||
opthelp:
|
||||
BIO_printf(bio_err, "%s: Use -help for summary.\n", prog);
|
||||
goto end;
|
||||
case OPT_HELP:
|
||||
ret = 0;
|
||||
opt_help(gendsa_options);
|
||||
goto end;
|
||||
case OPT_OUT:
|
||||
outfile = opt_arg();
|
||||
break;
|
||||
case OPT_PASSOUT:
|
||||
passoutarg = opt_arg();
|
||||
break;
|
||||
case OPT_ENGINE:
|
||||
e = setup_engine(opt_arg(), 0);
|
||||
break;
|
||||
case OPT_R_CASES:
|
||||
if (!opt_rand(o))
|
||||
goto end;
|
||||
break;
|
||||
case OPT_CIPHER:
|
||||
if (!opt_cipher(opt_unknown(), &enc))
|
||||
goto end;
|
||||
break;
|
||||
if (strcmp(*argv, "-out") == 0) {
|
||||
if (--argc < 1)
|
||||
goto bad;
|
||||
outfile = *(++argv);
|
||||
} else if (strcmp(*argv, "-passout") == 0) {
|
||||
if (--argc < 1)
|
||||
goto bad;
|
||||
passargout = *(++argv);
|
||||
}
|
||||
# ifndef OPENSSL_NO_ENGINE
|
||||
else if (strcmp(*argv, "-engine") == 0) {
|
||||
if (--argc < 1)
|
||||
goto bad;
|
||||
engine = *(++argv);
|
||||
}
|
||||
# endif
|
||||
else if (strcmp(*argv, "-rand") == 0) {
|
||||
if (--argc < 1)
|
||||
goto bad;
|
||||
inrand = *(++argv);
|
||||
} else if (strcmp(*argv, "-") == 0)
|
||||
goto bad;
|
||||
# ifndef OPENSSL_NO_DES
|
||||
else if (strcmp(*argv, "-des") == 0)
|
||||
enc = EVP_des_cbc();
|
||||
else if (strcmp(*argv, "-des3") == 0)
|
||||
enc = EVP_des_ede3_cbc();
|
||||
# endif
|
||||
# ifndef OPENSSL_NO_IDEA
|
||||
else if (strcmp(*argv, "-idea") == 0)
|
||||
enc = EVP_idea_cbc();
|
||||
# endif
|
||||
# ifndef OPENSSL_NO_SEED
|
||||
else if (strcmp(*argv, "-seed") == 0)
|
||||
enc = EVP_seed_cbc();
|
||||
# endif
|
||||
# ifndef OPENSSL_NO_AES
|
||||
else if (strcmp(*argv, "-aes128") == 0)
|
||||
enc = EVP_aes_128_cbc();
|
||||
else if (strcmp(*argv, "-aes192") == 0)
|
||||
enc = EVP_aes_192_cbc();
|
||||
else if (strcmp(*argv, "-aes256") == 0)
|
||||
enc = EVP_aes_256_cbc();
|
||||
# endif
|
||||
# ifndef OPENSSL_NO_CAMELLIA
|
||||
else if (strcmp(*argv, "-camellia128") == 0)
|
||||
enc = EVP_camellia_128_cbc();
|
||||
else if (strcmp(*argv, "-camellia192") == 0)
|
||||
enc = EVP_camellia_192_cbc();
|
||||
else if (strcmp(*argv, "-camellia256") == 0)
|
||||
enc = EVP_camellia_256_cbc();
|
||||
# endif
|
||||
else if (**argv != '-' && dsaparams == NULL) {
|
||||
dsaparams = *argv;
|
||||
} else
|
||||
goto bad;
|
||||
argv++;
|
||||
argc--;
|
||||
}
|
||||
argc = opt_num_rest();
|
||||
argv = opt_rest();
|
||||
private = 1;
|
||||
|
||||
if (dsaparams == NULL) {
|
||||
bad:
|
||||
BIO_printf(bio_err, "usage: gendsa [args] dsaparam-file\n");
|
||||
BIO_printf(bio_err, " -out file - output the key to 'file'\n");
|
||||
# ifndef OPENSSL_NO_DES
|
||||
BIO_printf(bio_err,
|
||||
" -des - encrypt the generated key with DES in cbc mode\n");
|
||||
BIO_printf(bio_err,
|
||||
" -des3 - encrypt the generated key with DES in ede cbc mode (168 bit key)\n");
|
||||
# endif
|
||||
# ifndef OPENSSL_NO_IDEA
|
||||
BIO_printf(bio_err,
|
||||
" -idea - encrypt the generated key with IDEA in cbc mode\n");
|
||||
# endif
|
||||
# ifndef OPENSSL_NO_SEED
|
||||
BIO_printf(bio_err, " -seed\n");
|
||||
BIO_printf(bio_err,
|
||||
" encrypt PEM output with cbc seed\n");
|
||||
# endif
|
||||
# ifndef OPENSSL_NO_AES
|
||||
BIO_printf(bio_err, " -aes128, -aes192, -aes256\n");
|
||||
BIO_printf(bio_err,
|
||||
" encrypt PEM output with cbc aes\n");
|
||||
# endif
|
||||
# ifndef OPENSSL_NO_CAMELLIA
|
||||
BIO_printf(bio_err, " -camellia128, -camellia192, -camellia256\n");
|
||||
BIO_printf(bio_err,
|
||||
" encrypt PEM output with cbc camellia\n");
|
||||
# endif
|
||||
# ifndef OPENSSL_NO_ENGINE
|
||||
BIO_printf(bio_err,
|
||||
" -engine e - use engine e, possibly a hardware device.\n");
|
||||
# endif
|
||||
BIO_printf(bio_err, " -rand file%cfile%c...\n", LIST_SEPARATOR_CHAR,
|
||||
LIST_SEPARATOR_CHAR);
|
||||
BIO_printf(bio_err,
|
||||
" - load the file (or the files in the directory) into\n");
|
||||
BIO_printf(bio_err, " the random number generator\n");
|
||||
BIO_printf(bio_err, " dsaparam-file\n");
|
||||
BIO_printf(bio_err,
|
||||
" - a DSA parameter file as generated by the dsaparam command\n");
|
||||
goto end;
|
||||
}
|
||||
e = setup_engine(bio_err, engine, 0);
|
||||
if (argc != 1)
|
||||
goto opthelp;
|
||||
dsaparams = *argv;
|
||||
|
||||
if (!app_passwd(bio_err, NULL, passargout, NULL, &passout)) {
|
||||
if (!app_passwd(NULL, passoutarg, NULL, &passout)) {
|
||||
BIO_printf(bio_err, "Error getting password\n");
|
||||
goto end;
|
||||
}
|
||||
|
||||
in = BIO_new(BIO_s_file());
|
||||
if (!(BIO_read_filename(in, dsaparams))) {
|
||||
perror(dsaparams);
|
||||
goto end;
|
||||
}
|
||||
in = bio_open_default(dsaparams, 'r', FORMAT_PEM);
|
||||
if (in == NULL)
|
||||
goto end2;
|
||||
|
||||
if ((dsa = PEM_read_bio_DSAparams(in, NULL, NULL, NULL)) == NULL) {
|
||||
BIO_printf(bio_err, "unable to load DSA parameter file\n");
|
||||
@ -225,61 +112,35 @@ int MAIN(int argc, char **argv)
|
||||
BIO_free(in);
|
||||
in = NULL;
|
||||
|
||||
out = BIO_new(BIO_s_file());
|
||||
out = bio_open_owner(outfile, FORMAT_PEM, private);
|
||||
if (out == NULL)
|
||||
goto end;
|
||||
goto end2;
|
||||
|
||||
if (outfile == NULL) {
|
||||
BIO_set_fp(out, stdout, BIO_NOCLOSE);
|
||||
# ifdef OPENSSL_SYS_VMS
|
||||
{
|
||||
BIO *tmpbio = BIO_new(BIO_f_linebuffer());
|
||||
out = BIO_push(tmpbio, out);
|
||||
}
|
||||
# endif
|
||||
} else {
|
||||
if (BIO_write_filename(out, outfile) <= 0) {
|
||||
perror(outfile);
|
||||
goto end;
|
||||
}
|
||||
}
|
||||
DSA_get0_pqg(dsa, &p, NULL, NULL);
|
||||
|
||||
if (!app_RAND_load_file(NULL, bio_err, 1) && inrand == NULL) {
|
||||
if (BN_num_bits(p) > OPENSSL_DSA_MAX_MODULUS_BITS)
|
||||
BIO_printf(bio_err,
|
||||
"warning, not much extra random data, consider using the -rand option\n");
|
||||
}
|
||||
if (inrand != NULL)
|
||||
BIO_printf(bio_err, "%ld semi-random bytes loaded\n",
|
||||
app_RAND_load_files(inrand));
|
||||
"Warning: It is not recommended to use more than %d bit for DSA keys.\n"
|
||||
" Your key size is %d! Larger key size may behave not as expected.\n",
|
||||
OPENSSL_DSA_MAX_MODULUS_BITS, BN_num_bits(p));
|
||||
|
||||
BIO_printf(bio_err, "Generating DSA key, %d bits\n", BN_num_bits(dsa->p));
|
||||
BIO_printf(bio_err, "Generating DSA key, %d bits\n", BN_num_bits(p));
|
||||
if (!DSA_generate_key(dsa))
|
||||
goto end;
|
||||
|
||||
app_RAND_write_file(NULL, bio_err);
|
||||
|
||||
assert(private);
|
||||
if (!PEM_write_bio_DSAPrivateKey(out, dsa, enc, NULL, 0, NULL, passout))
|
||||
goto end;
|
||||
ret = 0;
|
||||
end:
|
||||
if (ret != 0)
|
||||
ERR_print_errors(bio_err);
|
||||
if (in != NULL)
|
||||
BIO_free(in);
|
||||
if (out != NULL)
|
||||
BIO_free_all(out);
|
||||
if (dsa != NULL)
|
||||
DSA_free(dsa);
|
||||
end2:
|
||||
BIO_free(in);
|
||||
BIO_free_all(out);
|
||||
DSA_free(dsa);
|
||||
release_engine(e);
|
||||
if (passout)
|
||||
OPENSSL_free(passout);
|
||||
apps_shutdown();
|
||||
OPENSSL_EXIT(ret);
|
||||
OPENSSL_free(passout);
|
||||
return ret;
|
||||
}
|
||||
#else /* !OPENSSL_NO_DSA */
|
||||
|
||||
# if PEDANTIC
|
||||
static void *dummy = &dummy;
|
||||
# endif
|
||||
|
||||
#endif
|
||||
|
@ -1,64 +1,16 @@
|
||||
/* apps/genpkey.c */
|
||||
/*
|
||||
* Written by Dr Stephen N Henson (steve@openssl.org) for the OpenSSL project
|
||||
* 2006
|
||||
*/
|
||||
/* ====================================================================
|
||||
* Copyright (c) 2006 The OpenSSL Project. All rights reserved.
|
||||
*
|
||||
* Redistribution and use in source and binary forms, with or without
|
||||
* modification, are permitted provided that the following conditions
|
||||
* are met:
|
||||
*
|
||||
* 1. Redistributions of source code must retain the above copyright
|
||||
* notice, this list of conditions and the following disclaimer.
|
||||
*
|
||||
* 2. Redistributions in binary form must reproduce the above copyright
|
||||
* notice, this list of conditions and the following disclaimer in
|
||||
* the documentation and/or other materials provided with the
|
||||
* distribution.
|
||||
*
|
||||
* 3. All advertising materials mentioning features or use of this
|
||||
* software must display the following acknowledgment:
|
||||
* "This product includes software developed by the OpenSSL Project
|
||||
* for use in the OpenSSL Toolkit. (http://www.OpenSSL.org/)"
|
||||
*
|
||||
* 4. The names "OpenSSL Toolkit" and "OpenSSL Project" must not be used to
|
||||
* endorse or promote products derived from this software without
|
||||
* prior written permission. For written permission, please contact
|
||||
* licensing@OpenSSL.org.
|
||||
*
|
||||
* 5. Products derived from this software may not be called "OpenSSL"
|
||||
* nor may "OpenSSL" appear in their names without prior written
|
||||
* permission of the OpenSSL Project.
|
||||
*
|
||||
* 6. Redistributions of any form whatsoever must retain the following
|
||||
* acknowledgment:
|
||||
* "This product includes software developed by the OpenSSL Project
|
||||
* for use in the OpenSSL Toolkit (http://www.OpenSSL.org/)"
|
||||
*
|
||||
* THIS SOFTWARE IS PROVIDED BY THE OpenSSL PROJECT ``AS IS'' AND ANY
|
||||
* EXPRESSED OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
|
||||
* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
|
||||
* PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE OpenSSL PROJECT OR
|
||||
* ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
|
||||
* SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
|
||||
* NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
|
||||
* LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
|
||||
* HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT,
|
||||
* STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
|
||||
* ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED
|
||||
* OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
* ====================================================================
|
||||
*
|
||||
* This product includes cryptographic software written by Eric Young
|
||||
* (eay@cryptsoft.com). This product includes software written by Tim
|
||||
* Hudson (tjh@cryptsoft.com).
|
||||
*
|
||||
* Copyright 2006-2018 The OpenSSL Project Authors. All Rights Reserved.
|
||||
*
|
||||
* Licensed under the OpenSSL license (the "License"). You may not use
|
||||
* this file except in compliance with the License. You can obtain a copy
|
||||
* in the file LICENSE in the source distribution or at
|
||||
* https://www.openssl.org/source/license.html
|
||||
*/
|
||||
|
||||
#include <stdio.h>
|
||||
#include <string.h>
|
||||
#include "apps.h"
|
||||
#include "progs.h"
|
||||
#include <openssl/pem.h>
|
||||
#include <openssl/err.h>
|
||||
#include <openssl/evp.h>
|
||||
@ -66,159 +18,134 @@
|
||||
# include <openssl/engine.h>
|
||||
#endif
|
||||
|
||||
static int init_keygen_file(BIO *err, EVP_PKEY_CTX **pctx,
|
||||
const char *file, ENGINE *e);
|
||||
static int init_keygen_file(EVP_PKEY_CTX **pctx, const char *file, ENGINE *e);
|
||||
static int genpkey_cb(EVP_PKEY_CTX *ctx);
|
||||
|
||||
#define PROG genpkey_main
|
||||
typedef enum OPTION_choice {
|
||||
OPT_ERR = -1, OPT_EOF = 0, OPT_HELP,
|
||||
OPT_ENGINE, OPT_OUTFORM, OPT_OUT, OPT_PASS, OPT_PARAMFILE,
|
||||
OPT_ALGORITHM, OPT_PKEYOPT, OPT_GENPARAM, OPT_TEXT, OPT_CIPHER
|
||||
} OPTION_CHOICE;
|
||||
|
||||
int MAIN(int, char **);
|
||||
const OPTIONS genpkey_options[] = {
|
||||
{"help", OPT_HELP, '-', "Display this summary"},
|
||||
{"out", OPT_OUT, '>', "Output file"},
|
||||
{"outform", OPT_OUTFORM, 'F', "output format (DER or PEM)"},
|
||||
{"pass", OPT_PASS, 's', "Output file pass phrase source"},
|
||||
{"paramfile", OPT_PARAMFILE, '<', "Parameters file"},
|
||||
{"algorithm", OPT_ALGORITHM, 's', "The public key algorithm"},
|
||||
{"pkeyopt", OPT_PKEYOPT, 's',
|
||||
"Set the public key algorithm option as opt:value"},
|
||||
{"genparam", OPT_GENPARAM, '-', "Generate parameters, not key"},
|
||||
{"text", OPT_TEXT, '-', "Print the in text"},
|
||||
{"", OPT_CIPHER, '-', "Cipher to use to encrypt the key"},
|
||||
#ifndef OPENSSL_NO_ENGINE
|
||||
{"engine", OPT_ENGINE, 's', "Use engine, possibly a hardware device"},
|
||||
#endif
|
||||
/* This is deliberately last. */
|
||||
{OPT_HELP_STR, 1, 1,
|
||||
"Order of options may be important! See the documentation.\n"},
|
||||
{NULL}
|
||||
};
|
||||
|
||||
int MAIN(int argc, char **argv)
|
||||
int genpkey_main(int argc, char **argv)
|
||||
{
|
||||
ENGINE *e = NULL;
|
||||
char **args, *outfile = NULL;
|
||||
char *passarg = NULL;
|
||||
BIO *in = NULL, *out = NULL;
|
||||
const EVP_CIPHER *cipher = NULL;
|
||||
int outformat;
|
||||
int text = 0;
|
||||
ENGINE *e = NULL;
|
||||
EVP_PKEY *pkey = NULL;
|
||||
EVP_PKEY_CTX *ctx = NULL;
|
||||
char *pass = NULL;
|
||||
int badarg = 0;
|
||||
int ret = 1, rv;
|
||||
char *outfile = NULL, *passarg = NULL, *pass = NULL, *prog;
|
||||
const EVP_CIPHER *cipher = NULL;
|
||||
OPTION_CHOICE o;
|
||||
int outformat = FORMAT_PEM, text = 0, ret = 1, rv, do_param = 0;
|
||||
int private = 0;
|
||||
|
||||
int do_param = 0;
|
||||
|
||||
if (bio_err == NULL)
|
||||
bio_err = BIO_new_fp(stderr, BIO_NOCLOSE);
|
||||
|
||||
if (!load_config(bio_err, NULL))
|
||||
goto end;
|
||||
|
||||
outformat = FORMAT_PEM;
|
||||
|
||||
ERR_load_crypto_strings();
|
||||
OpenSSL_add_all_algorithms();
|
||||
args = argv + 1;
|
||||
while (!badarg && *args && *args[0] == '-') {
|
||||
if (!strcmp(*args, "-outform")) {
|
||||
if (args[1]) {
|
||||
args++;
|
||||
outformat = str2fmt(*args);
|
||||
} else
|
||||
badarg = 1;
|
||||
} else if (!strcmp(*args, "-pass")) {
|
||||
if (!args[1])
|
||||
goto bad;
|
||||
passarg = *(++args);
|
||||
}
|
||||
#ifndef OPENSSL_NO_ENGINE
|
||||
else if (strcmp(*args, "-engine") == 0) {
|
||||
if (!args[1])
|
||||
goto bad;
|
||||
e = setup_engine(bio_err, *(++args), 0);
|
||||
}
|
||||
#endif
|
||||
else if (!strcmp(*args, "-paramfile")) {
|
||||
if (!args[1])
|
||||
goto bad;
|
||||
args++;
|
||||
prog = opt_init(argc, argv, genpkey_options);
|
||||
while ((o = opt_next()) != OPT_EOF) {
|
||||
switch (o) {
|
||||
case OPT_EOF:
|
||||
case OPT_ERR:
|
||||
opthelp:
|
||||
BIO_printf(bio_err, "%s: Use -help for summary.\n", prog);
|
||||
goto end;
|
||||
case OPT_HELP:
|
||||
ret = 0;
|
||||
opt_help(genpkey_options);
|
||||
goto end;
|
||||
case OPT_OUTFORM:
|
||||
if (!opt_format(opt_arg(), OPT_FMT_PEMDER, &outformat))
|
||||
goto opthelp;
|
||||
break;
|
||||
case OPT_OUT:
|
||||
outfile = opt_arg();
|
||||
break;
|
||||
case OPT_PASS:
|
||||
passarg = opt_arg();
|
||||
break;
|
||||
case OPT_ENGINE:
|
||||
e = setup_engine(opt_arg(), 0);
|
||||
break;
|
||||
case OPT_PARAMFILE:
|
||||
if (do_param == 1)
|
||||
goto bad;
|
||||
if (!init_keygen_file(bio_err, &ctx, *args, e))
|
||||
goto opthelp;
|
||||
if (!init_keygen_file(&ctx, opt_arg(), e))
|
||||
goto end;
|
||||
} else if (!strcmp(*args, "-out")) {
|
||||
if (args[1]) {
|
||||
args++;
|
||||
outfile = *args;
|
||||
} else
|
||||
badarg = 1;
|
||||
} else if (strcmp(*args, "-algorithm") == 0) {
|
||||
if (!args[1])
|
||||
goto bad;
|
||||
if (!init_gen_str(bio_err, &ctx, *(++args), e, do_param))
|
||||
break;
|
||||
case OPT_ALGORITHM:
|
||||
if (!init_gen_str(&ctx, opt_arg(), e, do_param))
|
||||
goto end;
|
||||
} else if (strcmp(*args, "-pkeyopt") == 0) {
|
||||
if (!args[1])
|
||||
goto bad;
|
||||
if (!ctx) {
|
||||
BIO_puts(bio_err, "No keytype specified\n");
|
||||
goto bad;
|
||||
} else if (pkey_ctrl_string(ctx, *(++args)) <= 0) {
|
||||
BIO_puts(bio_err, "parameter setting error\n");
|
||||
break;
|
||||
case OPT_PKEYOPT:
|
||||
if (ctx == NULL) {
|
||||
BIO_printf(bio_err, "%s: No keytype specified.\n", prog);
|
||||
goto opthelp;
|
||||
}
|
||||
if (pkey_ctrl_string(ctx, opt_arg()) <= 0) {
|
||||
BIO_printf(bio_err,
|
||||
"%s: Error setting %s parameter:\n",
|
||||
prog, opt_arg());
|
||||
ERR_print_errors(bio_err);
|
||||
goto end;
|
||||
}
|
||||
} else if (strcmp(*args, "-genparam") == 0) {
|
||||
if (ctx)
|
||||
goto bad;
|
||||
break;
|
||||
case OPT_GENPARAM:
|
||||
if (ctx != NULL)
|
||||
goto opthelp;
|
||||
do_param = 1;
|
||||
} else if (strcmp(*args, "-text") == 0)
|
||||
break;
|
||||
case OPT_TEXT:
|
||||
text = 1;
|
||||
else {
|
||||
cipher = EVP_get_cipherbyname(*args + 1);
|
||||
if (!cipher) {
|
||||
BIO_printf(bio_err, "Unknown cipher %s\n", *args + 1);
|
||||
badarg = 1;
|
||||
break;
|
||||
case OPT_CIPHER:
|
||||
if (!opt_cipher(opt_unknown(), &cipher)
|
||||
|| do_param == 1)
|
||||
goto opthelp;
|
||||
if (EVP_CIPHER_mode(cipher) == EVP_CIPH_GCM_MODE ||
|
||||
EVP_CIPHER_mode(cipher) == EVP_CIPH_CCM_MODE ||
|
||||
EVP_CIPHER_mode(cipher) == EVP_CIPH_XTS_MODE ||
|
||||
EVP_CIPHER_mode(cipher) == EVP_CIPH_OCB_MODE) {
|
||||
BIO_printf(bio_err, "%s: cipher mode not supported\n", prog);
|
||||
goto end;
|
||||
}
|
||||
if (do_param == 1)
|
||||
badarg = 1;
|
||||
}
|
||||
args++;
|
||||
}
|
||||
argc = opt_num_rest();
|
||||
if (argc != 0)
|
||||
goto opthelp;
|
||||
|
||||
if (!ctx)
|
||||
badarg = 1;
|
||||
private = do_param ? 0 : 1;
|
||||
|
||||
if (badarg) {
|
||||
bad:
|
||||
BIO_printf(bio_err, "Usage: genpkey [options]\n");
|
||||
BIO_printf(bio_err, "where options may be\n");
|
||||
BIO_printf(bio_err, "-out file output file\n");
|
||||
BIO_printf(bio_err,
|
||||
"-outform X output format (DER or PEM)\n");
|
||||
BIO_printf(bio_err,
|
||||
"-pass arg output file pass phrase source\n");
|
||||
BIO_printf(bio_err,
|
||||
"-<cipher> use cipher <cipher> to encrypt the key\n");
|
||||
#ifndef OPENSSL_NO_ENGINE
|
||||
BIO_printf(bio_err,
|
||||
"-engine e use engine e, possibly a hardware device.\n");
|
||||
#endif
|
||||
BIO_printf(bio_err, "-paramfile file parameters file\n");
|
||||
BIO_printf(bio_err, "-algorithm alg the public key algorithm\n");
|
||||
BIO_printf(bio_err,
|
||||
"-pkeyopt opt:value set the public key algorithm option <opt>\n"
|
||||
" to value <value>\n");
|
||||
BIO_printf(bio_err,
|
||||
"-genparam generate parameters, not key\n");
|
||||
BIO_printf(bio_err, "-text print the in text\n");
|
||||
BIO_printf(bio_err,
|
||||
"NB: options order may be important! See the manual page.\n");
|
||||
goto end;
|
||||
}
|
||||
if (ctx == NULL)
|
||||
goto opthelp;
|
||||
|
||||
if (!app_passwd(bio_err, passarg, NULL, &pass, NULL)) {
|
||||
if (!app_passwd(passarg, NULL, &pass, NULL)) {
|
||||
BIO_puts(bio_err, "Error getting password\n");
|
||||
goto end;
|
||||
}
|
||||
|
||||
if (outfile) {
|
||||
if (!(out = BIO_new_file(outfile, "wb"))) {
|
||||
BIO_printf(bio_err, "Can't open output file %s\n", outfile);
|
||||
goto end;
|
||||
}
|
||||
} else {
|
||||
out = BIO_new_fp(stdout, BIO_NOCLOSE);
|
||||
#ifdef OPENSSL_SYS_VMS
|
||||
{
|
||||
BIO *tmpbio = BIO_new(BIO_f_linebuffer());
|
||||
out = BIO_push(tmpbio, out);
|
||||
}
|
||||
#endif
|
||||
}
|
||||
out = bio_open_owner(outfile, outformat, private);
|
||||
if (out == NULL)
|
||||
goto end;
|
||||
|
||||
EVP_PKEY_CTX_set_cb(ctx, genpkey_cb);
|
||||
EVP_PKEY_CTX_set_app_data(ctx, bio_err);
|
||||
@ -237,13 +164,15 @@ int MAIN(int argc, char **argv)
|
||||
}
|
||||
}
|
||||
|
||||
if (do_param)
|
||||
if (do_param) {
|
||||
rv = PEM_write_bio_Parameters(out, pkey);
|
||||
else if (outformat == FORMAT_PEM)
|
||||
} else if (outformat == FORMAT_PEM) {
|
||||
assert(private);
|
||||
rv = PEM_write_bio_PrivateKey(out, pkey, cipher, NULL, 0, NULL, pass);
|
||||
else if (outformat == FORMAT_ASN1)
|
||||
} else if (outformat == FORMAT_ASN1) {
|
||||
assert(private);
|
||||
rv = i2d_PrivateKey_bio(out, pkey);
|
||||
else {
|
||||
} else {
|
||||
BIO_printf(bio_err, "Bad format specified for key\n");
|
||||
goto end;
|
||||
}
|
||||
@ -268,33 +197,28 @@ int MAIN(int argc, char **argv)
|
||||
ret = 0;
|
||||
|
||||
end:
|
||||
if (pkey)
|
||||
EVP_PKEY_free(pkey);
|
||||
if (ctx)
|
||||
EVP_PKEY_CTX_free(ctx);
|
||||
if (out)
|
||||
BIO_free_all(out);
|
||||
EVP_PKEY_free(pkey);
|
||||
EVP_PKEY_CTX_free(ctx);
|
||||
BIO_free_all(out);
|
||||
BIO_free(in);
|
||||
release_engine(e);
|
||||
if (pass)
|
||||
OPENSSL_free(pass);
|
||||
OPENSSL_free(pass);
|
||||
return ret;
|
||||
}
|
||||
|
||||
static int init_keygen_file(BIO *err, EVP_PKEY_CTX **pctx,
|
||||
const char *file, ENGINE *e)
|
||||
static int init_keygen_file(EVP_PKEY_CTX **pctx, const char *file, ENGINE *e)
|
||||
{
|
||||
BIO *pbio;
|
||||
EVP_PKEY *pkey = NULL;
|
||||
EVP_PKEY_CTX *ctx = NULL;
|
||||
if (*pctx) {
|
||||
BIO_puts(err, "Parameters already set!\n");
|
||||
BIO_puts(bio_err, "Parameters already set!\n");
|
||||
return 0;
|
||||
}
|
||||
|
||||
pbio = BIO_new_file(file, "r");
|
||||
if (!pbio) {
|
||||
BIO_printf(err, "Can't open parameter file %s\n", file);
|
||||
BIO_printf(bio_err, "Can't open parameter file %s\n", file);
|
||||
return 0;
|
||||
}
|
||||
|
||||
@ -307,7 +231,7 @@ static int init_keygen_file(BIO *err, EVP_PKEY_CTX **pctx,
|
||||
}
|
||||
|
||||
ctx = EVP_PKEY_CTX_new(pkey, e);
|
||||
if (!ctx)
|
||||
if (ctx == NULL)
|
||||
goto err;
|
||||
if (EVP_PKEY_keygen_init(ctx) <= 0)
|
||||
goto err;
|
||||
@ -316,17 +240,15 @@ static int init_keygen_file(BIO *err, EVP_PKEY_CTX **pctx,
|
||||
return 1;
|
||||
|
||||
err:
|
||||
BIO_puts(err, "Error initializing context\n");
|
||||
ERR_print_errors(err);
|
||||
if (ctx)
|
||||
EVP_PKEY_CTX_free(ctx);
|
||||
if (pkey)
|
||||
EVP_PKEY_free(pkey);
|
||||
BIO_puts(bio_err, "Error initializing context\n");
|
||||
ERR_print_errors(bio_err);
|
||||
EVP_PKEY_CTX_free(ctx);
|
||||
EVP_PKEY_free(pkey);
|
||||
return 0;
|
||||
|
||||
}
|
||||
|
||||
int init_gen_str(BIO *err, EVP_PKEY_CTX **pctx,
|
||||
int init_gen_str(EVP_PKEY_CTX **pctx,
|
||||
const char *algname, ENGINE *e, int do_param)
|
||||
{
|
||||
EVP_PKEY_CTX *ctx = NULL;
|
||||
@ -335,7 +257,7 @@ int init_gen_str(BIO *err, EVP_PKEY_CTX **pctx,
|
||||
int pkey_id;
|
||||
|
||||
if (*pctx) {
|
||||
BIO_puts(err, "Algorithm already set!\n");
|
||||
BIO_puts(bio_err, "Algorithm already set!\n");
|
||||
return 0;
|
||||
}
|
||||
|
||||
@ -355,8 +277,7 @@ int init_gen_str(BIO *err, EVP_PKEY_CTX **pctx,
|
||||
|
||||
EVP_PKEY_asn1_get0_info(&pkey_id, NULL, NULL, NULL, NULL, ameth);
|
||||
#ifndef OPENSSL_NO_ENGINE
|
||||
if (tmpeng)
|
||||
ENGINE_finish(tmpeng);
|
||||
ENGINE_finish(tmpeng);
|
||||
#endif
|
||||
ctx = EVP_PKEY_CTX_new_id(pkey_id, e);
|
||||
|
||||
@ -374,10 +295,9 @@ int init_gen_str(BIO *err, EVP_PKEY_CTX **pctx,
|
||||
return 1;
|
||||
|
||||
err:
|
||||
BIO_printf(err, "Error initializing %s context\n", algname);
|
||||
ERR_print_errors(err);
|
||||
if (ctx)
|
||||
EVP_PKEY_CTX_free(ctx);
|
||||
BIO_printf(bio_err, "Error initializing %s context\n", algname);
|
||||
ERR_print_errors(bio_err);
|
||||
EVP_PKEY_CTX_free(ctx);
|
||||
return 0;
|
||||
|
||||
}
|
||||
@ -398,8 +318,5 @@ static int genpkey_cb(EVP_PKEY_CTX *ctx)
|
||||
c = '\n';
|
||||
BIO_write(b, &c, 1);
|
||||
(void)BIO_flush(b);
|
||||
#ifdef LINT
|
||||
p = n;
|
||||
#endif
|
||||
return 1;
|
||||
}
|
||||
|
Some files were not shown because too many files have changed in this diff Show More
Loading…
Reference in New Issue
Block a user