summaryrefslogtreecommitdiffstats
path: root/include
diff options
context:
space:
mode:
Diffstat (limited to 'include')
-rw-r--r--include/ncrypto/ncrypto.h73
1 files changed, 55 insertions, 18 deletions
diff --git a/include/ncrypto/ncrypto.h b/include/ncrypto/ncrypto.h
index a09d451..d9508bf 100644
--- a/include/ncrypto/ncrypto.h
+++ b/include/ncrypto/ncrypto.h
@@ -73,31 +73,68 @@ 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);
+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. */
CK_RV ncr_private_key_create (struct ncr_private_key **key, CK_KEY_TYPE type,
- const void *der, size_t der_size,
+ _Bool sensitive, const void *der, size_t der_size,
const void *public_value,
size_t public_value_size);
+CK_RV ncr_private_key_set_sensitive (struct ncr_private_key *key);
+CK_RV ncr_private_key_export (struct ncr_private_key *key, void *dest,
+ size_t *dest_size_ptr);
CK_RV ncr_private_key_destroy (struct ncr_private_key *key);
+ /* Multi-precision integers */
+
+/* This is used to avoid e.g. 8 separate parameters for RSA private key
+ passing. */
+struct ncr_mpi
+{
+ void *data;
+ size_t size;
+};
+
+ /* RSA keys */
+
+enum
+ {
+ NCR_RSA_PUBLIC_MPI_MODULUS,
+ NCR_RSA_PUBLIC_MPI_PUBLIC_EXPONENT,
+ NCR_RSA_PUBLIC_NUM_MPIS
+ };
+
+enum
+ {
+ NCR_RSA_PRIVATE_MPI_MODULUS,
+ NCR_RSA_PRIVATE_MPI_PUBLIC_EXPONENT,
+ NCR_RSA_PRIVATE_MPI_PRIVATE_EXPONENT,
+ NCR_RSA_PRIVATE_MPI_PRIME_1,
+ NCR_RSA_PRIVATE_MPI_PRIME_2,
+ NCR_RSA_PRIVATE_MPI_EXPONENT_1,
+ NCR_RSA_PRIVATE_MPI_EXPONENT_2,
+ NCR_RSA_PRIVATE_MPI_COEFFICIENT,
+ NCR_RSA_PRIVATE_NUM_MPIS
+ };
+
CK_RV ncr_public_key_create_rsa (struct ncr_public_key **key,
- const void *modulus, size_t modulus_size,
- const void *public_exponent,
- size_t public_exponent_size);
-CK_RV ncr_private_key_create_rsa (struct ncr_private_key **key,
- const void *modulus, size_t modulus_size,
- const void *public_exponent,
- size_t public_exponent_size,
- const void *private_exponent,
- size_t private_exponent_size,
- const void *prime_1, size_t prime_1_size,
- const void *prime_2, size_t prime_2_size,
- const void *exponent_1,
- size_t exponent_1_size,
- const void *exponent_2,
- size_t exponent_2_size,
- const void *coefficient,
- size_t coefficient_size);
+ const struct ncr_mpi
+ mpis[static NCR_RSA_PUBLIC_NUM_MPIS]);
+CK_RV ncr_public_key_export_rsa (struct ncr_public_key *key,
+ struct ncr_mpi
+ mpis [static NCR_RSA_PUBLIC_NUM_MPIS]);
+CK_RV ncr_private_key_create_rsa (struct ncr_private_key **key, _Bool sensitive,
+ const struct ncr_mpi
+ mpis[static NCR_RSA_PRIVATE_NUM_MPIS]);
+CK_RV ncr_private_key_export_rsa (struct ncr_private_key *key,
+ struct ncr_mpi
+ mpis[static NCR_RSA_PRIVATE_NUM_MPIS]);
+CK_RV ncr_key_pair_generate_rsa (struct ncr_public_key **public_key,
+ struct ncr_private_key **private_key,
+ CK_MECHANISM_TYPE mech, _Bool sensitive,
+ CK_ULONG modulus_bits,
+ const struct ncr_mpi *public_exponent);
/* Asymmetric operations */