How to use the webcrypto-core.AlgorithmError function in webcrypto-core

To help you get started, we’ve selected a few webcrypto-core examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github PeculiarVentures / webcrypto-liner / src / rsa / crypto.ts View on Github external
public static alg2jwk(alg: Algorithm) {
        const hash = (alg as any).hash as Algorithm;
        const hashSize = /(\d+)/.exec(![1];
        switch (!.toUpperCase()) {
            case AlgorithmNames.RsaOAEP.toUpperCase():
                return `RSA-OAEP${hashSize === "1" ? "" : `-${hashSize}`}`;
            case AlgorithmNames.RsaPSS.toUpperCase():
                return `PS${hashSize}`;
            case AlgorithmNames.RsaSSA.toUpperCase():
                return `RS${hashSize}`;
                throw new AlgorithmError(AlgorithmError.UNSUPPORTED_ALGORITHM,;
github PeculiarVentures / webcrypto-liner / src / mechs / sha / crypto.ts View on Github external
public static getDigest(name: string) {
    switch (name) {
      case "SHA-1":
        return new asmCrypto.Sha1();
      case "SHA-256":
        return new asmCrypto.Sha256();
      case "SHA-512":
        return new asmCrypto.Sha512();
        throw new core.AlgorithmError("keyAlgorithm.hash: Is not recognized");
github PeculiarVentures / node-webcrypto-ossl / lib / crypto / pbkdf2.ts View on Github external
.then((raw) => {
                let CryptoClass: typeof Core.BaseCrypto;
                switch ( {
                    case Core.AlgorithmNames.AesCBC:
                    case Core.AlgorithmNames.AesGCM:
                    case Core.AlgorithmNames.AesKW:
                        CryptoClass = AesCrypto;
                    case Core.AlgorithmNames.Hmac:
                        CryptoClass = HmacCrypto;
                        throw new Core.AlgorithmError(Core.AlgorithmError.UNSUPPORTED_ALGORITHM,;
                return CryptoClass.importKey("raw", Buffer.from(raw), derivedKeyType as any, extractable, keyUsages);
github PeculiarVentures / webcrypto / src / mechs / aes / key.ts View on Github external
public get alg() {
    switch ( {
      case "AES-CBC":
        return `A${this.algorithm.length}CBC`;
      case "AES-CTR":
        return `A${this.algorithm.length}CTR`;
      case "AES-GCM":
        return `A${this.algorithm.length}GCM`;
      case "AES-KW":
        return `A${this.algorithm.length}KW`;
      case "AES-CMAC":
        return `A${this.algorithm.length}CMAC`;
      case "AES-ECB":
        return `A${this.algorithm.length}ECB`;
        throw new core.AlgorithmError("Unsupported algorithm name");