Skip to content

Commit 7a949ad

Browse files
committed
deps: @sigstore/verify@3.1.0
1 parent 6979ce1 commit 7a949ad

File tree

16 files changed

+238
-90
lines changed

16 files changed

+238
-90
lines changed

node_modules/@sigstore/verify/dist/bundle/dsse.js

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,7 @@ limitations under the License.
1818
*/
1919
const core_1 = require("@sigstore/core");
2020
class DSSESignatureContent {
21+
env;
2122
constructor(env) {
2223
this.env = env;
2324
}

node_modules/@sigstore/verify/dist/bundle/index.js

Lines changed: 10 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -9,15 +9,17 @@ function toSignedEntity(bundle, artifact) {
99
const { tlogEntries, timestampVerificationData } = bundle.verificationMaterial;
1010
const timestamps = [];
1111
for (const entry of tlogEntries) {
12-
timestamps.push({
13-
$case: 'transparency-log',
14-
tlogEntry: entry,
15-
});
12+
if (entry.integratedTime && entry.integratedTime !== '0') {
13+
timestamps.push({
14+
$case: 'transparency-log',
15+
tlogEntry: entry,
16+
});
17+
}
1618
}
1719
for (const ts of timestampVerificationData?.rfc3161Timestamps ?? []) {
1820
timestamps.push({
1921
$case: 'timestamp-authority',
20-
timestamp: core_1.RFC3161Timestamp.parse(ts.signedTimestamp),
22+
timestamp: core_1.RFC3161Timestamp.parse(Buffer.from(ts.signedTimestamp)),
2123
});
2224
}
2325
return {
@@ -45,13 +47,13 @@ function key(bundle) {
4547
case 'x509CertificateChain':
4648
return {
4749
$case: 'certificate',
48-
certificate: core_1.X509Certificate.parse(bundle.verificationMaterial.content.x509CertificateChain
49-
.certificates[0].rawBytes),
50+
certificate: core_1.X509Certificate.parse(Buffer.from(bundle.verificationMaterial.content.x509CertificateChain
51+
.certificates[0].rawBytes)),
5052
};
5153
case 'certificate':
5254
return {
5355
$case: 'certificate',
54-
certificate: core_1.X509Certificate.parse(bundle.verificationMaterial.content.certificate.rawBytes),
56+
certificate: core_1.X509Certificate.parse(Buffer.from(bundle.verificationMaterial.content.certificate.rawBytes)),
5557
};
5658
}
5759
}

node_modules/@sigstore/verify/dist/bundle/message.js

Lines changed: 19 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,11 +17,29 @@ See the License for the specific language governing permissions and
1717
limitations under the License.
1818
*/
1919
const core_1 = require("@sigstore/core");
20+
const protobuf_specs_1 = require("@sigstore/protobuf-specs");
21+
// Map from the Sigstore protobuf HashAlgorithm enum to
22+
// the string values used by the Node.js crypto module.
23+
const HASH_ALGORITHM_MAP = {
24+
[protobuf_specs_1.HashAlgorithm.HASH_ALGORITHM_UNSPECIFIED]: 'sha256',
25+
[protobuf_specs_1.HashAlgorithm.SHA2_256]: 'sha256',
26+
[protobuf_specs_1.HashAlgorithm.SHA2_384]: 'sha384',
27+
[protobuf_specs_1.HashAlgorithm.SHA2_512]: 'sha512',
28+
[protobuf_specs_1.HashAlgorithm.SHA3_256]: 'sha3-256',
29+
[protobuf_specs_1.HashAlgorithm.SHA3_384]: 'sha3-384',
30+
};
2031
class MessageSignatureContent {
32+
signature;
33+
messageDigest;
34+
artifact;
35+
hashAlgorithm;
2136
constructor(messageSignature, artifact) {
2237
this.signature = messageSignature.signature;
2338
this.messageDigest = messageSignature.messageDigest.digest;
2439
this.artifact = artifact;
40+
this.hashAlgorithm =
41+
HASH_ALGORITHM_MAP[messageSignature.messageDigest.algorithm] ??
42+
/* istanbul ignore next */ 'sha256';
2543
}
2644
compareSignature(signature) {
2745
return core_1.crypto.bufferEqual(signature, this.signature);
@@ -30,7 +48,7 @@ class MessageSignatureContent {
3048
return core_1.crypto.bufferEqual(digest, this.messageDigest);
3149
}
3250
verifySignature(key) {
33-
return core_1.crypto.verify(this.artifact, key, this.signature);
51+
return core_1.crypto.verify(this.artifact, key, this.signature, this.hashAlgorithm);
3452
}
3553
}
3654
exports.MessageSignatureContent = MessageSignatureContent;

node_modules/@sigstore/verify/dist/error.js

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,8 @@ See the License for the specific language governing permissions and
1717
limitations under the License.
1818
*/
1919
class BaseError extends Error {
20+
code;
21+
cause; /* eslint-disable-line @typescript-eslint/no-explicit-any */
2022
constructor({ code, message, cause, }) {
2123
super(message);
2224
this.code = code;

node_modules/@sigstore/verify/dist/key/certificate.js

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -32,6 +32,10 @@ function verifyCertificateChain(timestamp, leaf, certificateAuthorities) {
3232
});
3333
}
3434
class CertificateChainVerifier {
35+
untrustedCert;
36+
trustedCerts;
37+
localCerts;
38+
timestamp;
3539
constructor(opts) {
3640
this.untrustedCert = opts.untrustedCert;
3741
this.trustedCerts = opts.trustedCerts;
Lines changed: 4 additions & 30 deletions
Original file line numberDiff line numberDiff line change
@@ -1,46 +1,20 @@
11
"use strict";
22
Object.defineProperty(exports, "__esModule", { value: true });
3-
exports.verifyTSATimestamp = verifyTSATimestamp;
4-
exports.verifyTLogTimestamp = verifyTLogTimestamp;
5-
const error_1 = require("../error");
6-
const checkpoint_1 = require("./checkpoint");
7-
const merkle_1 = require("./merkle");
8-
const set_1 = require("./set");
3+
exports.getTSATimestamp = getTSATimestamp;
4+
exports.getTLogTimestamp = getTLogTimestamp;
95
const tsa_1 = require("./tsa");
10-
function verifyTSATimestamp(timestamp, data, timestampAuthorities) {
6+
function getTSATimestamp(timestamp, data, timestampAuthorities) {
117
(0, tsa_1.verifyRFC3161Timestamp)(timestamp, data, timestampAuthorities);
128
return {
139
type: 'timestamp-authority',
1410
logID: timestamp.signerSerialNumber,
1511
timestamp: timestamp.signingTime,
1612
};
1713
}
18-
function verifyTLogTimestamp(entry, tlogAuthorities) {
19-
let inclusionVerified = false;
20-
if (isTLogEntryWithInclusionPromise(entry)) {
21-
(0, set_1.verifyTLogSET)(entry, tlogAuthorities);
22-
inclusionVerified = true;
23-
}
24-
if (isTLogEntryWithInclusionProof(entry)) {
25-
(0, merkle_1.verifyMerkleInclusion)(entry);
26-
(0, checkpoint_1.verifyCheckpoint)(entry, tlogAuthorities);
27-
inclusionVerified = true;
28-
}
29-
if (!inclusionVerified) {
30-
throw new error_1.VerificationError({
31-
code: 'TLOG_MISSING_INCLUSION_ERROR',
32-
message: 'inclusion could not be verified',
33-
});
34-
}
14+
function getTLogTimestamp(entry) {
3515
return {
3616
type: 'transparency-log',
3717
logID: entry.logId.keyId,
3818
timestamp: new Date(Number(entry.integratedTime) * 1000),
3919
};
4020
}
41-
function isTLogEntryWithInclusionPromise(entry) {
42-
return entry.inclusionPromise !== undefined;
43-
}
44-
function isTLogEntryWithInclusionProof(entry) {
45-
return entry.inclusionProof !== undefined;
46-
}

node_modules/@sigstore/verify/dist/timestamp/checkpoint.js renamed to node_modules/@sigstore/verify/dist/tlog/checkpoint.js

Lines changed: 15 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,9 @@
11
"use strict";
22
Object.defineProperty(exports, "__esModule", { value: true });
3+
exports.LogCheckpoint = void 0;
34
exports.verifyCheckpoint = verifyCheckpoint;
45
/*
5-
Copyright 2023 The Sigstore Authors.
6+
Copyright 2025 The Sigstore Authors.
67
78
Licensed under the Apache License, Version 2.0 (the "License");
89
you may not use this file except in compliance with the License.
@@ -18,7 +19,6 @@ limitations under the License.
1819
*/
1920
const core_1 = require("@sigstore/core");
2021
const error_1 = require("../error");
21-
const trust_1 = require("../trust");
2222
// Separator between the note and the signatures in a checkpoint
2323
const CHECKPOINT_SEPARATOR = '\n\n';
2424
// Checkpoint signatures are of the following form:
@@ -37,39 +37,29 @@ const SIGNATURE_REGEX = /\u2014 (\S+) (\S+)\n/g;
3737
// inclusion proof
3838
// See: https://github.com/transparency-dev/formats/blob/main/log/README.md
3939
function verifyCheckpoint(entry, tlogs) {
40-
// Filter tlog instances to just those which were valid at the time of the
41-
// entry
42-
const validTLogs = (0, trust_1.filterTLogAuthorities)(tlogs, {
43-
targetDate: new Date(Number(entry.integratedTime) * 1000),
44-
});
4540
const inclusionProof = entry.inclusionProof;
4641
const signedNote = SignedNote.fromString(inclusionProof.checkpoint.envelope);
4742
const checkpoint = LogCheckpoint.fromString(signedNote.note);
4843
// Verify that the signatures in the checkpoint are all valid
49-
if (!verifySignedNote(signedNote, validTLogs)) {
44+
if (!verifySignedNote(signedNote, tlogs)) {
5045
throw new error_1.VerificationError({
5146
code: 'TLOG_INCLUSION_PROOF_ERROR',
5247
message: 'invalid checkpoint signature',
5348
});
5449
}
55-
// Verify that the root hash from the checkpoint matches the root hash in the
56-
// inclusion proof
57-
if (!core_1.crypto.bufferEqual(checkpoint.logHash, inclusionProof.rootHash)) {
58-
throw new error_1.VerificationError({
59-
code: 'TLOG_INCLUSION_PROOF_ERROR',
60-
message: 'root hash mismatch',
61-
});
62-
}
50+
return checkpoint;
6351
}
6452
// Verifies the signatures in the SignedNote. For each signature, the
6553
// corresponding transparency log is looked up by the key hint and the
6654
// signature is verified against the public key in the transparency log.
6755
// Throws an error if any of the signatures are invalid.
6856
function verifySignedNote(signedNote, tlogs) {
6957
const data = Buffer.from(signedNote.note, 'utf-8');
70-
return signedNote.signatures.every((signature) => {
58+
return signedNote.signatures.some((signature) => {
7159
// Find the transparency log instance with the matching key hint
72-
const tlog = tlogs.find((tlog) => core_1.crypto.bufferEqual(tlog.logID.subarray(0, 4), signature.keyHint));
60+
const tlog = tlogs.find((tlog) => core_1.crypto.bufferEqual(tlog.logID.subarray(0, 4), signature.keyHint) &&
61+
tlog.baseURL.match(signature.name) // Match the name to the base URL of the tlog
62+
);
7363
if (!tlog) {
7464
return false;
7565
}
@@ -80,6 +70,8 @@ function verifySignedNote(signedNote, tlogs) {
8070
// of a body (or note) and one more signatures calculated over the body. See
8171
// https://github.com/transparency-dev/formats/blob/main/log/README.md#signed-envelope
8272
class SignedNote {
73+
note;
74+
signatures;
8375
constructor(note, signatures) {
8476
this.note = note;
8577
this.signatures = signatures;
@@ -134,6 +126,10 @@ class SignedNote {
134126
// See:
135127
// https://github.com/transparency-dev/formats/blob/main/log/README.md#checkpoint-body
136128
class LogCheckpoint {
129+
origin;
130+
logSize;
131+
logHash;
132+
rest;
137133
constructor(origin, logSize, logHash, rest) {
138134
this.origin = origin;
139135
this.logSize = logSize;
@@ -155,3 +151,4 @@ class LogCheckpoint {
155151
return new LogCheckpoint(origin, logSize, rootHash, rest);
156152
}
157153
}
154+
exports.LogCheckpoint = LogCheckpoint;

node_modules/@sigstore/verify/dist/tlog/dsse.js

Lines changed: 52 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,10 @@
11
"use strict";
22
Object.defineProperty(exports, "__esModule", { value: true });
3+
exports.DSSE_API_VERSION_V1 = void 0;
34
exports.verifyDSSETLogBody = verifyDSSETLogBody;
5+
exports.verifyDSSETLogBodyV2 = verifyDSSETLogBodyV2;
46
/*
5-
Copyright 2023 The Sigstore Authors.
7+
Copyright 2025 The Sigstore Authors.
68
79
Licensed under the Apache License, Version 2.0 (the "License");
810
you may not use this file except in compliance with the License.
@@ -17,10 +19,11 @@ See the License for the specific language governing permissions and
1719
limitations under the License.
1820
*/
1921
const error_1 = require("../error");
20-
// Compare the given intoto tlog entry to the given bundle
22+
exports.DSSE_API_VERSION_V1 = '0.0.1';
23+
// Compare the given dsse tlog entry to the given bundle
2124
function verifyDSSETLogBody(tlogEntry, content) {
2225
switch (tlogEntry.apiVersion) {
23-
case '0.0.1':
26+
case exports.DSSE_API_VERSION_V1:
2427
return verifyDSSE001TLogBody(tlogEntry, content);
2528
default:
2629
throw new error_1.VerificationError({
@@ -29,6 +32,26 @@ function verifyDSSETLogBody(tlogEntry, content) {
2932
});
3033
}
3134
}
35+
// Compare the given dsse tlog entry to the given bundle. This function is
36+
// specifically for Rekor V2 entries.
37+
function verifyDSSETLogBodyV2(tlogEntry, content) {
38+
const spec = tlogEntry.spec?.spec;
39+
if (!spec) {
40+
throw new error_1.VerificationError({
41+
code: 'TLOG_BODY_ERROR',
42+
message: `missing dsse spec`,
43+
});
44+
}
45+
switch (spec.$case) {
46+
case 'dsseV002':
47+
return verifyDSSE002TLogBody(spec.dsseV002, content);
48+
default:
49+
throw new error_1.VerificationError({
50+
code: 'TLOG_BODY_ERROR',
51+
message: `unsupported version: ${spec.$case}`,
52+
});
53+
}
54+
}
3255
// Compare the given dsse v0.0.1 tlog entry to the given DSSE envelope.
3356
function verifyDSSE001TLogBody(tlogEntry, content) {
3457
// Ensure the bundle's DSSE only contains a single signature
@@ -55,3 +78,29 @@ function verifyDSSE001TLogBody(tlogEntry, content) {
5578
});
5679
}
5780
}
81+
// Compare the given dsse v0.0.2 tlog entry to the given DSSE envelope.
82+
function verifyDSSE002TLogBody(spec, content) {
83+
// Ensure the bundle's DSSE only contains a single signature
84+
if (spec.signatures?.length !== 1) {
85+
throw new error_1.VerificationError({
86+
code: 'TLOG_BODY_ERROR',
87+
message: 'signature count mismatch',
88+
});
89+
}
90+
const tlogSig = spec.signatures[0].content;
91+
// Ensure that the signature in the bundle's DSSE matches tlog entry
92+
if (!content.compareSignature(tlogSig))
93+
throw new error_1.VerificationError({
94+
code: 'TLOG_BODY_ERROR',
95+
message: 'tlog entry signature mismatch',
96+
});
97+
// Ensure the digest of the bundle's DSSE payload matches the digest in the
98+
// tlog entry
99+
const tlogHash = spec.payloadHash?.digest || Buffer.from('');
100+
if (!content.compareDigest(tlogHash)) {
101+
throw new error_1.VerificationError({
102+
code: 'TLOG_BODY_ERROR',
103+
message: 'DSSE payload hash mismatch',
104+
});
105+
}
106+
}

0 commit comments

Comments
 (0)