Only 8, 16, 24, or 32 bits supported: 248
I maintainer di solito rispondono entro 1 giorno
Nessuno ha ancora preso questa issue.
Valutazione
- Difficoltà
- 4/5
- Tempo stimato
- 3-5 giorni
- Idoneità per principianti
- 25/100
- Tipo di issue
- Bug
- Chiarezza
- Da chiarire
- Stato di attività
- Ferma
- Stack tecnologico
- javascript
- Ambito
- cryptography, security
Direzione di ricerca
Start with forge.pki.decryptRsaPrivateKey and its forge.min.js stack frames, especially forge.asn1.fromDer and ByteStringBuffer.getInt. Reproduce the failure with the private keys that produce the 248-bit error, then determine whether the parser should reject or handle that input and add a regression case if a supported-key failure is confirmed.
Scritto dal modello di indicizzazione a partire dal testo della issue.
Descrizione
Hello,
I'm trying to decrypt a private key but am getting the following error when trying to decrypt - I was wondering if anyone has seen this before please?
Weirdly, this only seems to be from 'certain' private keys - we have lots of users that decrypt without issue, but every so often we get this error from Forge,
Thanks,
Will.
requestdownload:524 Error: Error: Only 8, 16, 24, or 32 bits supported: 248
at s (forge.min.js:1:1)
at i.ByteStringBuffer.getInt (forge.min.js:1:1)
at forge.min.js:1:1
at e (forge.min.js:1:1)
at n.fromDer (forge.min.js:1:1)
at s.decryptPrivateKeyInfo (forge.min.js:1:1)
at s.decryptRsaPrivateKey (forge.min.js:1:1)
at HTMLAnchorElement.<anonymous> (requestdownload:501:54)
at HTMLAnchorElement.dispatch (jquery.min.js:2:43064)
at v.handle (jquery.min.js:2:41048)
The code used is as follows:
const fileSelector = document.getElementById('privateKeyPicker');
fileSelector.addEventListener('change', () => {
const fileReader = new FileReader();
fileReader.onloadend = (function (loadEvent) {
let textFromFileLoaded = loadEvent.target.result;
$("#certkey").val(textFromFileLoaded);
keyValid();
});
fileReader.readAsText(document.getElementById('privateKeyPicker').files[0])
});
function downloadCert(b64p12) {
const myBuffer = base64DecToArr(b64p12).buffer;
const p12blob = new Blob([myBuffer], {type: 'application/x-pkcs12'});
saveAs(p12blob, "certBundle.p12");
}
$(document).ready(function () {
$("#createP12Button").click(function () {
//error checking to ensure all fields are filled in
if ($('#keypass').val() === "" && $('#certkey').val() === "=") {
alert("Please enter private key password and use 'Choose File' and 'Load File' buttons to select private key (or paste private key into textarea)");
} else if ($('#keypass').val() === "") {
alert("Please enter private key password");
} else if ($('#certkey').val() === "") {
alert("Please use 'Choose File' and 'Load File' buttons to select your private key (or paste private key into textarea)");
} else {
//regex to ensure only private key used from text pasted in
const regexPrivKey = $("#certkey").val().match(/(-----BEGIN \b(ENCRYPTED|RSA)\b PRIVATE KEY-----)[\s\S]*(-----END \b(ENCRYPTED|RSA)\b PRIVATE KEY-----)/);
if (regexPrivKey === null) {
alert("Private key not found, please ensure correct file has been selected or pasted into text area.");
} else {
const _pem = {
certificateDev: $("#certpem").val(),
privateKeyDev: regexPrivKey[0]
};
// Try to parse certificate and private key object
try {
const cert = forge.pki.certificateFromPem(_pem.certificateDev, true);
const password = $('#keypass').val();
const privateKey = forge.pki.decryptRsaPrivateKey(_pem.privateKeyDev, password);
if (privateKey !== null) {
if (privateKey.n.toString() !== cert.publicKey.n.toString()) {
alert("Private and public key modulo do not match. Are you sure you uploaded the correct file?")
} else {
const chain = [cert];
//create PKCS12
console.log('\nCreating PKCS#12...');
const newPkcs12Asn1 = forge.pkcs12.toPkcs12Asn1(privateKey, chain, password,
{generateLocalKeyId: true, friendlyName: 'myUkCaCertificate', algorithm: '3des'});
const newPkcs12Der = forge.asn1.toDer(newPkcs12Asn1).getBytes();
console.log('\nBase64-encoded new PKCS#12:');
const b64p12 = forge.util.encode64(newPkcs12Der);
downloadCert(b64p12);
}
} else {
alert("Please enter the correct password for the private key");
}
} catch (ex) {
alert("Could not create private key object - please contact [email protected]");
if (ex.stack) {
console.log('Error name:', ex.name);
console.log('Error message:', ex.message);
console.log('Error:', ex);
console.log(ex.stack);
} else {
console.log('Error name:', ex.name);
console.log('Error message:', ex.message);
console.log('Error:', ex);
}
}
}
}
});
}); // end on ready
- Lingua principale
- JavaScript
- Stelle
- 5.4k
- Fork
- 874
- Merge medio
- 3m
- PR unite (30g)
- 6
Preparare l'ambiente
- Nessun Dockerfile né file Docker Compose
- Nessun modello di pull request
- Leggi la guida per i contributori
Come iniziare
- Leggi tutta la issue e poi la guida ai contributi del progetto.
- Commenta sulla issue per dire che te ne occupi tu — evita che due persone facciano lo stesso lavoro.
- Fai un fork del repository e lavora su un branch.
- Apri una pull request che faccia riferimento al numero della issue.
Altre issue di digitalbazaar/forge
-
Difficoltà 2/5 1-3 ore Idoneità per principianti 82/100
digitalbazaar/forge#1170 ·
I maintainer di solito rispondono entro 1 giorno
-
Difficoltà 3/5 1-2 giorni Idoneità per principianti 52/100
digitalbazaar/forge#1147 ·
I maintainer di solito rispondono entro 1 giorno
-
Difficoltà 4/5 3-5 giorni Idoneità per principianti 45/100
digitalbazaar/forge#1146 ·
I maintainer di solito rispondono entro 1 giorno
-
Difficoltà 4/5 3-5 giorni Idoneità per principianti 58/100
digitalbazaar/forge#1145 ·
I maintainer di solito rispondono entro 1 giorno
-
Difficoltà 3/5 1-2 giorni Idoneità per principianti 48/100
digitalbazaar/forge#1144 ·
I maintainer di solito rispondono entro 1 giorno
Tutte le issue di digitalbazaar/forge
Issue simili
-
stringify escapes leading digits in pseudo-class arguments (:nth-child(1) becomes :nth-child(\31 ))Aperta
Difficoltà 2/5 1-3 ore Idoneità per principianti 83/100
I maintainer di solito rispondono entro 1 giorno
-
Difficoltà 2/5 1-3 ore Idoneità per principianti 76/100
I maintainer di solito rispondono entro 1 giorno
-
Difficoltà 2/5 1-3 ore Idoneità per principianti 68/100
getgrav/grav-plugin-form#664 ·
-
bug web-ui
Difficoltà 2/5 1-3 ore Idoneità per principianti 67/100
jenkinsci/jenkins#27705 · 3 commenti ·
I maintainer di solito rispondono entro 1 giorno
-
bug
Difficoltà 2/5 1-3 ore Idoneità per principianti 70/100
maproulette/maproulette-frontend#2978 ·
I maintainer di solito rispondono entro 1 giorno