From a4427401d8bcb95d07ee0d48b8dce8d1ad70394d Mon Sep 17 00:00:00 2001 From: Miloslav Trmač Date: Tue, 30 Nov 2010 19:36:37 +0100 Subject: Use subjectPublicKeyInfo for public keys in DER form Also avoid subjectPublicKeyInfo encoding/decoding when handling RSA key details. --- include/ncrypto/ncrypto.h | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) (limited to 'include') diff --git a/include/ncrypto/ncrypto.h b/include/ncrypto/ncrypto.h index d9508bf..3938b45 100644 --- a/include/ncrypto/ncrypto.h +++ b/include/ncrypto/ncrypto.h @@ -71,8 +71,9 @@ CK_RV ncr_symm_key_destroy (struct ncr_symm_key *key); struct ncr_public_key; struct ncr_private_key; -CK_RV ncr_public_key_create (struct ncr_public_key **key, CK_KEY_TYPE type, - const void *der, size_t der_size); +/* The X.509v3 subjectPublicKeyInfo structure is used for public keys. */ +CK_RV ncr_public_key_create (struct ncr_public_key **key, const void *der, + size_t der_size); CK_RV ncr_public_key_export (struct ncr_public_key *key, void *dest, size_t *dest_size_ptr); CK_RV ncr_public_key_destroy (struct ncr_public_key *key); -- cgit From 9f8c85856ca06788c4eedb16d37f375491948a54 Mon Sep 17 00:00:00 2001 From: Miloslav Trmač Date: Tue, 30 Nov 2010 21:58:21 +0100 Subject: Use PKCS#8 privateKeyInfo for private keys in DER form --- include/ncrypto/ncrypto.h | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) (limited to 'include') diff --git a/include/ncrypto/ncrypto.h b/include/ncrypto/ncrypto.h index 3938b45..07e57be 100644 --- a/include/ncrypto/ncrypto.h +++ b/include/ncrypto/ncrypto.h @@ -77,7 +77,8 @@ CK_RV ncr_public_key_create (struct ncr_public_key **key, const void *der, CK_RV ncr_public_key_export (struct ncr_public_key *key, void *dest, size_t *dest_size_ptr); CK_RV ncr_public_key_destroy (struct ncr_public_key *key); -/* "Sensitive" corresponds to CKA_SENSITIVE. */ +/* The PKCS#8 privateKeyInfo structure is used for private keys. "Sensitive" + corresponds to CKA_SENSITIVE. */ CK_RV ncr_private_key_create (struct ncr_private_key **key, CK_KEY_TYPE type, _Bool sensitive, const void *der, size_t der_size, const void *public_value, -- cgit From a2dd3a2b9045b5a787e0981bef2f378ab148ac1f Mon Sep 17 00:00:00 2001 From: Miloslav Trmač Date: Tue, 30 Nov 2010 22:02:17 +0100 Subject: Add DSA --- include/ncrypto/ncrypto.h | 47 +++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 47 insertions(+) (limited to 'include') diff --git a/include/ncrypto/ncrypto.h b/include/ncrypto/ncrypto.h index 07e57be..ff20d8c 100644 --- a/include/ncrypto/ncrypto.h +++ b/include/ncrypto/ncrypto.h @@ -138,6 +138,53 @@ CK_RV ncr_key_pair_generate_rsa (struct ncr_public_key **public_key, CK_ULONG modulus_bits, const struct ncr_mpi *public_exponent); + /* DSA keys */ + +enum + { + NCR_DSA_PUBLIC_MPI_PRIME, + NCR_DSA_PUBLIC_MPI_SUBPRIME, + NCR_DSA_PUBLIC_MPI_BASE, + NCR_DSA_PUBLIC_MPI_VALUE, + NCR_DSA_PUBLIC_NUM_MPIS + }; + +enum + { + NCR_DSA_PRIVATE_MPI_PRIME, + NCR_DSA_PRIVATE_MPI_SUBPRIME, + NCR_DSA_PRIVATE_MPI_BASE, + NCR_DSA_PRIVATE_MPI_VALUE, + NCR_DSA_PRIVATE_NUM_MPIS + }; + +enum + { + NCR_DSA_GEN_MPI_PRIME, + NCR_DSA_GEN_MPI_SUBPRIME, + NCR_DSA_GEN_MPI_BASE, + NCR_DSA_GEN_NUM_MPIS + }; + +CK_RV ncr_public_key_create_dsa (struct ncr_public_key **key, + const struct ncr_mpi + mpis[static NCR_DSA_PUBLIC_NUM_MPIS]); +CK_RV ncr_public_key_export_dsa (struct ncr_public_key *key, + struct ncr_mpi + mpis [static NCR_DSA_PUBLIC_NUM_MPIS]); +CK_RV ncr_private_key_create_dsa (struct ncr_private_key **key, _Bool sensitive, + const struct ncr_mpi + mpis[static NCR_DSA_PRIVATE_NUM_MPIS], + const struct ncr_mpi *public_value); +CK_RV ncr_private_key_export_dsa (struct ncr_private_key *key, + struct ncr_mpi + mpis[static NCR_DSA_PRIVATE_NUM_MPIS]); +CK_RV ncr_key_pair_generate_dsa (struct ncr_public_key **public_key, + struct ncr_private_key **private_key, + CK_MECHANISM_TYPE mech, _Bool sensitive, + const struct ncr_mpi + mpis[static NCR_DSA_GEN_NUM_MPIS]); + /* Asymmetric operations */ CK_RV ncr_public_key_encrypt (CK_MECHANISM_TYPE mech, -- cgit