webcrypto-api

Javascript - key / certificate from USB Token

南楼画角 提交于 2019-12-28 03:10:36
问题 I would like to ask if is still impossible, using JavaScript, to get key from USB token or from certificate stored in Browser . I was reading many articles which said WebCryptoApi doesn't enable to do that. Is any option to get key from token? Maybe something was changed? 回答1: It is not possible for now. The WebCryptoApi does not support using keys stored in external keystores like smartcards, Mozilla keystore or Windows KeyStore (used by Chrome and Explorer), and reading the comments of the

Public Key Encryption in Microsoft Edge

為{幸葍}努か 提交于 2019-12-23 10:59:22
问题 I have the following JavaScript code to implement public key encryption using the Web Cryptography API. It works for Firefox and Chrome but fails for Microsoft Edge. The error I am getting from Edge is "Could not complete the operation due to error 80700011." What have I missed? <script> var data = new Uint8Array([0, 1, 2, 3, 4, 5, 6, 7, 8, 9]); var crypto = window.crypto || window.msCrypto; var cryptoSubtle = crypto.subtle; cryptoSubtle.generateKey( { name: "RSA-OAEP", modulusLength: 2048,

Angular JS Cryptography. pbkdf2 and iteration

家住魔仙堡 提交于 2019-12-23 04:13:36
问题 I want to convert my string to PBKDF2 with sha512 and iteration count. I did in nodejs by using "pbkdf2" module. how can i achieve the same in angular JS. 回答1: You can use built-in WebCryptographyApi with native support in all modern browsers (http://caniuse.com/#feat=cryptography) This in an example extracted (and modified) from here and here function deriveAKey(password, salt, iterations, hash) { // First, create a PBKDF2 "key" containing the password window.crypto.subtle.importKey( "raw",

How to decrypt data from the result of an IE 11 encrypt operation using AES-GCM

被刻印的时光 ゝ 提交于 2019-12-21 17:06:34
问题 I've managed to encrypt some data with AES-GCM using IE 11 on Windows 10 but I can't get decryption to work. Example encryption JS code: let plainText = new Uint8Array([1]); let key; let keyBuf = window.msCrypto.getRandomValues(new Uint8Array(32)); let iv = window.msCrypto.getRandomValues(new Uint8Array(12)); let additionalData = window.msCrypto.getRandomValues(new Uint8Array(16)); let encResult; let importOp = window.msCrypto.subtle.importKey('raw', keyBuf, { name: 'AES-GCM' }, false, [

How to load a public key in PEM format for encryption?

狂风中的少年 提交于 2019-12-21 00:40:40
问题 Until now I used JSEncrypt which is able to load a public key from a PEM formatted string. And then use it with RSA in order to encrypt a string. For example : <textarea id="pubkey">-----BEGIN PUBLIC KEY----- MIGfMA0GCSqGSIb3DQEBAQUAA4GNADCBiQKBgQC+iOltdDtDdUq6u67L2Mb4HW5j 7E1scmYtg2mnnQD85LxFICZv3I3rQ4wMulfcH+n9VCrifdu4vN89lRLKgsb9Kzim GUrbOWEZdKZ9D5Sfo90EXocM5NtHou14aN8xkRWbN7x/RK5o9jfJwKmrC1fCm6tx 2Qwvx5kypWQUN6UpCQIDAQAB -----END PUBLIC KEY----- </textarea> and then: var encrypt = new

Accessing signing/encryption in a browser's Keystore using JavaScript - sample code? (WebCryptoAPI)

烈酒焚心 提交于 2019-12-18 00:17:12
问题 I have a web server that allows access only using X509 authentication. Works like a charm. Now I want to extend the use of the X509 certificates (which are stored in the user's browser keystore) to Sign data before it is sent to the server (using JavaScript and HTTPPost) Decrypt data read from the server (where it gets encrypted using the user's public key stored there) I found this example doing RSA Signature which is pretty close.... only it does take the key from a HTML textarea. I want to

p12 file import failure in windows certificate store by forge JavaScript library

此生再无相见时 提交于 2019-12-12 19:12:10
问题 I am using forge library to create a self signed certificate in .p12 format which generates private-public key pair using WebCryptoAPI. But when i am trying to import the .p12 file in windows certificate store, i am getting the following error : This link says that there might be issue with private key. Following is my key generation snippet by webcryptoApi window.crypto.subtle.generateKey({ name: 'RSA-PSS', modulusLength: 2048, publicExponent: new Uint8Array([0x01, 0x00, 0x01]), hash: {name:

Web Crypto API: importKey does not work in Firefox

那年仲夏 提交于 2019-12-11 13:53:04
问题 I tried this example for importKey in Google Chrome 46 and Firefox 41 (JSBin): window.crypto.subtle.importKey( "jwk", //can be "jwk" (public or private), "spki" (public only), or "pkcs8" (private only) { //this is an example jwk key, other key types are Uint8Array objects kty: "RSA", e: "AQAB", n: "vGO3eU16ag9zRkJ4AK8ZUZrjbtp5xWK0LyFMNT8933evJoHeczexMUzSiXaLrEFSyQZortk81zJH3y41MBO_UFDO_X0crAquNrkjZDrf9Scc5-MdxlWU2Jl7Gc4Z18AC9aNibWVmXhgvHYkEoFdLCFG-2Sq-qIyW4KFkjan05IE", alg: "PS256", ext: true

Safari WebCrypto API RSA-OAEP encryption

喜夏-厌秋 提交于 2019-12-11 03:48:39
问题 I have the following code to test WebCrypto API. It works in Firefox and Chrome and I am trying to make it work in Safari. function ab2str(buf) { return String.fromCharCode.apply(null, new Uint16Array(buf)); } //converts a forge 0.6.x string of bytes to an ArrayBuffer function str2ab(str) { var b = new ArrayBuffer(str.length); var view = new Uint8Array(b); for(var i = 0; i < str.length; ++i) { view[i] = str.charCodeAt(i); } return b; } function _arrayBufferToBase64( buffer ) { var binary = ''

How to enable crypto.subtle for unsecure origins in Chrome?

假如想象 提交于 2019-12-11 00:07:33
问题 In Chrome 60, they added a feature that disables crypto.subtle for non-TLS connections. Our product needs to run a local server and forward some secure remote connections to localhost for security reasons. Because localhost isn't technically a named domain, we cannot use TLS--effectively making crypto.subtle unusable in Chrome (and chromium-based browsers like Opera), and forcing us to use a less secure shim like asmCrypto.js . Is there any way to tell Chrome to enable crypto.subtle through