How to use the jsrsasign.KEYUTIL.getKey function in jsrsasign

To help you get started, we’ve selected a few jsrsasign 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 qzind / tray / assets / signing / sign-message.ts View on Github external
.then(data => {
     var pk = KEYUTIL.getKey(data);
     var sig = new KJUR.crypto.Signature({"alg": "SHA512withRSA"}); // Use "SHA1withRSA" for QZ Tray 2.0 and older
     sig.init(pk);
     sig.updateString(hash);
     var hex = sig.sign();
     console.log("DEBUG: \n\n" + stob64(hextorstr(hex)));
     resolve(stob64(hextorstr(hex)));
   })
   .catch(err => console.error(err));
github HL7-DaVinci / CRD / server / src / main / resources / node_interfaces / src / components / publicKey / EditEntry.js View on Github external
getKeyID(value){
        var encodedKey = null;
        try{
            encodedKey=JSON.parse(value);
        }catch(e){
            // the key is not JSON formatted
            encodedKey=value;
        }
        keyID = "";
        try{
            var pubKey = KEYUTIL.getKey(encodedKey);
            // this part won't fail
            var jwkPub = KEYUTIL.getJWKFromKey(pubKey);
            var keyID = KJUR.jws.JWS.getJWKthumbprint(jwkPub);
        }catch(e){
            // the key cannot be retrieved.
            console.log(e);
        }
        return keyID;
    }
github HL7-DaVinci / CRD / server / src / main / resources / node_interfaces / src / components / publicKey / KeyEntry.js View on Github external
updateContent(event){
        event.preventDefault();
        this.setState({animationClasses:"keyEntry"});
        console.log(this.state.animationClasses)
        try{
            var jwtPub = JSON.parse(this.state.jwt);
        }catch(e){
            jwtPub = this.state.jwt;
        }
        try{
            var pubKey = KEYUTIL.getKey(jwtPub);
            var jwkPub = KEYUTIL.getJWKFromKey(pubKey);
            this.setState({jwt: JSON.stringify(jwkPub)})
            // Dynamically generating a key id is counterintuitive when you 
            // can just add a new key that will auto-generate an ID.  
            // In the unlikely event that users want to be able to directly
            // edit an existing key (aka, acutally editing the text in
            // the PEM string, or the JSON) this could be useful, but I doubt that anybody
            // will be changing individual characters in an encoded string.  
            
            var keyID = KJUR.jws.JWS.getJWKthumbprint(jwkPub);
            if(keyID !=this.state.kid){
                this.props.updateIdCB(this.state.kid,keyID, jwkPub);
                this.setState({kid: keyID});
            }
            this.setState({data: "text/json;charset=utf-8," + encodeURIComponent(JSON.stringify(jwkPub))});
github hyperledger / fabric-sdk-node / fabric-network / lib / impl / wallet / hsmwalletmixin.js View on Github external
async importIdentity(client, label, identity) {
		// check the identity type
		const cryptoContent = {
			signedCertPEM: identity.certificate
		};
		const publicKey = KEYUTIL.getKey(identity.certificate);
		const ecdsakey = new ecdsaKey(publicKey);
		cryptoContent.privateKeyObj = await this.cryptoSuite.getKey(Buffer.from(ecdsakey.getSKI(), 'hex'));

		await client.createUser({
			username: label,
			mspid: identity.mspId,
			cryptoContent: cryptoContent
		});

	}
github damienbod / AspNetCoreIdentityServer4Persistence / ClientOne / angularApp / app / auth / services / oidc.security.validation.ts View on Github external
'RS256'
                        ]);
                        if (!isValid) {
                            this.loggerService.logWarning(
                                'incorrect Signature, validation failed for id_token'
                            );
                        }
                        return isValid;
                    }
                }
            }
        } else {
            // kid in the Jose header of id_token
            for (const key of jwtkeys.keys) {
                if ((key.kid as string) === (kid as string)) {
                    const publickey = KEYUTIL.getKey(key);
                    isValid = KJUR.jws.JWS.verify(id_token, publickey, [
                        'RS256'
                    ]);
                    if (!isValid) {
                        this.loggerService.logWarning(
                            'incorrect Signature, validation failed for id_token'
                        );
                    }
                    return isValid;
                }
            }
        }

        return isValid;
    }
github damienbod / AspNet5IdentityServerAngularImplicitFlow / src / AngularClient / angularApp / app / auth / services / oidc.security.validation.ts View on Github external
for (const key of jwtkeys.keys) {
                    if (key.kty as string === 'RSA' && key.use as string === 'sig') {
                        const publickey = KEYUTIL.getKey(key);
                        isValid = KJUR.jws.JWS.verify(id_token, publickey, ['RS256']);
                        if (!isValid) {
                            this.oidcSecurityCommon.logWarning('incorrect Signature, validation failed for id_token');
                        }
                        return isValid;
                    }
                }
            }
        } else {
            // kid in the Jose header of id_token
            for (const key of jwtkeys.keys) {
                if (key.kid as string === kid as string) {
                    const publickey = KEYUTIL.getKey(key);
                    isValid = KJUR.jws.JWS.verify(id_token, publickey, ['RS256']);
                    if (!isValid) {
                        this.oidcSecurityCommon.logWarning('incorrect Signature, validation failed for id_token');
                    }
                    return isValid;
                }
            }
        }

        return isValid;
    }
