aboutsummaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
authorAndreas Steffen <andreas.steffen@strongswan.org>2015-10-15 16:39:50 +0200
committerAndreas Steffen <andreas.steffen@strongswan.org>2015-11-03 19:07:15 +0100
commitde61e2cef4fbe75073335ab378fb2b54ec782aba (patch)
treed4157cbf282223db426e1c1aea33644a0e03143c /src
parent92ef3c2f216158b010b15faeaee0526dc9f71d5d (diff)
downloadstrongswan-de61e2cef4fbe75073335ab378fb2b54ec782aba.tar.bz2
strongswan-de61e2cef4fbe75073335ab378fb2b54ec782aba.tar.xz
Defined SHA-3 hashers
Diffstat (limited to 'src')
-rw-r--r--src/libstrongswan/asn1/oid.txt11
-rw-r--r--src/libstrongswan/crypto/hashers/hasher.c54
-rw-r--r--src/libstrongswan/crypto/hashers/hasher.h4
3 files changed, 59 insertions, 10 deletions
diff --git a/src/libstrongswan/asn1/oid.txt b/src/libstrongswan/asn1/oid.txt
index 919d24c43..d691426f4 100644
--- a/src/libstrongswan/asn1/oid.txt
+++ b/src/libstrongswan/asn1/oid.txt
@@ -226,6 +226,9 @@
0x01 "BLISS-with-SHA512" OID_BLISS_WITH_SHA512
0x02 "BLISS-with-SHA384" OID_BLISS_WITH_SHA384
0x03 "BLISS-with-SHA256" OID_BLISS_WITH_SHA256
+ 0x04 "BLISS-with-SHA3-512" OID_BLISS_WITH_SHA3_512
+ 0x05 "BLISS-with-SHA3-384" OID_BLISS_WITH_SHA3_384
+ 0x06 "BLISS-with-SHA3-256" OID_BLISS_WITH_SHA3_256
0x89 ""
0x31 ""
0x01 ""
@@ -435,10 +438,10 @@
0x04 "id-sha224" OID_SHA224
0x05 "id-sha512-224"
0x06 "id-sha512-256"
- 0x07 "id-sha3-224"
- 0x08 "id-sha3-256"
- 0x09 "id-sha3-384"
- 0x0A "id-sha3-512"
+ 0x07 "id-sha3-224" OID_SHA3_224
+ 0x08 "id-sha3-256" OID_SHA3_256
+ 0x09 "id-sha3-384" OID_SHA3_384
+ 0x0A "id-sha3-512" OID_SHA3_512
0x0B "id-shake128"
0x0C "id-shake256"
0x86 ""
diff --git a/src/libstrongswan/crypto/hashers/hasher.c b/src/libstrongswan/crypto/hashers/hasher.c
index 38eebea9c..5f8ea95a6 100644
--- a/src/libstrongswan/crypto/hashers/hasher.c
+++ b/src/libstrongswan/crypto/hashers/hasher.c
@@ -24,26 +24,34 @@ ENUM_BEGIN(hash_algorithm_names, HASH_SHA1, HASH_SHA512,
"HASH_SHA256",
"HASH_SHA384",
"HASH_SHA512");
-ENUM_NEXT(hash_algorithm_names, HASH_UNKNOWN, HASH_SHA224, HASH_SHA512,
+ENUM_NEXT(hash_algorithm_names, HASH_UNKNOWN, HASH_SHA3_512, HASH_SHA512,
"HASH_UNKNOWN",
"HASH_MD2",
"HASH_MD4",
"HASH_MD5",
- "HASH_SHA224");
-ENUM_END(hash_algorithm_names, HASH_SHA224);
+ "HASH_SHA224",
+ "HASH_SHA3_224",
+ "HASH_SHA3_256",
+ "HASH_SHA3_384",
+ "HASH_SHA3_512");
+ENUM_END(hash_algorithm_names, HASH_SHA3_512);
ENUM_BEGIN(hash_algorithm_short_names, HASH_SHA1, HASH_SHA512,
"sha1",
"sha256",
"sha384",
"sha512");
-ENUM_NEXT(hash_algorithm_short_names, HASH_UNKNOWN, HASH_SHA224, HASH_SHA512,
+ENUM_NEXT(hash_algorithm_short_names, HASH_UNKNOWN, HASH_SHA3_512, HASH_SHA512,
"unknown",
"md2",
"md4",
"md5",
- "sha224");
-ENUM_END(hash_algorithm_short_names, HASH_SHA224);
+ "sha224",
+ "sha3_224",
+ "sha3_256",
+ "sha3_384",
+ "sha3_512");
+ENUM_END(hash_algorithm_short_names, HASH_SHA3_512);
/*
* Described in header.
@@ -73,6 +81,14 @@ hash_algorithm_t hasher_algorithm_from_oid(int oid)
case OID_SHA512:
case OID_SHA512_WITH_RSA:
return HASH_SHA512;
+ case OID_SHA3_224:
+ return HASH_SHA3_224;
+ case OID_SHA3_256:
+ return HASH_SHA3_256;
+ case OID_SHA3_384:
+ return HASH_SHA3_384;
+ case OID_SHA3_512:
+ return HASH_SHA3_512;
default:
return HASH_UNKNOWN;
}
@@ -242,6 +258,10 @@ integrity_algorithm_t hasher_algorithm_to_integrity(hash_algorithm_t alg,
case HASH_MD2:
case HASH_MD4:
case HASH_SHA224:
+ case HASH_SHA3_224:
+ case HASH_SHA3_256:
+ case HASH_SHA3_384:
+ case HASH_SHA3_512:
case HASH_UNKNOWN:
break;
}
@@ -265,6 +285,10 @@ bool hasher_algorithm_for_ikev2(hash_algorithm_t alg)
case HASH_MD4:
case HASH_MD5:
case HASH_SHA224:
+ case HASH_SHA3_224:
+ case HASH_SHA3_256:
+ case HASH_SHA3_384:
+ case HASH_SHA3_512:
break;
}
return FALSE;
@@ -300,6 +324,18 @@ int hasher_algorithm_to_oid(hash_algorithm_t alg)
case HASH_SHA512:
oid = OID_SHA512;
break;
+ case HASH_SHA3_224:
+ oid = OID_SHA3_224;
+ break;
+ case HASH_SHA3_256:
+ oid = OID_SHA3_256;
+ break;
+ case HASH_SHA3_384:
+ oid = OID_SHA3_384;
+ break;
+ case HASH_SHA3_512:
+ oid = OID_SHA3_512;
+ break;
default:
oid = OID_UNKNOWN;
}
@@ -356,6 +392,12 @@ int hasher_signature_algorithm_to_oid(hash_algorithm_t alg, key_type_t key)
return OID_BLISS_WITH_SHA384;
case HASH_SHA512:
return OID_BLISS_WITH_SHA512;
+ case HASH_SHA3_256:
+ return OID_BLISS_WITH_SHA3_256;
+ case HASH_SHA3_384:
+ return OID_BLISS_WITH_SHA3_384;
+ case HASH_SHA3_512:
+ return OID_BLISS_WITH_SHA3_512;
default:
return OID_UNKNOWN;
}
diff --git a/src/libstrongswan/crypto/hashers/hasher.h b/src/libstrongswan/crypto/hashers/hasher.h
index 772586308..272502cf0 100644
--- a/src/libstrongswan/crypto/hashers/hasher.h
+++ b/src/libstrongswan/crypto/hashers/hasher.h
@@ -45,6 +45,10 @@ enum hash_algorithm_t {
HASH_MD4 = 1026,
HASH_MD5 = 1027,
HASH_SHA224 = 1028,
+ HASH_SHA3_224 = 1029,
+ HASH_SHA3_256 = 1030,
+ HASH_SHA3_384 = 1031,
+ HASH_SHA3_512 = 1032
};
#define HASH_SIZE_MD2 16