@parmana/crypto 0.0.0-stage → 0.1.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/LICENSE +202 -0
- package/NOTICE +8 -0
- package/README.md +16 -2
- package/dist/.tsbuildinfo +1 -0
- package/dist/ApprovalArtifactCrypto.d.ts +33 -0
- package/dist/ApprovalArtifactCrypto.d.ts.map +1 -0
- package/dist/ApprovalArtifactCrypto.js +54 -0
- package/dist/ApprovalArtifactCrypto.js.map +1 -0
- package/dist/ArtifactSigner.d.ts +22 -0
- package/dist/ArtifactSigner.d.ts.map +1 -0
- package/dist/ArtifactSigner.js +29 -0
- package/dist/ArtifactSigner.js.map +1 -0
- package/dist/AuditEventCrypto.d.ts +39 -0
- package/dist/AuditEventCrypto.d.ts.map +1 -0
- package/dist/AuditEventCrypto.js +57 -0
- package/dist/AuditEventCrypto.js.map +1 -0
- package/dist/AuthorizationSigner.d.ts +56 -0
- package/dist/AuthorizationSigner.d.ts.map +1 -0
- package/dist/AuthorizationSigner.js +103 -0
- package/dist/AuthorizationSigner.js.map +1 -0
- package/dist/AuthorizationVerifier.d.ts +53 -0
- package/dist/AuthorizationVerifier.d.ts.map +1 -0
- package/dist/AuthorizationVerifier.js +66 -0
- package/dist/AuthorizationVerifier.js.map +1 -0
- package/dist/CallerAuditChainVerifier.d.ts +62 -0
- package/dist/CallerAuditChainVerifier.d.ts.map +1 -0
- package/dist/CallerAuditChainVerifier.js +97 -0
- package/dist/CallerAuditChainVerifier.js.map +1 -0
- package/dist/CanonicalSerializer.d.ts +26 -0
- package/dist/CanonicalSerializer.d.ts.map +1 -0
- package/dist/CanonicalSerializer.js +78 -0
- package/dist/CanonicalSerializer.js.map +1 -0
- package/dist/CryptoBootstrap.d.ts +27 -0
- package/dist/CryptoBootstrap.d.ts.map +1 -0
- package/dist/CryptoBootstrap.js +70 -0
- package/dist/CryptoBootstrap.js.map +1 -0
- package/dist/CryptoBuilder.d.ts +27 -0
- package/dist/CryptoBuilder.d.ts.map +1 -0
- package/dist/CryptoBuilder.js +42 -0
- package/dist/CryptoBuilder.js.map +1 -0
- package/dist/ExecutableContentHasher.d.ts +22 -0
- package/dist/ExecutableContentHasher.d.ts.map +1 -0
- package/dist/ExecutableContentHasher.js +25 -0
- package/dist/ExecutableContentHasher.js.map +1 -0
- package/dist/ExecutionChainCrypto.d.ts +78 -0
- package/dist/ExecutionChainCrypto.d.ts.map +1 -0
- package/dist/ExecutionChainCrypto.js +165 -0
- package/dist/ExecutionChainCrypto.js.map +1 -0
- package/dist/ExecutionChainHasher.d.ts +10 -0
- package/dist/ExecutionChainHasher.d.ts.map +1 -0
- package/dist/ExecutionChainHasher.js +13 -0
- package/dist/ExecutionChainHasher.js.map +1 -0
- package/dist/ExecutionIntentCanonicalView.d.ts +28 -0
- package/dist/ExecutionIntentCanonicalView.d.ts.map +1 -0
- package/dist/ExecutionIntentCanonicalView.js +29 -0
- package/dist/ExecutionIntentCanonicalView.js.map +1 -0
- package/dist/ExecutionIntentCrypto.d.ts +21 -0
- package/dist/ExecutionIntentCrypto.d.ts.map +1 -0
- package/dist/ExecutionIntentCrypto.js +47 -0
- package/dist/ExecutionIntentCrypto.js.map +1 -0
- package/dist/ExecutionTrustRecordCanonicalView.d.ts +89 -0
- package/dist/ExecutionTrustRecordCanonicalView.d.ts.map +1 -0
- package/dist/ExecutionTrustRecordCanonicalView.js +106 -0
- package/dist/ExecutionTrustRecordCanonicalView.js.map +1 -0
- package/dist/HybridSignatureProvider.d.ts +48 -0
- package/dist/HybridSignatureProvider.d.ts.map +1 -0
- package/dist/HybridSignatureProvider.js +90 -0
- package/dist/HybridSignatureProvider.js.map +1 -0
- package/dist/KeyBootstrap.d.ts +23 -0
- package/dist/KeyBootstrap.d.ts.map +1 -0
- package/dist/KeyBootstrap.js +37 -0
- package/dist/KeyBootstrap.js.map +1 -0
- package/dist/KeyExpiry.d.ts +34 -0
- package/dist/KeyExpiry.d.ts.map +1 -0
- package/dist/KeyExpiry.js +66 -0
- package/dist/KeyExpiry.js.map +1 -0
- package/dist/KeyPair.d.ts +25 -0
- package/dist/KeyPair.d.ts.map +1 -0
- package/dist/KeyPair.js +37 -0
- package/dist/KeyPair.js.map +1 -0
- package/dist/KeyProvider.d.ts +98 -0
- package/dist/KeyProvider.d.ts.map +1 -0
- package/dist/KeyProvider.js +57 -0
- package/dist/KeyProvider.js.map +1 -0
- package/dist/KeyStore.d.ts +35 -0
- package/dist/KeyStore.d.ts.map +1 -0
- package/dist/KeyStore.js +2 -0
- package/dist/KeyStore.js.map +1 -0
- package/dist/OfflineVerifier.d.ts +80 -0
- package/dist/OfflineVerifier.d.ts.map +1 -0
- package/dist/OfflineVerifier.js +271 -0
- package/dist/OfflineVerifier.js.map +1 -0
- package/dist/PolicyChangeCrypto.d.ts +44 -0
- package/dist/PolicyChangeCrypto.d.ts.map +1 -0
- package/dist/PolicyChangeCrypto.js +79 -0
- package/dist/PolicyChangeCrypto.js.map +1 -0
- package/dist/PolicyChangeStepUpAuthorizationCrypto.d.ts +55 -0
- package/dist/PolicyChangeStepUpAuthorizationCrypto.d.ts.map +1 -0
- package/dist/PolicyChangeStepUpAuthorizationCrypto.js +107 -0
- package/dist/PolicyChangeStepUpAuthorizationCrypto.js.map +1 -0
- package/dist/ReceiptCrypto.d.ts +44 -0
- package/dist/ReceiptCrypto.d.ts.map +1 -0
- package/dist/ReceiptCrypto.js +84 -0
- package/dist/ReceiptCrypto.js.map +1 -0
- package/dist/ReceiptHasher.d.ts +10 -0
- package/dist/ReceiptHasher.d.ts.map +1 -0
- package/dist/ReceiptHasher.js +13 -0
- package/dist/ReceiptHasher.js.map +1 -0
- package/dist/RefusalCrypto.d.ts +35 -0
- package/dist/RefusalCrypto.d.ts.map +1 -0
- package/dist/RefusalCrypto.js +73 -0
- package/dist/RefusalCrypto.js.map +1 -0
- package/dist/SignatureCommitment.d.ts +33 -0
- package/dist/SignatureCommitment.d.ts.map +1 -0
- package/dist/SignatureCommitment.js +42 -0
- package/dist/SignatureCommitment.js.map +1 -0
- package/dist/SignatureVerifier.d.ts +20 -0
- package/dist/SignatureVerifier.d.ts.map +1 -0
- package/dist/SignatureVerifier.js +25 -0
- package/dist/SignatureVerifier.js.map +1 -0
- package/dist/Signer.d.ts +49 -0
- package/dist/Signer.d.ts.map +1 -0
- package/dist/Signer.js +2 -0
- package/dist/Signer.js.map +1 -0
- package/dist/SignerBootstrap.d.ts +37 -0
- package/dist/SignerBootstrap.d.ts.map +1 -0
- package/dist/SignerBootstrap.js +52 -0
- package/dist/SignerBootstrap.js.map +1 -0
- package/dist/TrustRecordHasher.d.ts +18 -0
- package/dist/TrustRecordHasher.d.ts.map +1 -0
- package/dist/TrustRecordHasher.js +23 -0
- package/dist/TrustRecordHasher.js.map +1 -0
- package/dist/VerificationCrypto.d.ts +132 -0
- package/dist/VerificationCrypto.d.ts.map +1 -0
- package/dist/VerificationCrypto.js +229 -0
- package/dist/VerificationCrypto.js.map +1 -0
- package/dist/errors/CryptoError.d.ts +14 -0
- package/dist/errors/CryptoError.d.ts.map +1 -0
- package/dist/errors/CryptoError.js +18 -0
- package/dist/errors/CryptoError.js.map +1 -0
- package/dist/index.d.ts +49 -0
- package/dist/index.d.ts.map +1 -0
- package/dist/index.js +73 -0
- package/dist/index.js.map +1 -0
- package/dist/models/HybridCryptoProvider.d.ts +9 -0
- package/dist/models/HybridCryptoProvider.d.ts.map +1 -0
- package/dist/models/HybridCryptoProvider.js +2 -0
- package/dist/models/HybridCryptoProvider.js.map +1 -0
- package/dist/providers/CryptoProvider.d.ts +15 -0
- package/dist/providers/CryptoProvider.d.ts.map +1 -0
- package/dist/providers/CryptoProvider.js +2 -0
- package/dist/providers/CryptoProvider.js.map +1 -0
- package/dist/providers/HashProvider.d.ts +17 -0
- package/dist/providers/HashProvider.d.ts.map +1 -0
- package/dist/providers/HashProvider.js +2 -0
- package/dist/providers/HashProvider.js.map +1 -0
- package/dist/providers/HashRegistry.d.ts +11 -0
- package/dist/providers/HashRegistry.d.ts.map +1 -0
- package/dist/providers/HashRegistry.js +18 -0
- package/dist/providers/HashRegistry.js.map +1 -0
- package/dist/providers/ProviderFactory.d.ts +11 -0
- package/dist/providers/ProviderFactory.d.ts.map +1 -0
- package/dist/providers/ProviderFactory.js +13 -0
- package/dist/providers/ProviderFactory.js.map +1 -0
- package/dist/providers/SignatureProvider.d.ts +25 -0
- package/dist/providers/SignatureProvider.d.ts.map +1 -0
- package/dist/providers/SignatureProvider.js +2 -0
- package/dist/providers/SignatureProvider.js.map +1 -0
- package/dist/providers/SignatureRegistry.d.ts +11 -0
- package/dist/providers/SignatureRegistry.d.ts.map +1 -0
- package/dist/providers/SignatureRegistry.js +18 -0
- package/dist/providers/SignatureRegistry.js.map +1 -0
- package/dist/providers/SignerKeyProviderAdapter.d.ts +50 -0
- package/dist/providers/SignerKeyProviderAdapter.d.ts.map +1 -0
- package/dist/providers/SignerKeyProviderAdapter.js +66 -0
- package/dist/providers/SignerKeyProviderAdapter.js.map +1 -0
- package/dist/providers/hash/SHA256HashProvider.d.ts +10 -0
- package/dist/providers/hash/SHA256HashProvider.d.ts.map +1 -0
- package/dist/providers/hash/SHA256HashProvider.js +12 -0
- package/dist/providers/hash/SHA256HashProvider.js.map +1 -0
- package/dist/providers/key/FileKeyProvider.d.ts +85 -0
- package/dist/providers/key/FileKeyProvider.d.ts.map +1 -0
- package/dist/providers/key/FileKeyProvider.js +163 -0
- package/dist/providers/key/FileKeyProvider.js.map +1 -0
- package/dist/providers/signature/Dilithium3SignatureProvider.d.ts +23 -0
- package/dist/providers/signature/Dilithium3SignatureProvider.d.ts.map +1 -0
- package/dist/providers/signature/Dilithium3SignatureProvider.js +33 -0
- package/dist/providers/signature/Dilithium3SignatureProvider.js.map +1 -0
- package/dist/providers/signature/Ed25519SignatureProvider.d.ts +17 -0
- package/dist/providers/signature/Ed25519SignatureProvider.d.ts.map +1 -0
- package/dist/providers/signature/Ed25519SignatureProvider.js +40 -0
- package/dist/providers/signature/Ed25519SignatureProvider.js.map +1 -0
- package/dist/providers/signature/assertKeyType.d.ts +14 -0
- package/dist/providers/signature/assertKeyType.d.ts.map +1 -0
- package/dist/providers/signature/assertKeyType.js +19 -0
- package/dist/providers/signature/assertKeyType.js.map +1 -0
- package/dist/providers/signer/KmsSigner.d.ts +71 -0
- package/dist/providers/signer/KmsSigner.d.ts.map +1 -0
- package/dist/providers/signer/KmsSigner.js +270 -0
- package/dist/providers/signer/KmsSigner.js.map +1 -0
- package/dist/providers/signer/LocalFileSigner.d.ts +28 -0
- package/dist/providers/signer/LocalFileSigner.d.ts.map +1 -0
- package/dist/providers/signer/LocalFileSigner.js +38 -0
- package/dist/providers/signer/LocalFileSigner.js.map +1 -0
- package/dist/support/MlDsaSupport.d.ts +9 -0
- package/dist/support/MlDsaSupport.d.ts.map +1 -0
- package/dist/support/MlDsaSupport.js +23 -0
- package/dist/support/MlDsaSupport.js.map +1 -0
- package/package.json +45 -4
|
@@ -0,0 +1,132 @@
|
|
|
1
|
+
import type { ExecutionTrustRecord, Signature, SignatureEntry } from "@parmana/shared";
|
|
2
|
+
/**
|
|
3
|
+
* Verification cryptographic operations.
|
|
4
|
+
*
|
|
5
|
+
* Provides hashing, signing and verification
|
|
6
|
+
* services for Execution Trust Records.
|
|
7
|
+
*/
|
|
8
|
+
export declare class VerificationCrypto {
|
|
9
|
+
private readonly crypto;
|
|
10
|
+
private readonly config;
|
|
11
|
+
/**
|
|
12
|
+
* Signer (ADR-0009) -- LocalFileSigner or KmsSigner depending on
|
|
13
|
+
* KEY_PROVIDER. Used for both signing (sign()) and verification
|
|
14
|
+
* (verifySignature()/verify()), since Signer's read operations
|
|
15
|
+
* (getPublicKey/getMetadata/hasKey) are identical to KeyProvider's.
|
|
16
|
+
*/
|
|
17
|
+
private readonly signerPromise;
|
|
18
|
+
/**
|
|
19
|
+
* Hybrid mode is out of scope for the Signer migration (ADR-0009):
|
|
20
|
+
* it needs a second, independent key/algorithm pair, and KmsSigner
|
|
21
|
+
* today only supports Ed25519. HybridSignatureProvider keeps using
|
|
22
|
+
* FileKeyProvider directly for BOTH entries of the `signatures`
|
|
23
|
+
* array, the Ed25519 one included, so CRYPTO_MODE=hybrid is
|
|
24
|
+
* local-file-only. assertSigningKeyMaterialConfigured (packages/api)
|
|
25
|
+
* refuses CRYPTO_MODE=hybrid with KEY_PROVIDER=aws-kms at startup.
|
|
26
|
+
* CRYPTO_MODE defaults to "single", so this does not affect a
|
|
27
|
+
* deployment that hasn't opted into hybrid.
|
|
28
|
+
*/
|
|
29
|
+
private readonly hybridKeys;
|
|
30
|
+
private readonly hasher;
|
|
31
|
+
private readonly signer;
|
|
32
|
+
private readonly verifier;
|
|
33
|
+
/**
|
|
34
|
+
* Creates the canonical immutable view of an Execution Trust Record
|
|
35
|
+
* used for hashing and signing.
|
|
36
|
+
*
|
|
37
|
+
* Delegates to canonicalExecutionTrustRecord() (own file, PQC audit
|
|
38
|
+
* RED-1) -- the same mapping OfflineVerifier.ts uses -- rather than
|
|
39
|
+
* duplicating the field list here, so there is exactly one place
|
|
40
|
+
* that defines "which fields participate in the signature."
|
|
41
|
+
* Unchanged behavior; see that function's own doc comment for the
|
|
42
|
+
* full field-by-field reasoning (authorization inclusion,
|
|
43
|
+
* CanonicalSerializer's undefined-key-dropping compatibility, etc.).
|
|
44
|
+
*/
|
|
45
|
+
private canonicalRecord;
|
|
46
|
+
/**
|
|
47
|
+
* Canonical view signed/verified by the hybrid `signatures` array.
|
|
48
|
+
* Delegates to hybridSignedCanonicalView() for the same
|
|
49
|
+
* single-source-of-truth reason as canonicalRecord() above.
|
|
50
|
+
*/
|
|
51
|
+
private hybridCanonicalRecord;
|
|
52
|
+
private hybridSignatureProvider;
|
|
53
|
+
/**
|
|
54
|
+
* Computes the canonical Trust Record hash.
|
|
55
|
+
*/
|
|
56
|
+
hash(trustRecord: ExecutionTrustRecord): Promise<string>;
|
|
57
|
+
/**
|
|
58
|
+
* Creates a digital signature over the canonical
|
|
59
|
+
* Trust Record.
|
|
60
|
+
*
|
|
61
|
+
* Unchanged by hybrid mode: always the single, legacy signature,
|
|
62
|
+
* over exactly the same content as before this milestone. See
|
|
63
|
+
* signHybrid() for the additive second signature.
|
|
64
|
+
*/
|
|
65
|
+
sign(trustRecord: ExecutionTrustRecord): Promise<Signature>;
|
|
66
|
+
/**
|
|
67
|
+
* Signing readiness probe (docs/VERIFICATION-GAPS.md G-52).
|
|
68
|
+
*
|
|
69
|
+
* Proves, before an action is released, that the evidence signing path
|
|
70
|
+
* can currently produce a signature that verifies. It signs a synthetic
|
|
71
|
+
* artifact through the SAME Signer and key id sign() uses for Execution
|
|
72
|
+
* Trust Records, then verifies it against the public key the same
|
|
73
|
+
* Signer publishes, so it catches a missing, disabled or access denied
|
|
74
|
+
* key, a KMS or network outage, a signing and verification key
|
|
75
|
+
* mismatch, and the KMS raw message size limit. The artifact is padded
|
|
76
|
+
* past 4096 bytes on purpose, so the large message path (ADR-0010) is
|
|
77
|
+
* exercised, not only the small one. Throws on any failure and returns
|
|
78
|
+
* nothing on success. It signs nothing that is stored or trusted.
|
|
79
|
+
*/
|
|
80
|
+
probeSigning(): Promise<void>;
|
|
81
|
+
/**
|
|
82
|
+
* Signs the Trust Record with both configured algorithms
|
|
83
|
+
* (Hybrid Signature Support milestone, Phase A). Additive:
|
|
84
|
+
* callers combine this with the unchanged sign() above -- the
|
|
85
|
+
* legacy `signature` field is untouched, `signatures` is new.
|
|
86
|
+
*
|
|
87
|
+
* Fails closed: throws if CRYPTO_MODE is not "hybrid", or if
|
|
88
|
+
* SECONDARY_SIGNATURE_PROVIDER isn't configured (via
|
|
89
|
+
* CryptoBootstrap.createHybrid()'s own guard), or if either key
|
|
90
|
+
* file is missing (via FileKeyProvider's own guard) -- never a
|
|
91
|
+
* silent partial signature.
|
|
92
|
+
*/
|
|
93
|
+
signHybrid(trustRecord: ExecutionTrustRecord): Promise<readonly SignatureEntry[]>;
|
|
94
|
+
/**
|
|
95
|
+
* Verifies only the cryptographic signature(s) of the Trust
|
|
96
|
+
* Record, independent of hash comparison.
|
|
97
|
+
*
|
|
98
|
+
* The legacy `signature` field is always checked (unchanged
|
|
99
|
+
* behavior). If `signatures` is also present and non-empty, it is
|
|
100
|
+
* independently and fully verified too -- both must pass. A
|
|
101
|
+
* `signatures`-bearing record with a missing or malformed entry
|
|
102
|
+
* fails here even if the legacy `signature` alone is valid: never a
|
|
103
|
+
* silent downgrade to single-signature verification.
|
|
104
|
+
*
|
|
105
|
+
* PQC audit RED-4 (docs/VERIFICATION-GAPS.md): by itself, the
|
|
106
|
+
* paragraph above only protects a record that still *carries* its
|
|
107
|
+
* `signatures` array -- nothing stopped `signatures` from being
|
|
108
|
+
* stripped entirely, at which point this method fell back to
|
|
109
|
+
* `legacyVerified` alone and reported a fully hybrid-signed record
|
|
110
|
+
* as valid via its now-lone classical signature. That silently
|
|
111
|
+
* defeats hybrid mode's entire purpose (a future break of the
|
|
112
|
+
* classical algorithm no longer has a surviving PQ signature to
|
|
113
|
+
* fall back on), and required no key material to pull off -- only
|
|
114
|
+
* write/storage access to a copy of the record. `requireHybridSignature`
|
|
115
|
+
* closes this for any deployment that opts in: when set, a missing
|
|
116
|
+
* or empty `signatures` array is a rejection, not a silent
|
|
117
|
+
* single-signature pass. Off by default, so enabling CRYPTO_MODE=
|
|
118
|
+
* hybrid never retroactively invalidates a record issued before a
|
|
119
|
+
* deployment decided every future record must be hybrid-signed.
|
|
120
|
+
*
|
|
121
|
+
* Reuses the same canonical view and verifier as verify(), so
|
|
122
|
+
* callers that need to report integrity and signature failures
|
|
123
|
+
* independently don't have to reimplement canonicalization.
|
|
124
|
+
*/
|
|
125
|
+
verifySignature(trustRecord: ExecutionTrustRecord): Promise<boolean>;
|
|
126
|
+
/**
|
|
127
|
+
* Verifies integrity and authenticity of the
|
|
128
|
+
* Trust Record.
|
|
129
|
+
*/
|
|
130
|
+
verify(trustRecord: ExecutionTrustRecord): Promise<boolean>;
|
|
131
|
+
}
|
|
132
|
+
//# sourceMappingUR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G,MAAM,CAAC,WAAW,EAAE,oBAAoB,GAAG,OAAO,CAAC,OAAO,CAAC,CAehE;CACF"}
|
|
@@ -0,0 +1,229 @@
|
|
|
1
|
+
import { loadConfig } from "@parmana/shared";
|
|
2
|
+
import { CryptoBootstrap } from "./CryptoBootstrap.js";
|
|
3
|
+
import { canonicalExecutionTrustRecord, hybridSignedCanonicalView, SUPPORTED_HYBRID_SCHEMA_VERSIONS, isAtOrAfterCutover, WHOLE_RECORD_SCHEMA_VERSION, } from "./ExecutionTrustRecordCanonicalView.js";
|
|
4
|
+
import { HybridSignatureProvider } from "./HybridSignatureProvider.js";
|
|
5
|
+
import { TrustRecordHasher } from "./TrustRecordHasher.js";
|
|
6
|
+
import { ArtifactSigner } from "./ArtifactSigner.js";
|
|
7
|
+
import { SignatureVerifier } from "./SignatureVerifier.js";
|
|
8
|
+
import { SignerBootstrap } from "./SignerBootstrap.js";
|
|
9
|
+
import { FileKeyProvider } from "./providers/key/FileKeyProvider.js";
|
|
10
|
+
import { currentVerificationKeyId, currentVerificationSecondaryKeyId, } from "./KeyProvider.js";
|
|
11
|
+
/**
|
|
12
|
+
* Schema version assumed for a `signatures`-bearing record that does not
|
|
13
|
+
* declare one. Bumped from the implicit v1 (no `schemaVersion` field
|
|
14
|
+
* at all -- today's shape) the moment a second, independent signature
|
|
15
|
+
* is added alongside the legacy one (Hybrid Signature Support
|
|
16
|
+
* milestone, Phase A). The version new records are signed with is
|
|
17
|
+
* `crypto.hybridSchemaVersion`, which defaults to this value.
|
|
18
|
+
*/
|
|
19
|
+
const HYBRID_SCHEMA_VERSION = 2;
|
|
20
|
+
/**
|
|
21
|
+
* Verification cryptographic operations.
|
|
22
|
+
*
|
|
23
|
+
* Provides hashing, signing and verification
|
|
24
|
+
* services for Execution Trust Records.
|
|
25
|
+
*/
|
|
26
|
+
export class VerificationCrypto {
|
|
27
|
+
crypto = CryptoBootstrap.create();
|
|
28
|
+
config = loadConfig();
|
|
29
|
+
/**
|
|
30
|
+
* Signer (ADR-0009) -- LocalFileSigner or KmsSigner depending on
|
|
31
|
+
* KEY_PROVIDER. Used for both signing (sign()) and verification
|
|
32
|
+
* (verifySignature()/verify()), since Signer's read operations
|
|
33
|
+
* (getPublicKey/getMetadata/hasKey) are identical to KeyProvider's.
|
|
34
|
+
*/
|
|
35
|
+
signerPromise = SignerBootstrap.create();
|
|
36
|
+
/**
|
|
37
|
+
* Hybrid mode is out of scope for the Signer migration (ADR-0009):
|
|
38
|
+
* it needs a second, independent key/algorithm pair, and KmsSigner
|
|
39
|
+
* today only supports Ed25519. HybridSignatureProvider keeps using
|
|
40
|
+
* FileKeyProvider directly for BOTH entries of the `signatures`
|
|
41
|
+
* array, the Ed25519 one included, so CRYPTO_MODE=hybrid is
|
|
42
|
+
* local-file-only. assertSigningKeyMaterialConfigured (packages/api)
|
|
43
|
+
* refuses CRYPTO_MODE=hybrid with KEY_PROVIDER=aws-kms at startup.
|
|
44
|
+
* CRYPTO_MODE defaults to "single", so this does not affect a
|
|
45
|
+
* deployment that hasn't opted into hybrid.
|
|
46
|
+
*/
|
|
47
|
+
hybridKeys = new FileKeyProvider();
|
|
48
|
+
hasher = new TrustRecordHasher(this.crypto);
|
|
49
|
+
signer = new ArtifactSigner(this.crypto);
|
|
50
|
+
verifier = new SignatureVerifier(this.crypto);
|
|
51
|
+
/**
|
|
52
|
+
* Creates the canonical immutable view of an Execution Trust Record
|
|
53
|
+
* used for hashing and signing.
|
|
54
|
+
*
|
|
55
|
+
* Delegates to canonicalExecutionTrustRecord() (own file, PQC audit
|
|
56
|
+
* RED-1) -- the same mapping OfflineVerifier.ts uses -- rather than
|
|
57
|
+
* duplicating the field list here, so there is exactly one place
|
|
58
|
+
* that defines "which fields participate in the signature."
|
|
59
|
+
* Unchanged behavior; see that function's own doc comment for the
|
|
60
|
+
* full field-by-field reasoning (authorization inclusion,
|
|
61
|
+
* CanonicalSerializer's undefined-key-dropping compatibility, etc.).
|
|
62
|
+
*/
|
|
63
|
+
canonicalRecord(trustRecord) {
|
|
64
|
+
return canonicalExecutionTrustRecord(trustRecord);
|
|
65
|
+
}
|
|
66
|
+
/**
|
|
67
|
+
* Canonical view signed/verified by the hybrid `signatures` array.
|
|
68
|
+
* Delegates to hybridSignedCanonicalView() for the same
|
|
69
|
+
* single-source-of-truth reason as canonicalRecord() above.
|
|
70
|
+
*/
|
|
71
|
+
hybridCanonicalRecord(trustRecord, schemaVersion) {
|
|
72
|
+
return hybridSignedCanonicalView(trustRecord, schemaVersion);
|
|
73
|
+
}
|
|
74
|
+
hybridSignatureProvider() {
|
|
75
|
+
return new HybridSignatureProvider(CryptoBootstrap.createHybrid(), this.hybridKeys);
|
|
76
|
+
}
|
|
77
|
+
/**
|
|
78
|
+
* Computes the canonical Trust Record hash.
|
|
79
|
+
*/
|
|
80
|
+
async hash(trustRecord) {
|
|
81
|
+
return this.hasher.hash(this.canonicalRecord(trustRecord));
|
|
82
|
+
}
|
|
83
|
+
/**
|
|
84
|
+
* Creates a digital signature over the canonical
|
|
85
|
+
* Trust Record.
|
|
86
|
+
*
|
|
87
|
+
* Unchanged by hybrid mode: always the single, legacy signature,
|
|
88
|
+
* over exactly the same content as before this milestone. See
|
|
89
|
+
* signHybrid() for the additive second signature.
|
|
90
|
+
*/
|
|
91
|
+
async sign(trustRecord) {
|
|
92
|
+
const keyId = currentVerificationKeyId();
|
|
93
|
+
const signer = await this.signerPromise;
|
|
94
|
+
const value = await this.signer.signWithSigner(this.canonicalRecord(trustRecord), keyId, signer);
|
|
95
|
+
return {
|
|
96
|
+
algorithm: this.crypto.signature.algorithm,
|
|
97
|
+
keyId,
|
|
98
|
+
value,
|
|
99
|
+
signedAt: new Date(),
|
|
100
|
+
};
|
|
101
|
+
}
|
|
102
|
+
/**
|
|
103
|
+
* Signing readiness probe (docs/VERIFICATION-GAPS.md G-52).
|
|
104
|
+
*
|
|
105
|
+
* Proves, before an action is released, that the evidence signing path
|
|
106
|
+
* can currently produce a signature that verifies. It signs a synthetic
|
|
107
|
+
* artifact through the SAME Signer and key id sign() uses for Execution
|
|
108
|
+
* Trust Records, then verifies it against the public key the same
|
|
109
|
+
* Signer publishes, so it catches a missing, disabled or access denied
|
|
110
|
+
* key, a KMS or network outage, a signing and verification key
|
|
111
|
+
* mismatch, and the KMS raw message size limit. The artifact is padded
|
|
112
|
+
* past 4096 bytes on purpose, so the large message path (ADR-0010) is
|
|
113
|
+
* exercised, not only the small one. Throws on any failure and returns
|
|
114
|
+
* nothing on success. It signs nothing that is stored or trusted.
|
|
115
|
+
*/
|
|
116
|
+
async probeSigning() {
|
|
117
|
+
const keyId = currentVerificationKeyId();
|
|
118
|
+
const signer = await this.signerPromise;
|
|
119
|
+
const probe = {
|
|
120
|
+
purpose: "parmana-signing-readiness-probe",
|
|
121
|
+
padding: "x".repeat(6000),
|
|
122
|
+
};
|
|
123
|
+
const value = await this.signer.signWithSigner(probe, keyId, signer);
|
|
124
|
+
const publicKey = await signer.getPublicKey(keyId);
|
|
125
|
+
const verified = await this.verifier.verify(probe, value, publicKey);
|
|
126
|
+
if (!verified) {
|
|
127
|
+
throw new Error(`Signing readiness probe signature did not verify against the ` +
|
|
128
|
+
`published public key for key "${keyId}".`);
|
|
129
|
+
}
|
|
130
|
+
}
|
|
131
|
+
/**
|
|
132
|
+
* Signs the Trust Record with both configured algorithms
|
|
133
|
+
* (Hybrid Signature Support milestone, Phase A). Additive:
|
|
134
|
+
* callers combine this with the unchanged sign() above -- the
|
|
135
|
+
* legacy `signature` field is untouched, `signatures` is new.
|
|
136
|
+
*
|
|
137
|
+
* Fails closed: throws if CRYPTO_MODE is not "hybrid", or if
|
|
138
|
+
* SECONDARY_SIGNATURE_PROVIDER isn't configured (via
|
|
139
|
+
* CryptoBootstrap.createHybrid()'s own guard), or if either key
|
|
140
|
+
* file is missing (via FileKeyProvider's own guard) -- never a
|
|
141
|
+
* silent partial signature.
|
|
142
|
+
*/
|
|
143
|
+
async signHybrid(trustRecord) {
|
|
144
|
+
if (this.config.crypto.mode !== "hybrid") {
|
|
145
|
+
throw new Error("VerificationCrypto.signHybrid() requires CRYPTO_MODE=hybrid.");
|
|
146
|
+
}
|
|
147
|
+
return this.hybridSignatureProvider().sign(this.hybridCanonicalRecord(trustRecord, this.config.crypto.hybridSchemaVersion), currentVerificationKeyId(), currentVerificationSecondaryKeyId());
|
|
148
|
+
}
|
|
149
|
+
/**
|
|
150
|
+
* Verifies only the cryptographic signature(s) of the Trust
|
|
151
|
+
* Record, independent of hash comparison.
|
|
152
|
+
*
|
|
153
|
+
* The legacy `signature` field is always checked (unchanged
|
|
154
|
+
* behavior). If `signatures` is also present and non-empty, it is
|
|
155
|
+
* independently and fully verified too -- both must pass. A
|
|
156
|
+
* `signatures`-bearing record with a missing or malformed entry
|
|
157
|
+
* fails here even if the legacy `signature` alone is valid: never a
|
|
158
|
+
* silent downgrade to single-signature verification.
|
|
159
|
+
*
|
|
160
|
+
* PQC audit RED-4 (docs/VERIFICATION-GAPS.md): by itself, the
|
|
161
|
+
* paragraph above only protects a record that still *carries* its
|
|
162
|
+
* `signatures` array -- nothing stopped `signatures` from being
|
|
163
|
+
* stripped entirely, at which point this method fell back to
|
|
164
|
+
* `legacyVerified` alone and reported a fully hybrid-signed record
|
|
165
|
+
* as valid via its now-lone classical signature. That silently
|
|
166
|
+
* defeats hybrid mode's entire purpose (a future break of the
|
|
167
|
+
* classical algorithm no longer has a surviving PQ signature to
|
|
168
|
+
* fall back on), and required no key material to pull off -- only
|
|
169
|
+
* write/storage access to a copy of the record. `requireHybridSignature`
|
|
170
|
+
* closes this for any deployment that opts in: when set, a missing
|
|
171
|
+
* or empty `signatures` array is a rejection, not a silent
|
|
172
|
+
* single-signature pass. Off by default, so enabling CRYPTO_MODE=
|
|
173
|
+
* hybrid never retroactively invalidates a record issued before a
|
|
174
|
+
* deployment decided every future record must be hybrid-signed.
|
|
175
|
+
*
|
|
176
|
+
* Reuses the same canonical view and verifier as verify(), so
|
|
177
|
+
* callers that need to report integrity and signature failures
|
|
178
|
+
* independently don't have to reimplement canonicalization.
|
|
179
|
+
*/
|
|
180
|
+
async verifySignature(trustRecord) {
|
|
181
|
+
const signer = await this.signerPromise;
|
|
182
|
+
const publicKey = await signer.getPublicKey(trustRecord.signature.keyId);
|
|
183
|
+
const legacyVerified = await this.verifier.verify(this.canonicalRecord(trustRecord), trustRecord.signature.value, publicKey);
|
|
184
|
+
const declaredVersion = trustRecord.schemaVersion ?? HYBRID_SCHEMA_VERSION;
|
|
185
|
+
if (!SUPPORTED_HYBRID_SCHEMA_VERSIONS.includes(declaredVersion)) {
|
|
186
|
+
return false;
|
|
187
|
+
}
|
|
188
|
+
if (trustRecord.signatures === undefined ||
|
|
189
|
+
trustRecord.signatures.length === 0) {
|
|
190
|
+
//
|
|
191
|
+
// A schema version 3 record declares that it is whole-record
|
|
192
|
+
// signed, so a missing hybrid envelope is a rejection even when
|
|
193
|
+
// requireHybridSignature is off (ADR-0016, decision 4).
|
|
194
|
+
//
|
|
195
|
+
//
|
|
196
|
+
// ADR-0016 option 2: a record created at or after the configured
|
|
197
|
+
// cutover must carry a hybrid envelope, so stripping the envelope
|
|
198
|
+
// makes it fail here.
|
|
199
|
+
//
|
|
200
|
+
if (this.config.crypto.requireHybridSignature ||
|
|
201
|
+
declaredVersion === WHOLE_RECORD_SCHEMA_VERSION ||
|
|
202
|
+
isAtOrAfterCutover(trustRecord.createdAt, this.config.crypto.hybridRequiredFrom)) {
|
|
203
|
+
return false;
|
|
204
|
+
}
|
|
205
|
+
return legacyVerified;
|
|
206
|
+
}
|
|
207
|
+
const hybridVerified = await this.hybridSignatureProvider().verify(this.hybridCanonicalRecord(trustRecord, declaredVersion), trustRecord.signatures);
|
|
208
|
+
return legacyVerified && hybridVerified;
|
|
209
|
+
}
|
|
210
|
+
/**
|
|
211
|
+
* Verifies integrity and authenticity of the
|
|
212
|
+
* Trust Record.
|
|
213
|
+
*/
|
|
214
|
+
async verify(trustRecord) {
|
|
215
|
+
//
|
|
216
|
+
// Verify hash integrity.
|
|
217
|
+
//
|
|
218
|
+
const expectedHash = await this.hash(trustRecord);
|
|
219
|
+
if (expectedHash !== trustRecord.trustRecordHash) {
|
|
220
|
+
return false;
|
|
221
|
+
}
|
|
222
|
+
//
|
|
223
|
+
// Verify signature(s) -- legacy always, hybrid additionally
|
|
224
|
+
// when the record declares itself hybrid-signed.
|
|
225
|
+
//
|
|
226
|
+
return this.verifySignature(trustRecord);
|
|
227
|
+
}
|
|
228
|
+
}
|
|
229
|
+
//# sourceMappingURL=VerificationCrypto.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"VerificationCrypto.js","sourceRoot":"","sources":["../src/VerificationCrypto.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,UAAU,EAAE,MAAM,iBAAiB,CAAC;AAO7C,OAAO,EAAE,eAAe,EAAE,MAAM,sBAAsB,CAAC;AACvD,OAAO,EACL,6BAA6B,EAC7B,yBAAyB,EACzB,gCAAgC,EAChC,kBAAkB,EAClB,2BAA2B,GAC5B,MAAM,wCAAwC,CAAC;AAChD,OAAO,EAAE,uBAAuB,EAAE,MAAM,8BAA8B,CAAC;AACvE,OAAO,EAAE,iBAAiB,EAAE,MAAM,wBAAwB,CAAC;AAC3D,OAAO,EAAE,cAAc,EAAE,MAAM,qBAAqB,CAAC;AACrD,OAAO,EAAE,iBAAiB,EAAE,MAAM,wBAAwB,CAAC;AAC3D,OAAO,EAAE,eAAe,EAAE,MAAM,sBAAsB,CAAC;AACvD,OAAO,EAAE,eAAe,EAAE,MAAM,oCAAoC,CAAC;AACrE,OAAO,EACL,wBAAwB,EACxB,iCAAiC,GAClC,MAAM,kBAAkB,CAAC;AAE1B;;;;;;;GAOG;AACH,MAAM,qBAAqB,GAAG,CAAC,CAAC;AAEhC;;;;;GAKG;AACH,MAAM,OAAO,kBAAkB;IACZ,MAAM,GAAG,eAAe,CAAC,MAAM,EAAE,CAAC;IAElC,MAAM,GAAG,UAAU,EAAE,CAAC;IAEvC;;;;;OAKG;I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AAiC;QAC5C,EAAE;QACF,yBAAyB;QACzB,EAAE;QACF,MAAM,YAAY,GAAG,MAAM,IAAI,CAAC,IAAI,CAAC,WAAW,CAAC,CAAC;QAElD,IAAI,YAAY,KAAK,WAAW,CAAC,eAAe,EAAE,CAAC;YACjD,OAAO,KAAK,CAAC;QACf,CAAC;QAED,EAAE;QACF,4DAA4D;QAC5D,iDAAiD;QACjD,EAAE;QACF,OAAO,IAAI,CAAC,eAAe,CAAC,WAAW,CAAC,CAAC;IAC3C,CAAC;CACF"}
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Base error for all cryptographic operations.
|
|
3
|
+
*
|
|
4
|
+
* All Crypto package exceptions should extend this class.
|
|
5
|
+
*/
|
|
6
|
+
export declare class CryptoError extends Error {
|
|
7
|
+
/**
|
|
8
|
+
* Creates a new CryptoError.
|
|
9
|
+
*
|
|
10
|
+
* @param message Error message.
|
|
11
|
+
*/
|
|
12
|
+
constructor(message: string);
|
|
13
|
+
}
|
|
14
|
+
//# sourceMappingURL=CryptoError.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"CryptoError.d.ts","sourceRoot":"","sources":["../../src/errors/CryptoError.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AACH,qBAAa,WAAY,SAAQ,KAAK;IACpC;;;;OAIG;IACH,YAAY,OAAO,EAAE,MAAM,EAM1B;CACF"}
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Base error for all cryptographic operations.
|
|
3
|
+
*
|
|
4
|
+
* All Crypto package exceptions should extend this class.
|
|
5
|
+
*/
|
|
6
|
+
export class CryptoError extends Error {
|
|
7
|
+
/**
|
|
8
|
+
* Creates a new CryptoError.
|
|
9
|
+
*
|
|
10
|
+
* @param message Error message.
|
|
11
|
+
*/
|
|
12
|
+
constructor(message) {
|
|
13
|
+
super(message);
|
|
14
|
+
this.name = "CryptoError";
|
|
15
|
+
Object.setPrototypeOf(this, new.target.prototype);
|
|
16
|
+
}
|
|
17
|
+
}
|
|
18
|
+
//# sourceMappingURL=CryptoError.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"CryptoError.js","sourceRoot":"","sources":["../../src/errors/CryptoError.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AACH,MAAM,OAAO,WAAY,SAAQ,KAAK;IACpC;;;;OAIG;IACH,YAAY,OAAe;QACzB,KAAK,CAAC,OAAO,CAAC,CAAC;QAEf,IAAI,CAAC,IAAI,GAAG,aAAa,CAAC;QAE1B,MAAM,CAAC,cAAc,CAAC,IAAI,EAAE,IAAI,MAAM,CAAC,SAAS,CAAC,CAAC;IACpD,CAAC;CACF"}
|
package/dist/index.d.ts
ADDED
|
@@ -0,0 +1,49 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* @parmana/crypto
|
|
3
|
+
*
|
|
4
|
+
* Canonical public API.
|
|
5
|
+
*/
|
|
6
|
+
export * from "./models/HybridCryptoProvider.js";
|
|
7
|
+
export * from "./HybridSignatureProvider.js";
|
|
8
|
+
export * from "./CanonicalSerializer.js";
|
|
9
|
+
export * from "./TrustRecordHasher.js";
|
|
10
|
+
export * from "./ReceiptHasher.js";
|
|
11
|
+
export * from "./ExecutableContentHasher.js";
|
|
12
|
+
export * from "./ExecutionChainHasher.js";
|
|
13
|
+
export * from "./ArtifactSigner.js";
|
|
14
|
+
export * from "./SignatureVerifier.js";
|
|
15
|
+
export * from "./SignatureCommitment.js";
|
|
16
|
+
export * from "./AuthorizationSigner.js";
|
|
17
|
+
export * from "./AuthorizationVerifier.js";
|
|
18
|
+
export * from "./PolicyChangeStepUpAuthorizationCrypto.js";
|
|
19
|
+
export * from "./ApprovalArtifactCrypto.js";
|
|
20
|
+
export * from "./ReceiptCrypto.js";
|
|
21
|
+
export * from "./VerificationCrypto.js";
|
|
22
|
+
export * from "./ExecutionTrustRecordCanonicalView.js";
|
|
23
|
+
export * from "./OfflineVerifier.js";
|
|
24
|
+
export * from "./ExecutionIntentCanonicalView.js";
|
|
25
|
+
export * from "./ExecutionIntentCrypto.js";
|
|
26
|
+
export * from "./RefusalCrypto.js";
|
|
27
|
+
export * from "./AuditEventCrypto.js";
|
|
28
|
+
export * from "./CallerAuditChainVerifier.js";
|
|
29
|
+
export * from "./PolicyChangeCrypto.js";
|
|
30
|
+
export * from "./ExecutionChainCrypto.js";
|
|
31
|
+
export * from "./CryptoBuilder.js";
|
|
32
|
+
export * from "./CryptoBootstrap.js";
|
|
33
|
+
export * from "./KeyPair.js";
|
|
34
|
+
export * from "./KeyStore.js";
|
|
35
|
+
export * from "./KeyProvider.js";
|
|
36
|
+
export * from "./providers/key/FileKeyProvider.js";
|
|
37
|
+
export * from "./KeyExpiry.js";
|
|
38
|
+
export * from "./Signer.js";
|
|
39
|
+
export * from "./SignerBootstrap.js";
|
|
40
|
+
export * from "./providers/signer/LocalFileSigner.js";
|
|
41
|
+
export * from "./providers/signer/KmsSigner.js";
|
|
42
|
+
export * from "./providers/SignerKeyProviderAdapter.js";
|
|
43
|
+
export * from "./providers/CryptoProvider.js";
|
|
44
|
+
export * from "./providers/HashProvider.js";
|
|
45
|
+
export * from "./providers/SignatureProvider.js";
|
|
46
|
+
export * from "./providers/ProviderFactory.js";
|
|
47
|
+
export * from "./errors/CryptoError.js";
|
|
48
|
+
export * from "./support/MlDsaSupport.js";
|
|
49
|
+
//# sourceMappingURL=index.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AACH,cAAc,kCAAkC,CAAC;AACjD,cAAc,8BAA8B,CAAC;AAM7C,cAAc,0BAA0B,CAAC;AAMzC,cAAc,wBAAwB,CAAC;AACvC,cAAc,oBAAoB,CAAC;AACnC,cAAc,8BAA8B,CAAC;AAC7C,cAAc,2BAA2B,CAAC;AAM1C,cAAc,qBAAqB,CAAC;AACpC,cAAc,wBAAwB,CAAC;AACvC,cAAc,0BAA0B,CAAC;AACzC,cAAc,0BAA0B,CAAC;AACzC,cAAc,4BAA4B,CAAC;AAC3C,cAAc,4CAA4C,CAAC;AAC3D,cAAc,6BAA6B,CAAC;AAM5C,cAAc,oBAAoB,CAAC;AACnC,cAAc,yBAAyB,CAAC;AACxC,cAAc,wCAAwC,CAAC;AACvD,cAAc,sBAAsB,CAAC;AACrC,cAAc,mCAAmC,CAAC;AAClD,cAAc,4BAA4B,CAAC;AAC3C,cAAc,oBAAoB,CAAC;AACnC,cAAc,uBAAuB,CAAC;AACtC,cAAc,+BAA+B,CAAC;AAC9C,cAAc,yBAAyB,CAAC;AACxC,cAAc,2BAA2B,CAAC;AAM1C,cAAc,oBAAoB,CAAC;AACnC,cAAc,sBAAsB,CAAC;AACrC,cAAc,cAAc,CAAC;AAC7B,cAAc,eAAe,CAAC;AAC9B,cAAc,kBAAkB,CAAC;AACjC,cAAc,oCAAoC,CAAC;AACnD,cAAc,gBAAgB,CAAC;AAC/B,cAAc,aAAa,CAAC;AAC5B,cAAc,sBAAsB,CAAC;AACrC,cAAc,uCAAuC,CAAC;AACtD,cAAc,iCAAiC,CAAC;AAChD,cAAc,yCAAyC,CAAC;AAMxD,cAAc,+BAA+B,CAAC;AAC9C,cAAc,6BAA6B,CAAC;AAC5C,cAAc,kCAAkC,CAAC;AACjD,cAAc,gCAAgC,CAAC;AAM/C,cAAc,yBAAyB,CAAC;AAMxC,cAAc,2BAA2B,CAAC"}
|
package/dist/index.js
ADDED
|
@@ -0,0 +1,73 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* @parmana/crypto
|
|
3
|
+
*
|
|
4
|
+
* Canonical public API.
|
|
5
|
+
*/
|
|
6
|
+
export * from "./models/HybridCryptoProvider.js";
|
|
7
|
+
export * from "./HybridSignatureProvider.js";
|
|
8
|
+
// -----------------------------------------------------------------------------
|
|
9
|
+
// Serialization
|
|
10
|
+
// -----------------------------------------------------------------------------
|
|
11
|
+
export * from "./CanonicalSerializer.js";
|
|
12
|
+
// -----------------------------------------------------------------------------
|
|
13
|
+
// Hashing
|
|
14
|
+
// -----------------------------------------------------------------------------
|
|
15
|
+
export * from "./TrustRecordHasher.js";
|
|
16
|
+
export * from "./ReceiptHasher.js";
|
|
17
|
+
export * from "./ExecutableContentHasher.js";
|
|
18
|
+
export * from "./ExecutionChainHasher.js";
|
|
19
|
+
// -----------------------------------------------------------------------------
|
|
20
|
+
// Signatures
|
|
21
|
+
// -----------------------------------------------------------------------------
|
|
22
|
+
export * from "./ArtifactSigner.js";
|
|
23
|
+
export * from "./SignatureVerifier.js";
|
|
24
|
+
export * from "./SignatureCommitment.js";
|
|
25
|
+
export * from "./AuthorizationSigner.js";
|
|
26
|
+
export * from "./AuthorizationVerifier.js";
|
|
27
|
+
export * from "./PolicyChangeStepUpAuthorizationCrypto.js";
|
|
28
|
+
export * from "./ApprovalArtifactCrypto.js";
|
|
29
|
+
// -----------------------------------------------------------------------------
|
|
30
|
+
// High-Level Crypto Services
|
|
31
|
+
// -----------------------------------------------------------------------------
|
|
32
|
+
export * from "./ReceiptCrypto.js";
|
|
33
|
+
export * from "./VerificationCrypto.js";
|
|
34
|
+
export * from "./ExecutionTrustRecordCanonicalView.js";
|
|
35
|
+
export * from "./OfflineVerifier.js";
|
|
36
|
+
export * from "./ExecutionIntentCanonicalView.js";
|
|
37
|
+
export * from "./ExecutionIntentCrypto.js";
|
|
38
|
+
export * from "./RefusalCrypto.js";
|
|
39
|
+
export * from "./AuditEventCrypto.js";
|
|
40
|
+
export * from "./CallerAuditChainVerifier.js";
|
|
41
|
+
export * from "./PolicyChangeCrypto.js";
|
|
42
|
+
export * from "./ExecutionChainCrypto.js";
|
|
43
|
+
// -----------------------------------------------------------------------------
|
|
44
|
+
// Bootstrap & Configuration
|
|
45
|
+
// -----------------------------------------------------------------------------
|
|
46
|
+
export * from "./CryptoBuilder.js";
|
|
47
|
+
export * from "./CryptoBootstrap.js";
|
|
48
|
+
export * from "./KeyPair.js";
|
|
49
|
+
export * from "./KeyStore.js";
|
|
50
|
+
export * from "./KeyProvider.js";
|
|
51
|
+
export * from "./providers/key/FileKeyProvider.js";
|
|
52
|
+
export * from "./KeyExpiry.js";
|
|
53
|
+
export * from "./Signer.js";
|
|
54
|
+
export * from "./SignerBootstrap.js";
|
|
55
|
+
export * from "./providers/signer/LocalFileSigner.js";
|
|
56
|
+
export * from "./providers/signer/KmsSigner.js";
|
|
57
|
+
export * from "./providers/SignerKeyProviderAdapter.js";
|
|
58
|
+
// -----------------------------------------------------------------------------
|
|
59
|
+
// Provider Interfaces
|
|
60
|
+
// -----------------------------------------------------------------------------
|
|
61
|
+
export * from "./providers/CryptoProvider.js";
|
|
62
|
+
export * from "./providers/HashProvider.js";
|
|
63
|
+
export * from "./providers/SignatureProvider.js";
|
|
64
|
+
export * from "./providers/ProviderFactory.js";
|
|
65
|
+
// -----------------------------------------------------------------------------
|
|
66
|
+
// Errors
|
|
67
|
+
// -----------------------------------------------------------------------------
|
|
68
|
+
export * from "./errors/CryptoError.js";
|
|
69
|
+
// -----------------------------------------------------------------------------
|
|
70
|
+
// Runtime capability detection
|
|
71
|
+
// -----------------------------------------------------------------------------
|
|
72
|
+
export * from "./support/MlDsaSupport.js";
|
|
73
|
+
//# sourceMappingURL=index.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AACH,cAAc,kCAAkC,CAAC;AACjD,cAAc,8BAA8B,CAAC;AAE7C,gFAAgF;AAChF,gBAAgB;AAChB,gFAAgF;AAEhF,cAAc,0BAA0B,CAAC;AAEzC,gFAAgF;AAChF,UAAU;AACV,gFAAgF;AAEhF,cAAc,wBAAwB,CAAC;AACvC,cAAc,oBAAoB,CAAC;AACnC,cAAc,8BAA8B,CAAC;AAC7C,cAAc,2BAA2B,CAAC;AAE1C,gFAAgF;AAChF,aAAa;AACb,gFAAgF;AA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Provider } from "../providers/CryptoProvider.js";
|
|
2
|
+
/**
|
|
3
|
+
* Two independent crypto providers used together.
|
|
4
|
+
*/
|
|
5
|
+
export interface HybridCryptoProvider {
|
|
6
|
+
readonly primary: CryptoProvider;
|
|
7
|
+
readonly secondary: CryptoProvider;
|
|
8
|
+
}
|
|
9
|
+
//# sourceMappingURL=HybridCryptoProvider.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"HybridCryptoProvider.d.ts","sourceRoot":"","sources":["../../src/models/HybridCryptoProvider.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,gCAAgC,CAAC;AAErE;;GAEG;AACH,MAAM,WAAW,oBAAoB;IACnC,QAAQ,CAAC,OAAO,EAAE,cAAc,CAAC;IAEjC,QAAQ,CAAC,SAAS,EAAE,cAAc,CAAC;CACpC"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"HybridCryptoProvider.js","sourceRoot":"","sources":["../../src/models/HybridCryptoProvider.ts"],"names":[],"mappings":""}
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
import type { HashProvider } from "./HashProvider.js";
|
|
2
|
+
import type { SignatureProvider } from "./SignatureProvider.js";
|
|
3
|
+
/**
|
|
4
|
+
* Configured cryptographic capabilities.
|
|
5
|
+
*
|
|
6
|
+
* Provider selection is performed by the
|
|
7
|
+
* ProviderFactory. Consumers use the configured
|
|
8
|
+
* providers without knowing the underlying
|
|
9
|
+
* algorithms.
|
|
10
|
+
*/
|
|
11
|
+
export interface CryptoProvider {
|
|
12
|
+
readonly hash: HashProvider;
|
|
13
|
+
readonly signature: SignatureProvider;
|
|
14
|
+
}
|
|
15
|
+
//# sourceMappingURL=CryptoProvider.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"CryptoProvider.d.ts","sourceRoot":"","sources":["../../src/providers/CryptoProvider.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,mBAAmB,CAAC;AAEtD,OAAO,KAAK,EAAE,iBAAiB,EAAE,MAAM,wBAAwB,CAAC;AAEhE;;;;;;;GAOG;AACH,MAAM,WAAW,cAAc;IAC7B,QAAQ,CAAC,IAAI,EAAE,YAAY,CAAC;IAE5B,QAAQ,CAAC,SAAS,EAAE,iBAAiB,CAAC;CACvC"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"CryptoProvider.js","sourceRoot":"","sources":["../../src/providers/CryptoProvider.ts"],"names":[],"mappings":""}
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
import type { HashAlgorithm } from "@parmana/shared";
|
|
2
|
+
/**
|
|
3
|
+
* Hash Provider.
|
|
4
|
+
*
|
|
5
|
+
* Abstraction for cryptographic hashing.
|
|
6
|
+
*/
|
|
7
|
+
export interface HashProvider {
|
|
8
|
+
/**
|
|
9
|
+
* Canonical algorithm identifier.
|
|
10
|
+
*/
|
|
11
|
+
readonly algorithm: HashAlgorithm;
|
|
12
|
+
/**
|
|
13
|
+
* Computes a cryptographic hash.
|
|
14
|
+
*/
|
|
15
|
+
hash(data: Uint8Array): Promise<string>;
|
|
16
|
+
}
|
|
17
|
+
//# sourceMappingURL=HashProvider.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"HashProvider.d.ts","sourceRoot":"","sources":["../../src/providers/HashProvider.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,iBAAiB,CAAC;AAErD;;;;GAIG;AACH,MAAM,WAAW,YAAY;IAC3B;;OAEG;IACH,QAAQ,CAAC,SAAS,EAAE,aAAa,CAAC;IAElC;;OAEG;IACH,IAAI,CAAC,IAAI,EAAE,UAAU,GAAG,OAAO,CAAC,MAAM,CAAC,CAAC;CACzC"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"HashProvider.js","sourceRoot":"","sources":["../../src/providers/HashProvider.ts"],"names":[],"mappings":""}
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
import type { HashAlgorithm } from "@parmana/shared";
|
|
2
|
+
import type { HashProvider } from "./HashProvider.js";
|
|
3
|
+
/**
|
|
4
|
+
* Registry of hash providers.
|
|
5
|
+
*/
|
|
6
|
+
export declare class HashRegistry {
|
|
7
|
+
private readonly providers;
|
|
8
|
+
register(provider: HashProvider): this;
|
|
9
|
+
get(algorithm: HashAlgorithm): HashProvider;
|
|
10
|
+
}
|
|
11
|
+
//# sourceMappingURL=HashRegistry.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"HashRegistry.d.ts","sourceRoot":"","sources":["../../src/providers/HashRegistry.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,iBAAiB,CAAC;AAErD,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,mBAAmB,CAAC;AAEtD;;GAEG;AACH,qBAAa,YAAY;IACvB,OAAO,CAAC,QAAQ,CAAC,SAAS,CAA0C;IAEpE,QAAQ,CAAC,QAAQ,EAAE,YAAY,GAAG,IAAI,CAIrC;IAED,GAAG,CAAC,SAAS,EAAE,aAAa,GAAG,YAAY,CAQ1C;CACF"}
|