File tree Expand file tree Collapse file tree 3 files changed +29
-1
lines changed Expand file tree Collapse file tree 3 files changed +29
-1
lines changed Original file line number Diff line number Diff line change 1
1
Forge ChangeLog
2
2
===============
3
3
4
+ ## 1.3.1 - 2022-03-xx
5
+
6
+ ### Fixes
7
+ - RFC 3447 and RFC 8017 allow for optional ` DigestAlgorithm ` ` NULL ` parameters
8
+ for ` sha* ` algorithms and require ` NULL ` paramters for ` md2 ` and ` md5 `
9
+ algorithms.
10
+
4
11
## 1.3.0 - 2022-03-17
5
12
6
13
### Security
Original file line number Diff line number Diff line change @@ -286,6 +286,8 @@ var digestInfoValidator = {
286
286
name : 'DigestInfo.DigestAlgorithm.parameters' ,
287
287
tagClass : asn1 . Class . UNIVERSAL ,
288
288
type : asn1 . Type . NULL ,
289
+ // captured only to check existence for md2 and md5
290
+ capture : 'parameters' ,
289
291
optional : true ,
290
292
constructed : false
291
293
} ]
@@ -1188,6 +1190,16 @@ pki.setRsaPublicKey = pki.rsa.setPublicKey = function(n, e) {
1188
1190
throw error ;
1189
1191
}
1190
1192
1193
+ // special check for md2 and md5 that NULL parameters exist
1194
+ if ( oid === forge . oids . md2 || oid === forge . oids . md5 ) {
1195
+ if ( ! ( 'parameters' in capture ) ) {
1196
+ throw new Error (
1197
+ 'ASN.1 object does not contain a valid RSASSA-PKCS1-v1_5 ' +
1198
+ 'DigestInfo value. ' +
1199
+ 'Missing algorithm identifer NULL parameters.' ) ;
1200
+ }
1201
+ }
1202
+
1191
1203
// compare the given digest to the decrypted one
1192
1204
return digest === capture . digest ;
1193
1205
}
Original file line number Diff line number Diff line change @@ -845,6 +845,15 @@ var UTIL = require('../../lib/util');
845
845
/ ^ E r r o r : A S N .1 o b j e c t d o e s n o t c o n t a i n a v a l i d R S A S S A - P K C S 1 - v 1 _ 5 D i g e s t I n f o v a l u e .$ / ) ;
846
846
}
847
847
848
+ function _checkGoodDigestInfo ( publicKey , S , skipTailingGarbage ) {
849
+ var md = MD . sha256 . create ( ) ;
850
+ md . update ( m ) ;
851
+
852
+ ASSERT . ok ( publicKey . verify ( md . digest ( ) . getBytes ( ) , S , undefined , {
853
+ _parseAllDigestBytes : ! skipTailingGarbage
854
+ } ) ) ;
855
+ }
856
+
848
857
it ( 'should check DigestInfo structure' , function ( ) {
849
858
var publicKey = RSA . setPublicKey ( N , e ) ;
850
859
// 0xff bytes stolen from padding
@@ -904,7 +913,7 @@ var UTIL = require('../../lib/util');
904
913
'0bc1dd3f020cb1091af6b476416da3024ea046b09fbbbc4d2355da9a2bc6ddb9' ) ;
905
914
906
915
_checkBadTailingGarbage ( publicKey , S ) ;
907
- _checkBadDigestInfo ( publicKey , S , true ) ;
916
+ _checkGoodDigestInfo ( publicKey , S , true ) ;
908
917
} ) ;
909
918
910
919
it ( 'should check tailing garbage and DigestInfo [2]' , function ( ) {
You can’t perform that action at this time.
0 commit comments