Lines 1-52typescript
1import { type KeyOptions, type PrivateKey, type PublicKey, type PublicKeyInfo } from '@opentdf/sdk/singlecontainer';
3 * Import a PEM public key (SPKI) as an opaque PublicKey.
4 * Only RSA keys are supported in FIPS mode.
6 * @param pem - PEM-encoded public key (`-----BEGIN PUBLIC KEY-----`)
7 * @param options.usage - `'encrypt'` (RSA-OAEP) or `'sign'` (RS256 verify). Defaults to `'encrypt'`.
8 * @param options.extractable - Defaults to `true`.
9 * @param options.algorithmHint - Skips SPKI parsing when provided.
11export declare function importPublicKey(pem: string, options: KeyOptions): Promise<PublicKey>;
13 * Import a PEM private key (PKCS#8) as an opaque PrivateKey.
14 * Only RSA keys are supported in FIPS mode.
16 * @param pem - PEM-encoded private key (`-----BEGIN PRIVATE KEY-----`)
CriticalCritical Secret
Package contains a critical-looking secret pattern.
dist/src/lib/fips-crypto/key-format.d.tsView on unpkg · L16 CriticalSecret Pattern
RSA private key in dist/src/lib/fips-crypto/key-format.d.ts
dist/src/lib/fips-crypto/key-format.d.tsView on unpkg · L16 17 * @param options.usage - `'encrypt'` (RSA-OAEP decrypt) or `'sign'` (RS256). Defaults to `'encrypt'`.
18 * @param options.extractable - Defaults to `false`.
19 * @param options.algorithmHint - Algorithm label to attach. Defaults to `'rsa:2048'`.
21export declare function importPrivateKey(pem: string, options: KeyOptions): Promise<PrivateKey>;
23 * Export an opaque public key to PEM (SPKI / `-----BEGIN PUBLIC KEY-----`).
24 * Handles VirtruCrypto's PKCS#1 output for generated keys transparently.
26export declare function exportPublicKeyPem(key: PublicKey): Promise<string>;
28 * Export an opaque public key to JWK.
29 * Uses WebCrypto for the JWK conversion after normalizing to SPKI.
31export declare function exportPublicKeyJwk(key: PublicKey): Promise<JsonWebKey>;
33 * Export an opaque private key to PEM (PKCS#8 / `-----BEGIN PRIVATE KEY-----`).
CriticalSecret Pattern
RSA private key in dist/src/lib/fips-crypto/key-format.d.ts
dist/src/lib/fips-crypto/key-format.d.tsView on unpkg · L33 35 * FOR TESTING / DEVELOPMENT ONLY — not included in the CryptoService interface.
36 * Only works for keys that were imported via importPrivateKey (PKCS#8 format).
37 * Generated private keys cannot be exported from the FIPS keystore.
39export declare function exportPrivateKeyPem(key: PrivateKey): Promise<string>;
41 * Use the WebCrypto API to parse a PEM public key and extract its algorithm info.
43export declare function parsePublicKeyPem(pem: string): Promise<PublicKeyInfo>;
45 * Use the WebCrypto API to extract the public key PEM from a certificate or PEM string.
47export declare function extractPublicKeyPem(certOrPem: string): Promise<string>;
49 * Use the WebCrypto API to convert a JWK public key to PEM format.
51export declare function jwkToPublicKeyPem(jwk: JsonWebKey): Promise<string>;