aboutsummaryrefslogtreecommitdiffstats
path: root/src/lib/pubkey
diff options
context:
space:
mode:
authorJack Lloyd <[email protected]>2019-08-01 09:20:26 -0400
committerJack Lloyd <[email protected]>2019-08-01 09:26:00 -0400
commitcb90f825466b08cf8a64c042e72b40d9191f2033 (patch)
tree14d677e41a51891eafd750c04162a2fdd40a88ac /src/lib/pubkey
parentfdf9970f921bf6b3e99c2a99ebc251b6e5dd760e (diff)
Updates for GOST 2012 support
GOST uses IEEE style formatting for signatures rather than DER struct. Confirmed using 2012 test certs from CryptoPro GH #1860 #1897
Diffstat (limited to 'src/lib/pubkey')
-rw-r--r--src/lib/pubkey/ec_group/ec_named.cpp2
-rw-r--r--src/lib/pubkey/ecc_key/info.txt1
-rw-r--r--src/lib/pubkey/gost_3410/gost_3410.h3
-rw-r--r--src/lib/pubkey/pk_algs.cpp4
-rw-r--r--src/lib/pubkey/pk_keys.h10
-rw-r--r--src/lib/pubkey/pubkey.h5
6 files changed, 17 insertions, 8 deletions
diff --git a/src/lib/pubkey/ec_group/ec_named.cpp b/src/lib/pubkey/ec_group/ec_named.cpp
index ba91b5eaa..3687fabdf 100644
--- a/src/lib/pubkey/ec_group/ec_named.cpp
+++ b/src/lib/pubkey/ec_group/ec_named.cpp
@@ -114,7 +114,7 @@ std::shared_ptr<EC_Group_Data> EC_Group::EC_group_info(const OID& oid)
"0xF1FD178C0B3AD58F10126DE8CE42435B53DC67E140D2BF941FFDD459C6D655E1",
oid);
// gost_256A
- if(oid == OID{1,2,643,2,2,35,1})
+ if(oid == OID{1,2,643,2,2,35,1} || oid == OID{1,2,643,2,2,36,0} || oid == OID{1,2,643,7,1,2,1,1,1})
return load_EC_group_info("0xFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFD97",
"0xFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFD94",
"0xA6",
diff --git a/src/lib/pubkey/ecc_key/info.txt b/src/lib/pubkey/ecc_key/info.txt
index f46c9bb54..32d05f2f9 100644
--- a/src/lib/pubkey/ecc_key/info.txt
+++ b/src/lib/pubkey/ecc_key/info.txt
@@ -1,5 +1,6 @@
<defines>
ECC_PUBLIC_KEY_CRYPTO -> 20131128
+ECC_KEY -> 20190801
</defines>
<requires>
diff --git a/src/lib/pubkey/gost_3410/gost_3410.h b/src/lib/pubkey/gost_3410/gost_3410.h
index 52b6ad758..8c42f5091 100644
--- a/src/lib/pubkey/gost_3410/gost_3410.h
+++ b/src/lib/pubkey/gost_3410/gost_3410.h
@@ -53,6 +53,9 @@ class BOTAN_PUBLIC_API(2,0) GOST_3410_PublicKey : public virtual EC_PublicKey
size_t message_part_size() const override
{ return domain().get_order().bytes(); }
+ Signature_Format default_x509_signature_format() const
+ { return IEEE_1363; }
+
std::unique_ptr<PK_Ops::Verification>
create_verification_op(const std::string& params,
const std::string& provider) const override;
diff --git a/src/lib/pubkey/pk_algs.cpp b/src/lib/pubkey/pk_algs.cpp
index 16bfbfb1f..126f27cd4 100644
--- a/src/lib/pubkey/pk_algs.cpp
+++ b/src/lib/pubkey/pk_algs.cpp
@@ -146,7 +146,7 @@ load_public_key(const AlgorithmIdentifier& alg_id,
#endif
#if defined(BOTAN_HAS_GOST_34_10_2001)
- if(alg_name == "GOST-34.10")
+ if(alg_name == "GOST-34.10" || alg_name == "GOST-34.10-2012-256" || alg_name == "GOST-34.10-2012-512")
return std::unique_ptr<Public_Key>(new GOST_3410_PublicKey(alg_id, key_bits));
#endif
@@ -222,7 +222,7 @@ load_private_key(const AlgorithmIdentifier& alg_id,
#endif
#if defined(BOTAN_HAS_GOST_34_10_2001)
- if(alg_name == "GOST-34.10")
+ if(alg_name == "GOST-34.10" || alg_name == "GOST-34.10-2012-256" || alg_name == "GOST-34.10-2012-512")
return std::unique_ptr<Private_Key>(new GOST_3410_PrivateKey(alg_id, key_bits));
#endif
diff --git a/src/lib/pubkey/pk_keys.h b/src/lib/pubkey/pk_keys.h
index 0aa9caf54..e7e86d8fa 100644
--- a/src/lib/pubkey/pk_keys.h
+++ b/src/lib/pubkey/pk_keys.h
@@ -19,6 +19,11 @@ namespace Botan {
class RandomNumberGenerator;
/**
+* The two types of signature format supported by Botan.
+*/
+enum Signature_Format { IEEE_1363, DER_SEQUENCE };
+
+/**
* Public Key Base Class.
*/
class BOTAN_PUBLIC_API(2,0) Public_Key
@@ -118,6 +123,11 @@ class BOTAN_PUBLIC_API(2,0) Public_Key
*/
virtual size_t message_part_size() const { return 0; }
+ virtual Signature_Format default_x509_signature_format() const
+ {
+ return (this->message_parts() >= 2) ? DER_SEQUENCE : IEEE_1363;
+ }
+
/**
* This is an internal library function exposed on key types.
* In almost all cases applications should use wrappers in pubkey.h
diff --git a/src/lib/pubkey/pubkey.h b/src/lib/pubkey/pubkey.h
index dc4ef6ee6..2aa8ea916 100644
--- a/src/lib/pubkey/pubkey.h
+++ b/src/lib/pubkey/pubkey.h
@@ -23,11 +23,6 @@ namespace Botan {
class RandomNumberGenerator;
/**
-* The two types of signature format supported by Botan.
-*/
-enum Signature_Format { IEEE_1363, DER_SEQUENCE };
-
-/**
* Public Key Encryptor
* This is the primary interface for public key encryption
*/