edockit
Version:
A JavaScript library for listing, parsing, and verifying the contents and signatures of electronic documents (eDoc) and Associated Signature Containers (ASiC-E), supporting EU eIDAS standards for digital signatures and electronic seals.
16 lines (15 loc) • 695 B
TypeScript
/**
* Fixes ASN.1 DER encoding of RSA keys to be compatible with browser Web Crypto
*
* This specifically targets the issue with modulus padding in SPKI format RSA keys.
* In DER encoding, when the high bit of an INTEGER is set, a 0x00 byte must be
* prepended to distinguish it from a negative number. Some libraries omit this padding,
* which works in Node.js but causes browsers to reject the key.
*/
/**
* Fixes ASN.1 DER encoding of RSA modulus to ensure proper padding
*
* @param publicKeyData The original public key data as ArrayBuffer
* @returns Fixed key with proper modulus padding
*/
export declare function fixRSAModulusPadding(publicKeyData: ArrayBuffer): ArrayBuffer;