You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
69 lines
2.0 KiB
69 lines
2.0 KiB
// The differential of ECDSA and RSA against the Go reference on the VM,
|
|
// with every case of test/vectors/cms_ecdsa.json and cms_rsa.json. And the
|
|
// part of the files test/vectors/cms_*.json that cms_vectors.g.dart holds
|
|
// for the tests compiled to JavaScript: for each section, the cases whose
|
|
// index is a multiple of the step that "every" gives.
|
|
@TestOn('vm')
|
|
library;
|
|
|
|
import 'dart:convert';
|
|
import 'dart:io';
|
|
|
|
import 'package:test/test.dart';
|
|
|
|
import 'cms_support.dart';
|
|
import 'vectors/cms_vectors.g.dart';
|
|
|
|
const _embedded = {
|
|
'ecdsa': cmsEcdsaJson,
|
|
'rsa': cmsRsaJson,
|
|
'certs': cmsCertsJson,
|
|
'signatures': cmsSignaturesJson,
|
|
'algorithms': cmsAlgorithmsJson,
|
|
'tokens': cmsTokensJson,
|
|
'mutations': cmsMutationsJson,
|
|
'corpus': cmsCorpusJson,
|
|
};
|
|
|
|
void main() {
|
|
final files = {
|
|
for (final n in cmsFiles)
|
|
n: jsonDecode(
|
|
File('test/vectors/cms_$n.json').readAsStringSync(),
|
|
) as Json,
|
|
};
|
|
|
|
test('every file is of the draft v0.12 and of its generator', () {
|
|
for (final f in files.values) {
|
|
expect(f['spec'], '0.12 draft');
|
|
expect(f['generator'], startsWith('tool/cms_go_vectors_test.go, go'));
|
|
expect(f['source'], startsWith('datekeys-go c531e93'));
|
|
}
|
|
});
|
|
|
|
group('cms_vectors.g.dart', () {
|
|
for (final n in cmsFiles) {
|
|
test('holds the part of cms_$n.json of its steps', () {
|
|
final full = files[n]!;
|
|
final part = jsonDecode(_embedded[n]!) as Json;
|
|
final every = part['every']! as Json;
|
|
expect(part.keys.toSet(), {...full.keys, 'every'});
|
|
for (final MapEntry(:key, :value) in full.entries) {
|
|
final step = every[key] as int?;
|
|
if (step == null) {
|
|
expect(part[key], value, reason: key);
|
|
continue;
|
|
}
|
|
expect(part[key], [
|
|
for (final (i, c) in (value! as List).indexed)
|
|
if (step != 0 && i % step == 0) c,
|
|
], reason: key);
|
|
}
|
|
});
|
|
}
|
|
});
|
|
|
|
group('ECDSA', () => ecdsaTests(files['ecdsa']!));
|
|
group('RSA', () => rsaTests(files['rsa']!));
|
|
}
|