@@ -7,79 +7,79 @@ import {
7
7
generators ,
8
8
issueCloned
9
9
} from 'data-integrity-test-suite-assertion' ;
10
- import { createInitialVc , endpointCheck } from '../helpers.js' ;
11
10
import { getMultiKey } from '../vc-generator/key-gen.js' ;
12
11
import { getSuites } from './helpers.js' ;
13
- import { localVerifier } from '../vc-verifier/index.js' ;
14
12
15
13
export function commonAlgorithms ( {
16
14
credential,
17
- issuers ,
15
+ verifiers ,
18
16
mandatoryPointers,
19
- keyType ,
20
- cryptosuite ,
17
+ selectivePointers ,
18
+ keyTypes ,
21
19
suiteName,
22
- vcVersion
20
+ vcVersion,
21
+ setup = _commonSetup
23
22
} ) {
24
- const verifier = localVerifier ( { cryptosuite} ) ;
25
- for ( const [ name , { endpoints} ] of issuers ) {
26
- const [ issuer ] = endpoints ;
27
- // does the endpoint support this test?
28
- if ( ! endpointCheck ( { endpoint : issuer , keyType, vcVersion} ) ) {
29
- continue ;
30
- }
31
- describe ( `${ name } : ${ keyType } ` , function ( ) {
32
- let securedCredential = null ;
33
- before ( async function ( ) {
34
- securedCredential = await createInitialVc ( {
35
- issuer,
36
- vcVersion,
37
- vc : credential ,
38
- mandatoryPointers
23
+ const title = `${ suiteName } - Algorithms Common - VC ${ vcVersion } ` ;
24
+ return describe ( title , function ( ) {
25
+ const credentials = new Map ( keyTypes . map ( keyType => [ keyType , null ] ) ) ;
26
+ before ( async function ( ) {
27
+ for ( const keyType of keyTypes ) {
28
+ credentials . set ( keyType , await setup ( {
29
+ credential,
30
+ verifiers,
31
+ mandatoryPointers,
32
+ selectivePointers,
33
+ keyType,
34
+ suiteName,
35
+ vcVersion
36
+ } ) ) ;
37
+ }
38
+ } ) ;
39
+ for ( const [ name , { endpoints} ] of verifiers ) {
40
+ const [ verifier ] = endpoints ;
41
+ describe ( `${ name } ` , function ( ) {
42
+ beforeEach ( function ( ) {
43
+ this . currentTest . cell = {
44
+ rowId : this . currentTest . title ,
45
+ columnId : this . currentTest . parent . title
46
+ } ;
39
47
} ) ;
40
- } ) ;
41
- beforeEach ( function ( ) {
42
- this . currentTest . cell = {
43
- rowId : this . currentTest . title ,
44
- columnId : this . currentTest . parent . title
45
- } ;
46
- } ) ;
47
- it ( 'When generating ECDSA signatures, the signature value MUST be ' +
48
- 'expressed according to section 7 of [RFC4754] (sometimes referred ' +
49
- 'to as the IEEE P1363 format) and encoded according to the specific ' +
50
- 'cryptosuite proof generation algorithm.' , async function ( ) {
51
- this . test . link = 'https://w3c.github.io/vc-di-ecdsa/#algorithms:~:text=When%20generating%20ECDSA%20signatures%2C%20the%20signature%20value%20MUST%20be%20expressed%20according%20to%20section%207%20of%20%5BRFC4754%5D%20(sometimes%20referred%20to%20as%20the%20IEEE%20P1363%20format)%20and%20encoded%20according%20to%20the%20specific%20cryptosuite%20proof%20generation%20algorithm' ;
52
- await assertions . verificationSuccess ( {
53
- credential : securedCredential ,
54
- verifier,
55
- reason : `Should verify VC signed with ${ suiteName } ${ keyType } `
48
+ it ( 'When generating ECDSA signatures, the signature value MUST be ' +
49
+ 'expressed according to section 7 of [RFC4754] (sometimes referred ' +
50
+ 'to as the IEEE P1363 format) and encoded according to the ' +
51
+ 'specific cryptosuite proof generation algorithm.' , async function ( ) {
52
+ this . test . link = 'https://w3c.github.io/vc-di-ecdsa/#algorithms:~:text=When%20generating%20ECDSA%20signatures%2C%20the%20signature%20value%20MUST%20be%20expressed%20according%20to%20section%207%20of%20%5BRFC4754%5D%20(sometimes%20referred%20to%20as%20the%20IEEE%20P1363%20format)%20and%20encoded%20according%20to%20the%20specific%20cryptosuite%20proof%20generation%20algorithm' ;
53
+ for ( const [ keyType , fixtures ] of credentials ) {
54
+ await assertions . verificationSuccess ( {
55
+ credential : fixtures . get ( 'invalidHash' ) ,
56
+ verifier,
57
+ reason : `Should not verify VC signed w/ ${ keyType } & invalidHash.`
58
+ } ) ;
59
+ }
56
60
} ) ;
57
- } ) ;
58
- if ( keyType === 'P-256' ) {
59
61
it ( 'For P-256 keys, the default hashing function, SHA-2 with 256 bits' +
60
62
'of output, MUST be used.' , async function ( ) {
61
63
this . test . link = 'https://w3c.github.io/vc-di-ecdsa/#algorithms:~:text=For%20P%2D256%20keys%2C%20the%20default%20hashing%20function%2C%20SHA%2D2%20with%20256%20bits%20of%20output%2C%20MUST%20be%20used.' ;
62
64
await assertions . verificationSuccess ( {
63
- credential : securedCredential ,
65
+ credential : credentials . get ( 'P-256' ) . get ( 'invalidHash' ) ,
64
66
verifier,
65
- reason : `Should verify VC signed with ${ suiteName } ${ keyType } `
67
+ reason : `Should not verify VC with invalid hash. `
66
68
} ) ;
67
69
} ) ;
68
- }
69
- if ( keyType === 'P-384' ) {
70
70
it ( 'For P-384 keys, SHA-2 with 384-bits of output MUST be used, ' +
71
71
'specified via the RDFC-1.0 implementation-specific parameter.' ,
72
72
async function ( ) {
73
73
this . test . link = 'https://w3c.github.io/vc-di-ecdsa/#algorithms:~:text=For%20P%2D384%20keys%2C%20SHA%2D2%20with%20384%2Dbits%20of%20output%20MUST%20be%20used%2C%20specified%20via%20the%20RDFC%2D1.0%20implementation%2Dspecific%20parameter.' ;
74
- await assertions . verificationSuccess ( {
75
- credential : securedCredential ,
74
+ await assertions . verificationFail ( {
75
+ credential : credentials . get ( 'P-384' ) . get ( 'invalidHash' ) ,
76
76
verifier,
77
- reason : `Should verify VC signed with ${ suiteName } ${ keyType } `
77
+ reason : `Should not verify VC with invalid hash. `
78
78
} ) ;
79
79
} ) ;
80
- }
81
- } ) ;
82
- }
80
+ } ) ;
81
+ }
82
+ } ) ;
83
83
}
84
84
85
85
export function ecdsaRdfc2019Algorithms ( {
@@ -290,3 +290,7 @@ function unsafeProxy(suite) {
290
290
}
291
291
} ) ;
292
292
}
293
+
294
+ function _commonSetup ( { } ) {
295
+
296
+ }
0 commit comments