Skip to content

Commit 0b95aeb

Browse files
committed
FIX: TLS: using proper checksum method for message-hash (not only SHA256)
Also: * enabled rsa_pkcs1_sha512 TSL signature algorithm * using `Decode_error` alert instead of just _halting_ execution in some places
1 parent ae67956 commit 0b95aeb

File tree

1 file changed

+7
-8
lines changed

1 file changed

+7
-8
lines changed

src/mezz/prot-tls.r

+7-8
Original file line numberDiff line numberDiff line change
@@ -263,7 +263,7 @@ suported-cipher-suites: rejoin [
263263
]
264264

265265
supported-signature-algorithms: rejoin [
266-
;#{0601} ; rsa_pkcs1_sha512
266+
#{0601} ; rsa_pkcs1_sha512
267267
#{0602} ; SHA512 DSA
268268
;#{0603} ; ecdsa_secp521r1_sha512
269269
#{0501} ; rsa_pkcs1_sha384
@@ -1378,8 +1378,8 @@ TLS-read-handshake-message: function [
13781378
ctx/client-random
13791379
ctx/server-random
13801380
]
1381-
message-hash: checksum/method message 'sha256
1382-
;print ["??? signature message length:" length? message]
1381+
1382+
message-hash: checksum/method message hash-algorithm
13831383
;?? message-hash
13841384

13851385
either hash-algorithm = 'md5_sha1 [
@@ -1397,12 +1397,11 @@ TLS-read-handshake-message: function [
13971397
signature: decode 'der signature
13981398
]
13991399
;note tls1.3 is different a little bit here!
1400-
(probe message-hash) <> probe signature/sequence/octet_string
1400+
message-hash <> signature/sequence/octet_string
14011401
][
14021402
log-error "Failed to validate signature"
14031403
if error? err [print err]
1404-
halt
1405-
;@@TODO: alret: TLS_BROKEN_PACKET
1404+
return *Alert/Decode_error
14061405
]
14071406
log-more "Signature valid!"
14081407
]
@@ -1415,7 +1414,7 @@ TLS-read-handshake-message: function [
14151414
"Extra" len "bytes at the end of message:"
14161415
mold extra
14171416
]
1418-
halt
1417+
return *Alert/Decode_error
14191418
]
14201419

14211420
ctx/dh-key: dh-init dh_g dh_p
@@ -1440,7 +1439,7 @@ TLS-read-handshake-message: function [
14401439
if ends <> index? ctx/in/buffer [
14411440
log-error ["Positions:" ends index? ctx/in/buffer]
14421441
log-error "Looks we should read also something else!"
1443-
halt
1442+
return *Alert/Decode_error
14441443
]
14451444
]
14461445
;----------------------------------------------------------

0 commit comments

Comments
 (0)