소스 검색

[rsa] Actually check the unused-bits byte in the public key bit string

Signed-off-by: Michael Brown <mcb30@ipxe.org>
tags/v1.20.1
Michael Brown 13 년 전
부모
커밋
d6979e0d55
1개의 변경된 파일4개의 추가작업 그리고 3개의 파일을 삭제
  1. 4
    3
      src/crypto/rsa.c

+ 4
- 3
src/crypto/rsa.c 파일 보기

236
 
236
 
237
 		/* Check and skip unused-bits byte of bit string */
237
 		/* Check and skip unused-bits byte of bit string */
238
 		bit_string = cursor.data;
238
 		bit_string = cursor.data;
239
-		if ( cursor.len < 1 ) {
239
+		if ( ( cursor.len < sizeof ( *bit_string ) ) ||
240
+		     ( bit_string->unused != 0 ) ) {
240
 			rc = -EINVAL;
241
 			rc = -EINVAL;
241
 			goto err_parse;
242
 			goto err_parse;
242
 		}
243
 		}
243
-		cursor.data++;
244
-		cursor.len--;
244
+		cursor.data = &bit_string->data;
245
+		cursor.len -= offsetof ( typeof ( *bit_string ), data );
245
 
246
 
246
 		/* Enter RSAPublicKey */
247
 		/* Enter RSAPublicKey */
247
 		asn1_enter ( &cursor, ASN1_SEQUENCE );
248
 		asn1_enter ( &cursor, ASN1_SEQUENCE );

Loading…
취소
저장