aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorAlex Stapleton <alexs@prol.etari.at>2014-01-19 11:39:57 +0000
committerAlex Stapleton <alexs@prol.etari.at>2014-01-19 11:45:39 +0000
commit259f30dc084d1eebec921b29ade3b37e0da29c19 (patch)
tree6ad76b0e45c818f16c5826f8037f8373f9df114a
parent489c525c5a42923f70c4bd5e95cb616d086595ad (diff)
downloadcryptography-259f30dc084d1eebec921b29ade3b37e0da29c19.tar.gz
cryptography-259f30dc084d1eebec921b29ade3b37e0da29c19.tar.bz2
cryptography-259f30dc084d1eebec921b29ade3b37e0da29c19.zip
Expose the innards of DH and DSA
So we can manually construct or serialise keys at some point. Also BN2BIN stuff because JWK uses the base64 version of this representation.
-rw-r--r--cryptography/hazmat/bindings/openssl/bignum.py3
-rw-r--r--cryptography/hazmat/bindings/openssl/dh.py8
-rw-r--r--cryptography/hazmat/bindings/openssl/dsa.py9
3 files changed, 18 insertions, 2 deletions
diff --git a/cryptography/hazmat/bindings/openssl/bignum.py b/cryptography/hazmat/bindings/openssl/bignum.py
index 59efd171..6545f329 100644
--- a/cryptography/hazmat/bindings/openssl/bignum.py
+++ b/cryptography/hazmat/bindings/openssl/bignum.py
@@ -47,6 +47,9 @@ char *BN_bn2hex(const BIGNUM *);
int BN_hex2bn(BIGNUM **, const char *);
int BN_dec2bn(BIGNUM **, const char *);
+int BN_bn2bin(const BIGNUM *, unsigned char *);
+BIGNUM *BN_bin2bn(const unsigned char *, int, BIGNUM *);
+
int BN_num_bits(const BIGNUM *);
"""
diff --git a/cryptography/hazmat/bindings/openssl/dh.py b/cryptography/hazmat/bindings/openssl/dh.py
index 3c12fbc6..edbe0e39 100644
--- a/cryptography/hazmat/bindings/openssl/dh.py
+++ b/cryptography/hazmat/bindings/openssl/dh.py
@@ -16,7 +16,13 @@ INCLUDES = """
"""
TYPES = """
-typedef ... DH;
+typedef struct dh_st {
+ BIGNUM *p; // prime number (shared)
+ BIGNUM *g; // generator of Z_p (shared)
+ BIGNUM *priv_key; // private DH value x
+ BIGNUM *pub_key; // public DH value g^x
+ ...;
+} DH;
"""
FUNCTIONS = """
diff --git a/cryptography/hazmat/bindings/openssl/dsa.py b/cryptography/hazmat/bindings/openssl/dsa.py
index 3b77d7ae..9068e057 100644
--- a/cryptography/hazmat/bindings/openssl/dsa.py
+++ b/cryptography/hazmat/bindings/openssl/dsa.py
@@ -16,7 +16,14 @@ INCLUDES = """
"""
TYPES = """
-typedef ... DSA;
+typedef struct dsa_st {
+ BIGNUM *p; // prime number (public)
+ BIGNUM *q; // 160-bit subprime, q | p-1 (public)
+ BIGNUM *g; // generator of subgroup (public)
+ BIGNUM *priv_key; // private key x
+ BIGNUM *pub_key; // public key y = g^x
+ ...;
+} DSA;
"""
FUNCTIONS = """