summaryrefslogtreecommitdiff
path: root/usr
diff options
context:
space:
mode:
authorfr41279 <none@none>2007-10-15 12:38:20 -0700
committerfr41279 <none@none>2007-10-15 12:38:20 -0700
commit8d4583b007f9d4eeaf0c8a5d4e1c96af5c0c71da (patch)
treed7b59f9cb1c4f4b3581b9dfe52aa5ce8af46816c /usr
parentef4ff518aacd5f057272eb9c58de31629c4260d3 (diff)
downloadillumos-joyent-8d4583b007f9d4eeaf0c8a5d4e1c96af5c0c71da.tar.gz
6558449 Add ECC support to NCP
Diffstat (limited to 'usr')
-rw-r--r--usr/src/uts/common/sys/crypto/common.h23
-rw-r--r--usr/src/uts/sun4v/sys/bignum.h37
2 files changed, 59 insertions, 1 deletions
diff --git a/usr/src/uts/common/sys/crypto/common.h b/usr/src/uts/common/sys/crypto/common.h
index 0a90323e7c..656564e8c9 100644
--- a/usr/src/uts/common/sys/crypto/common.h
+++ b/usr/src/uts/common/sys/crypto/common.h
@@ -82,6 +82,21 @@ typedef struct CK_AES_CCM_PARAMS {
uchar_t *authData;
} CK_AES_CCM_PARAMS;
+
+#ifdef _KERNEL
+/*
+ * CK_ECDH1_DERIVE_PARAMS provides the parameters to the
+ * CKM_ECDH1_KEY_DERIVE mechanism
+ */
+typedef struct CK_ECDH1_DERIVE_PARAMS {
+ ulong_t kdf;
+ ulong_t ulSharedDataLen;
+ uchar_t *pSharedData;
+ ulong_t ulPublicDataLen;
+ uchar_t *pPublicData;
+} CK_ECDH1_DERIVE_PARAMS;
+#endif
+
#ifdef _KERNEL
#ifdef _SYSCALL32
@@ -101,6 +116,14 @@ typedef struct CK_AES_CCM_PARAMS32 {
caddr32_t authData;
} CK_AES_CCM_PARAMS32;
+typedef struct CK_ECDH1_DERIVE_PARAMS32 {
+ uint32_t kdf;
+ uint32_t ulSharedDataLen;
+ caddr32_t pSharedData;
+ uint32_t ulPublicDataLen;
+ caddr32_t pPublicData;
+} CK_ECDH1_DERIVE_PARAMS32;
+
#endif /* _SYSCALL32 */
#endif /* _KERNEL */
diff --git a/usr/src/uts/sun4v/sys/bignum.h b/usr/src/uts/sun4v/sys/bignum.h
index 4a9f16c2ef..1cd0b63483 100644
--- a/usr/src/uts/sun4v/sys/bignum.h
+++ b/usr/src/uts/sun4v/sys/bignum.h
@@ -19,7 +19,7 @@
* CDDL HEADER END
*/
/*
- * Copyright 2006 Sun Microsystems, Inc. All rights reserved.
+ * Copyright 2007 Sun Microsystems, Inc. All rights reserved.
* Use is subject to license terms.
*/
@@ -42,6 +42,7 @@ typedef int BIG_ERR_CODE;
#ifdef BIGNUM_CHUNK_32
#define BIG_CHUNK_SIZE 32
#define BIG_CHUNK_TYPE uint32_t
+#define BIG_CHUNK_TYPE_SIGNED int32_t
#define BIG_CHUNK_HIGHBIT 0x80000000
#define BIG_CHUNK_ALLBITS 0xffffffff
#define BIG_CHUNK_LOWHALFBITS 0xffff
@@ -49,6 +50,7 @@ typedef int BIG_ERR_CODE;
#else
#define BIG_CHUNK_SIZE 64
#define BIG_CHUNK_TYPE uint64_t
+#define BIG_CHUNK_TYPE_SIGNED int64_t
#define BIG_CHUNK_HIGHBIT 0x8000000000000000ULL
#define BIG_CHUNK_ALLBITS 0xffffffffffffffffULL
#define BIG_CHUNK_LOWHALFBITS 0xffffffffULL
@@ -116,6 +118,7 @@ typedef struct {
#define BIG_DIV_BY_0 -3
#define BIG_NO_RANDOM -4
#define BIG_TEST_FAILED -5
+#define BIG_BUFFER_TOO_SMALL -6
#define arraysize(x) (sizeof (x) / sizeof (x[0]))
@@ -133,13 +136,23 @@ BIG_ERR_CODE ncp_big_init(BIGNUM *number, int size);
BIG_ERR_CODE ncp_big_extend(BIGNUM *number, int size);
void ncp_big_finish(BIGNUM *number);
int ncp_big_is_zero(BIGNUM *n);
+int ncp_big_equals_one(BIGNUM *aa);
void ncp_kcl2bignum(BIGNUM *bn, uchar_t *kn, size_t len);
void ncp_bignum2kcl(uchar_t *kn, BIGNUM *bn, size_t len);
+BIG_ERR_CODE ncp_kcl_to_bignum(BIGNUM *bn,
+ uint8_t *kn, int knlen, int check, int mont,
+ int ispoly, BIGNUM *nn, int nndegree, BIG_CHUNK_TYPE nprime, BIGNUM *R);
+BIG_ERR_CODE ncp_bignum_to_kcl(uint8_t *kn, int *knlength,
+ BIGNUM *bn, int shorten, int mont, int ispoly,
+ BIGNUM *nn, BIG_CHUNK_TYPE nprime, BIGNUM *Rinv);
+BIG_ERR_CODE ncp_big_set_int(BIGNUM *tgt, BIG_CHUNK_TYPE_SIGNED value);
+BIG_ERR_CODE ncp_big_shiftright(BIGNUM *result, BIGNUM *aa, int offs);
BIG_ERR_CODE ncp_DSA_key_init(DSAkey *key, int size);
void ncp_DSA_key_finish(DSAkey *key);
BIG_ERR_CODE ncp_RSA_key_init(RSAkey *key, int psize, int qsize);
void ncp_RSA_key_finish(RSAkey *key);
BIG_ERR_CODE ncp_big_mont_rr(BIGNUM *result, BIGNUM *n);
+BIG_CHUNK_TYPE ncp_big_n0(BIG_CHUNK_TYPE n);
BIG_ERR_CODE ncp_big_modexp(BIGNUM *result, BIGNUM *a, BIGNUM *e,
BIGNUM *n, BIGNUM *n_rr, void *ncp, void *reqp);
BIG_ERR_CODE ncp_big_modexp_crt(BIGNUM *result, BIGNUM *a, BIGNUM *dmodpminus1,
@@ -153,12 +166,34 @@ BIG_ERR_CODE ncp_big_ext_gcd_pos(BIGNUM *gcd, BIGNUM *cm, BIGNUM *ce,
BIGNUM *m, BIGNUM *e);
BIG_ERR_CODE ncp_big_add(BIGNUM *result, BIGNUM *aa, BIGNUM *bb);
BIG_ERR_CODE ncp_big_mul(BIGNUM *result, BIGNUM *aa, BIGNUM *bb);
+BIG_ERR_CODE ncp_big_mul_extend(BIGNUM *result, BIGNUM *aa, BIGNUM *bb);
BIG_ERR_CODE ncp_big_nextprime_pos(BIGNUM *result, BIGNUM *n, void *ncp,
void *reqp);
BIG_ERR_CODE ncp_big_sub_pos(BIGNUM *result, BIGNUM *aa, BIGNUM *bb);
BIG_ERR_CODE ncp_big_copy(BIGNUM *dest, BIGNUM *src);
BIG_ERR_CODE ncp_big_sub(BIGNUM *result, BIGNUM *aa, BIGNUM *bb);
int ncp_big_bitlength(BIGNUM *n);
+int ncp_big_MSB(BIGNUM *X);
+int ncp_big_extract_bit(BIGNUM *aa, int k);
+BIG_ERR_CODE ncp_big_mod_add(BIGNUM *result,
+ BIGNUM *aa, BIGNUM *bb, BIGNUM *nn);
+BIG_ERR_CODE ncp_big_mod_sub(BIGNUM *result,
+ BIGNUM *aa, BIGNUM *bb, BIGNUM *nn);
+int ncp_big_poly_bit_k(BIGNUM *target, int k, BIGNUM *nn, unsigned int minlen);
+BIG_ERR_CODE ncp_big_mont_encode(BIGNUM *result, BIGNUM *input,
+ int ispoly, BIGNUM *nn, BIG_CHUNK_TYPE nprime, BIGNUM *R);
+BIG_ERR_CODE ncp_big_mont_decode(BIGNUM *result, BIGNUM *input,
+ int ispoly, BIGNUM *nn, BIG_CHUNK_TYPE nprime, BIGNUM *Rinv);
+BIG_ERR_CODE ncp_big_reduce(BIGNUM *target, BIGNUM *modulus, int ispoly);
+BIG_CHUNK_TYPE ncp_big_poly_nprime(BIGNUM *nn, int nndegree);
+BIG_ERR_CODE ncp_big_poly_add(BIGNUM *result, BIGNUM *aa, BIGNUM *bb);
+BIG_ERR_CODE ncp_big_poly_mont_mul(BIGNUM *result,
+ BIGNUM *aa, BIGNUM *bb, BIGNUM *nn, BIG_CHUNK_TYPE nprime);
+BIG_ERR_CODE ncp_big_mont_mul_extend(BIGNUM *ret,
+ BIGNUM *a, BIGNUM *b, BIGNUM *n, BIG_CHUNK_TYPE n0);
+BIG_ERR_CODE ncp_big_inverse(BIGNUM *result,
+ BIGNUM *aa, BIGNUM *nn, int poly, int mont,
+ BIGNUM *R2, BIG_CHUNK_TYPE nprime);
#ifdef __cplusplus
}