mirror of
https://github.com/Mbed-TLS/mbedtls.git
synced 2025-08-01 10:06:53 +03:00
Test that SHA-1 defaults off
Added tests to validate that certificates signed using SHA-1 are rejected by default, but accepted if SHA-1 is explicitly enabled.
This commit is contained in:
committed by
Manuel Pégourié-Gonnard
parent
cd3c845157
commit
bc70a1836b
1
tests/data_files/.gitignore
vendored
1
tests/data_files/.gitignore
vendored
@ -1,2 +1,3 @@
|
||||
cli-rsa.csr
|
||||
server2-rsa.csr
|
||||
test-ca.csr
|
||||
|
@ -31,6 +31,14 @@ cli-rsa-sha256.crt: $(cli_crt_key_file_rsa) test-ca-sha256.crt cli-rsa.csr
|
||||
$(OPENSSL) x509 -req -extfile $(cli_crt_extensions_file) -extensions cli-rsa -CA test-ca-sha256.crt -CAkey $(test_ca_key_file_rsa) -passin "pass:$(test_ca_pwd_rsa)" -set_serial 4 -days 3653 -sha256 -in cli-rsa.csr -out $@
|
||||
all_final += cli-rsa-sha256.crt
|
||||
|
||||
server2-rsa.csr: server2.key
|
||||
$(OPENSSL) req -new -key server2.key -passin "pass:$(test_ca_pwd_rsa)" -subj "/C=NL/O=PolarSSL/CN=localhost" -out $@
|
||||
all_intermediate += server2-rsa.csr
|
||||
server2-sha256.crt: server2-rsa.csr
|
||||
$(OPENSSL) x509 -req -extfile $(cli_crt_extensions_file) -extensions cli-rsa -CA test-ca-sha256.crt -CAkey $(test_ca_key_file_rsa) -passin "pass:$(test_ca_pwd_rsa)" -set_serial 4 -days 3653 -sha256 -in server2-rsa.csr -out $@
|
||||
all_final += server2-sha256.crt
|
||||
|
||||
|
||||
all_final: $(all_final)
|
||||
all: $(all_intermediate) $(all_final)
|
||||
|
||||
|
21
tests/data_files/server2-sha256.crt
Normal file
21
tests/data_files/server2-sha256.crt
Normal file
@ -0,0 +1,21 @@
|
||||
-----BEGIN CERTIFICATE-----
|
||||
MIIDfTCCAmWgAwIBAgIBBDANBgkqhkiG9w0BAQsFADA7MQswCQYDVQQGEwJOTDER
|
||||
MA8GA1U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nOBDOiaCzintEcdJdY4F6p5j8jwMvVNVAXNfxAEwa0MoVRTt
|
||||
/GORvq4ZEfsatVA+HRi602m+dZETTWKSODrj8AuQcG8/i1AOhk3C1WNOFKj/ZSfB
|
||||
2P6EQmhLeRp4bO+3rG73T3R2yn0PZYQ7ZrjFPPKqgu+n
|
||||
-----END CERTIFICATE-----
|
@ -699,6 +699,40 @@ run_test "RC4: both enabled" \
|
||||
-S "SSL - None of the common ciphersuites is usable" \
|
||||
-S "SSL - The server has no ciphersuites in common"
|
||||
|
||||
# Tests for SHA-1 support
|
||||
|
||||
run_test "SHA-1 forbidden by default in server certificate" \
|
||||
"$P_SRV key_file=data_files/server2.key crt_file=data_files/server2.crt" \
|
||||
"$P_CLI debug_level=2 allow_sha1=0" \
|
||||
1 \
|
||||
-c "The certificate is signed with an unacceptable hash"
|
||||
|
||||
run_test "SHA-1 explicitly allowed in server certificate" \
|
||||
"$P_SRV key_file=data_files/server2.key crt_file=data_files/server2.crt" \
|
||||
"$P_CLI allow_sha1=1" \
|
||||
0
|
||||
|
||||
run_test "SHA-256 allowed by default in server certificate" \
|
||||
"$P_SRV key_file=data_files/server2.key crt_file=data_files/server2-sha256.crt" \
|
||||
"$P_CLI allow_sha1=0" \
|
||||
0
|
||||
|
||||
run_test "SHA-1 forbidden by default in client certificate" \
|
||||
"$P_SRV auth_mode=required allow_sha1=0" \
|
||||
"$P_CLI key_file=data_files/cli-rsa.key crt_file=data_files/cli-rsa-sha1.crt" \
|
||||
1 \
|
||||
-s "The certificate is signed with an unacceptable hash"
|
||||
|
||||
run_test "SHA-1 explicitly allowed in client certificate" \
|
||||
"$P_SRV auth_mode=required allow_sha1=1" \
|
||||
"$P_CLI key_file=data_files/cli-rsa.key crt_file=data_files/cli-rsa-sha1.crt" \
|
||||
0
|
||||
|
||||
run_test "SHA-256 allowed by default in client certificate" \
|
||||
"$P_SRV auth_mode=required allow_sha1=0" \
|
||||
"$P_CLI key_file=data_files/cli-rsa.key crt_file=data_files/cli-rsa-sha256.crt" \
|
||||
0
|
||||
|
||||
# Tests for Truncated HMAC extension
|
||||
|
||||
run_test "Truncated HMAC: client default, server default" \
|
||||
|
Reference in New Issue
Block a user