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.
30 lines (29 loc) • 1.42 kB
TypeScript
/**
* RSA DigestInfo Workaround
*
* Some older signing tools (particularly pre-Java 8) produced RSA signatures with
* non-standard DigestInfo format - missing the NULL parameter in AlgorithmIdentifier.
*
* Standard DigestInfo for SHA-1: 30 21 30 09 06 05 2b0e03021a 05 00 04 14 [hash]
* Non-standard (missing NULL): 30 1f 30 07 06 05 2b0e03021a 04 14 [hash]
*
* Web Crypto API's subtle.verify() is strict and rejects the non-standard format.
* This module provides a fallback that manually performs RSA verification using
* BigInt math, which works in both browser and Node.js environments.
*/
/**
* Verify RSA signature with non-standard DigestInfo format.
*
* This function performs RSA signature verification that tolerates
* non-standard DigestInfo formats (missing NULL in AlgorithmIdentifier).
*
* - Node.js: Uses native crypto.publicDecrypt() for speed
* - Browser: Uses BigInt math (Web Crypto doesn't expose raw RSA)
*
* @param publicKeyData SPKI-formatted public key
* @param signatureBytes Raw signature bytes
* @param dataToVerify The data that was signed
* @param hashAlgorithm Hash algorithm name (e.g., "SHA-1", "SHA-256")
* @returns true if signature is valid, false otherwise
*/
export declare function verifyRsaWithNonStandardDigestInfo(publicKeyData: ArrayBuffer, signatureBytes: Uint8Array, dataToVerify: Uint8Array, hashAlgorithm: string): Promise<boolean>;