PK sign/verify: hash=NULL is ok if md_alg=0 and hash_len=0
diff --git a/library/pk.c b/library/pk.c
index 38ab774..66301ee 100644
--- a/library/pk.c
+++ b/library/pk.c
@@ -240,7 +240,8 @@
                mbedtls_pk_restart_ctx *rs_ctx )
 {
     PK_VALIDATE_RET( ctx != NULL );
-    PK_VALIDATE_RET( hash != NULL );
+    PK_VALIDATE_RET( ( md_alg == MBEDTLS_MD_NONE && hash_len == 0 ) ||
+                     hash != NULL );
     PK_VALIDATE_RET( sig != NULL );
 
     if( ctx->pk_info == NULL ||
@@ -297,7 +298,8 @@
                    const unsigned char *sig, size_t sig_len )
 {
     PK_VALIDATE_RET( ctx != NULL );
-    PK_VALIDATE_RET( hash != NULL );
+    PK_VALIDATE_RET( ( md_alg == MBEDTLS_MD_NONE && hash_len == 0 ) ||
+                     hash != NULL );
     PK_VALIDATE_RET( sig != NULL );
 
     if( ctx->pk_info == NULL )
@@ -361,7 +363,8 @@
              mbedtls_pk_restart_ctx *rs_ctx )
 {
     PK_VALIDATE_RET( ctx != NULL );
-    PK_VALIDATE_RET( hash != NULL );
+    PK_VALIDATE_RET( ( md_alg == MBEDTLS_MD_NONE && hash_len == 0 ) ||
+                     hash != NULL );
     PK_VALIDATE_RET( sig != NULL );
 
     if( ctx->pk_info == NULL ||