Merge branch mbedtls-1.3 into development
* commit '95f0089':
Update Changelog for DH params
Add test case for dh params with privateValueLength
accept PKCS#3 DH parameters with privateValueLength included
Conflicts:
library/dhm.c
diff --git a/library/dhm.c b/library/dhm.c
index 05cbbd9..c5e41a3 100644
--- a/library/dhm.c
+++ b/library/dhm.c
@@ -444,8 +444,9 @@
/*
* DHParams ::= SEQUENCE {
- * prime INTEGER, -- P
- * generator INTEGER, -- g
+ * prime INTEGER, -- P
+ * generator INTEGER, -- g
+ * privateValueLength INTEGER OPTIONAL
* }
*/
if( ( ret = mbedtls_asn1_get_tag( &p, end, &len,
@@ -466,9 +467,23 @@
if( p != end )
{
- ret = MBEDTLS_ERR_DHM_INVALID_FORMAT +
- MBEDTLS_ERR_ASN1_LENGTH_MISMATCH;
- goto exit;
+ /* This might be the optional privateValueLength.
+ * If so, we can cleanly discard it */
+ mbedtls_mpi rec;
+ mbedtls_mpi_init( &rec );
+ ret = mbedtls_asn1_get_mpi( &p, end, &rec );
+ mbedtls_mpi_free( &rec );
+ if ( ret != 0 )
+ {
+ ret = MBEDTLS_ERR_DHM_INVALID_FORMAT + ret;
+ goto exit;
+ }
+ if ( p != end )
+ {
+ ret = MBEDTLS_ERR_DHM_INVALID_FORMAT +
+ MBEDTLS_ERR_ASN1_LENGTH_MISMATCH;
+ goto exit;
+ }
}
ret = 0;