diff options
| author | Miloslav Trmač <mitr@redhat.com> | 2010-11-29 17:40:47 +0100 |
|---|---|---|
| committer | Miloslav Trmač <mitr@redhat.com> | 2010-11-29 17:40:47 +0100 |
| commit | 642c97ec86ff47d83f2492e3969b05ef1cb86f03 (patch) | |
| tree | bda0e5779ff6429245653e8df274e88ecb6c1cc1 /include | |
| parent | 4218a944cf36890f6ab89d0bf1bf608be879343e (diff) | |
| parent | cd4794e966303075633d6ac28e98279282734fd7 (diff) | |
Merge branch 'local'
Diffstat (limited to 'include')
| -rw-r--r-- | include/ncrypto/ncrypto.h | 73 |
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 */ |
