@keeex/tsr
Version:
Manipulate data related to TSR with pki.js
62 lines (61 loc) • 3.02 kB
TypeScript
/**
* @license
* @preserve
*
* KeeeX SAS Public code
* https://keeex.me
* Copyright 2013-2024 KeeeX All Rights Reserved.
*
* These computer program listings and specifications, herein,
* are and remain the property of KeeeX SAS. The intellectual
* and technical concepts herein are proprietary to KeeeX SAS
* and may be covered by EU and foreign patents,
* patents in process, trade secrets and copyright law.
*
* These listings are published as a way to provide third party
* with the ability to process KeeeX data.
* As such, support for public inquiries is limited.
* They are provided "as-is", without warrany of any kind.
*
* They shall not be reproduced or copied or used in whole or
* in part as the basis for manufacture or sale of items unless
* prior written permission is obtained from KeeeX SAS.
*
* For a license agreement, please contact:
* <mailto: contact@keeex.net>
*
*/
import * as digest from "@keeex/crypto/digest.js";
import * as asn1js from "asn1js";
import * as pkijs from "pkijs";
import * as types from "./types.js";
/** If not already setup otherwise, setup pkijs crypto engine and return subtle implementation */
export declare const getCryptoImpl: (tryLoad?: boolean) => Promise<SubtleCrypto>;
/** Convert digest algorithm from `@keeex/crypto` to ASN1 identifier */
export declare const cryptoDigestAlgToPkiOid: (algorithm: digest.Algorithms) => string;
export declare const pkiOidToCryptoDigestAlg: (algorithm: digest.Algorithms | string) => digest.Algorithms;
/** Convert a `@keeex/crypto` digest alg name to a subtlecrypto alg name */
export declare const cryptoDigestAlgToSubtleAlg: (algorithm: digest.Algorithms) => string;
/**
* Return a SigningCertificate sequence
*
* If multiple certificates are provided, the signing one is expected to be the first one.
*/
export declare const createSigningCertificate: (certs: pkijs.Certificate | Array<pkijs.Certificate>) => Promise<asn1js.Sequence>;
/** Return the digest of an OctetString */
export declare const getContentDigest: (content: asn1js.OctetString, algorithm: digest.Algorithms | string) => Promise<asn1js.OctetString>;
export declare const loadCertificate: (certificatePEM: string) => pkijs.Certificate;
export declare const loadCertificates: (certificatesPEM: string) => Array<pkijs.Certificate>;
/**
* Load a private key from a PEM PKCS#8 file using SubtleCrypto
*
* @param digestAlgorithm - Used only for RSA, because we have to provide something for SubtleCrypto
*/
export declare const loadPrivateKey: (privateKeyPEM: string, certificate: pkijs.Certificate, digestAlgorithm?: digest.Algorithms) => Promise<CryptoKey>;
/** Return the CN string */
export declare const getCnString: (attr: pkijs.RelativeDistinguishedNames) => string;
export declare const messageImprintFromInput: (input: types.MessageInput) => Promise<pkijs.MessageImprint>;
export declare const digestFromMessageInput: (input: types.MessageInput) => Promise<{
digest: Uint8Array;
algorithm: digest.Algorithms;
}>;