github damienbod / AspNet5IdentityServerAngularImplicitFlow / src / AngularClientCode / angularApp / app / auth / services / oidc.security.validation.ts View on Github external
for (const key of jwtkeys.keys) {
                if ((key.kty as string) === 'RSA' && (key.use as string) === 'sig') {
                    amountOfMatchingKeys = amountOfMatchingKeys + 1;
                }
            }

            if (amountOfMatchingKeys === 0) {
                this.loggerService.logWarning('no keys found, incorrect Signature, validation failed for id_token');
                return false;
            } else if (amountOfMatchingKeys > 1) {
                this.loggerService.logWarning('no ID Token kid claim in JOSE header and multiple supplied in jwks_uri');
                return false;
            } else {
                for (const key of jwtkeys.keys) {
                    if ((key.kty as string) === 'RSA' && (key.use as string) === 'sig') {
                        const publickey = KEYUTIL.getKey(key);
                        isValid = KJUR.jws.JWS.verify(id_token, publickey, ['RS256']);
                        if (!isValid) {
                            this.loggerService.logWarning('incorrect Signature, validation failed for id_token');
                        }
                        return isValid;
                    }
                }
            }
        } else {
            // kid in the Jose header of id_token
            for (const key of jwtkeys.keys) {
                if ((key.kid as string) === (kid as string)) {
                    const publickey = KEYUTIL.getKey(key);
                    isValid = KJUR.jws.JWS.verify(id_token, publickey, ['RS256']);
                    if (!isValid) {
                        this.loggerService.logWarning('incorrect Signature, validation failed for id_token');
github HL7-DaVinci / CRD / server / src / main / resources / node_interfaces / src / components / publicKey / EditEntry.js View on Github external
updateContent(event){
        try{
            var jwtPub = JSON.parse(this.state.jwt);
        }catch(e){
            jwtPub = this.state.jwt;
        }
        try{
            var pubKey = KEYUTIL.getKey(jwtPub);

            var jwkPub = KEYUTIL.getJWKFromKey(pubKey);
            this.setState({jwt: JSON.stringify(jwkPub)})
            var keyID = KJUR.jws.JWS.getJWKthumbprint(jwkPub);
            // this.props.updateIdCB(this.state.kid,keyID, jwkPub);
            this.setState({kid: keyID});

            
        }catch(e){
        }

        
        
        event.preventDefault();
        if(!this.state.editMode){
            this.setState({editMode:true});
github damienbod / AspNet5IdentityServerAngularImplicitFlow / src / AngularClientCode / angularApp / app / auth / services / oidc.security.validation.js View on Github external
amountOfMatchingKeys = amountOfMatchingKeys + 1;
                }
            }
            if (amountOfMatchingKeys === 0) {
                this.loggerService.logWarning('no keys found, incorrect Signature, validation failed for id_token');
                return false;
            }
            else if (amountOfMatchingKeys > 1) {
                this.loggerService.logWarning('no ID Token kid claim in JOSE header and multiple supplied in jwks_uri');
                return false;
            }
            else {
                for (var _b = 0, _c = jwtkeys.keys; _b < _c.length; _b++) {
                    var key = _c[_b];
                    if (key.kty === 'RSA' && key.use === 'sig') {
                        var publickey = KEYUTIL.getKey(key);
                        isValid = KJUR.jws.JWS.verify(id_token, publickey, ['RS256']);
                        if (!isValid) {
                            this.loggerService.logWarning('incorrect Signature, validation failed for id_token');
                        }
                        return isValid;
                    }
                }
            }
        }
        else {
            for (var _d = 0, _e = jwtkeys.keys; _d < _e.length; _d++) {
                var key = _e[_d];
                if (key.kid === kid) {
                    var publickey = KEYUTIL.getKey(key);
                    isValid = KJUR.jws.JWS.verify(id_token, publickey, ['RS256']);
                    if (!isValid) {

jsrsasign

opensource free pure JavaScript cryptographic library supports RSA/RSAPSS/ECDSA/DSA signing/validation, ASN.1, PKCS#1/5/8 private/public key, X.509 certificate, CRL, OCSP, CMS SignedData, TimeStamp and CAdES and JSON Web Signature(JWS)/Token(JWT)/Key(JWK)

MIT
Latest version published 11 months ago

Package Health Score

74 / 100
Full package analysis