@@ -118,7 +118,7 @@ mod test {
118118 use super :: * ;
119119 use crate :: buffer:: Buf ;
120120
121- // Test message with supported values:
121+ // Test message with recognized values:
122122 // - Certificate type: 0x40 (ECDSA_SIGN)
123123 // - Signature algorithms: SHA256/ECDSA (0x04, 0x03), SHA256/RSA (0x04, 0x01)
124124 const MESSAGE : & [ u8 ] = & [
@@ -135,15 +135,34 @@ mod test {
135135 ] ;
136136
137137 #[ test]
138- fn roundtrip ( ) {
138+ fn filters_unsupported_rsa_signature_algorithm ( ) {
139139 // Parse the message with base_offset 0
140140 let ( rest, parsed) = CertificateRequest :: parse ( MESSAGE , 0 ) . unwrap ( ) ;
141141 assert ! ( rest. is_empty( ) ) ;
142+ assert_eq ! ( parsed. supported_signature_algorithms. len( ) , 1 ) ;
143+ assert_eq ! (
144+ parsed. supported_signature_algorithms[ 0 ] ,
145+ SignatureAndHashAlgorithm :: new(
146+ super :: super :: HashAlgorithm :: SHA256 ,
147+ super :: super :: SignatureAlgorithm :: ECDSA ,
148+ )
149+ ) ;
142150
143- // Serialize and compare to MESSAGE
151+ // Serialization must not re-advertise the filtered RSA algorithm.
144152 let mut serialized = Buf :: new ( ) ;
145153 parsed. serialize ( MESSAGE , & mut serialized) ;
146- assert_eq ! ( & * serialized, MESSAGE ) ;
154+ let expected = [
155+ 0x01 , // Certificate types length (1 byte)
156+ 0x40 , // Certificate type: ECDSA_SIGN
157+ 0x00 , 0x02 , // Signature algorithms length (2 bytes = 1 algorithm)
158+ 0x04 , 0x03 , // SHA256/ECDSA
159+ 0x00 , 0x0C , // Certificate authorities length
160+ 0x00 , 0x04 , // Distinguished name 1 length
161+ 0x01 , 0x02 , 0x03 , 0x04 , // Distinguished name 1 data
162+ 0x00 , 0x04 , // Distinguished name 2 length
163+ 0x05 , 0x06 , 0x07 , 0x08 , // Distinguished name 2 data
164+ ] ;
165+ assert_eq ! ( & * serialized, expected) ;
147166 }
148167
149168 #[ test]
0 commit comments