mirror of
https://gitlab.winehq.org/wine/wine-gecko.git
synced 2024-09-13 09:24:08 -07:00
Bug 1191936 - Implement RSA-PSS key generation r=rbarnes
This commit is contained in:
parent
6f36eece83
commit
c594a59e41
@ -27,6 +27,7 @@
|
|||||||
#define WEBCRYPTO_ALG_PBKDF2 "PBKDF2"
|
#define WEBCRYPTO_ALG_PBKDF2 "PBKDF2"
|
||||||
#define WEBCRYPTO_ALG_RSASSA_PKCS1 "RSASSA-PKCS1-v1_5"
|
#define WEBCRYPTO_ALG_RSASSA_PKCS1 "RSASSA-PKCS1-v1_5"
|
||||||
#define WEBCRYPTO_ALG_RSA_OAEP "RSA-OAEP"
|
#define WEBCRYPTO_ALG_RSA_OAEP "RSA-OAEP"
|
||||||
|
#define WEBCRYPTO_ALG_RSA_PSS "RSA-PSS"
|
||||||
#define WEBCRYPTO_ALG_ECDH "ECDH"
|
#define WEBCRYPTO_ALG_ECDH "ECDH"
|
||||||
#define WEBCRYPTO_ALG_ECDSA "ECDSA"
|
#define WEBCRYPTO_ALG_ECDSA "ECDSA"
|
||||||
#define WEBCRYPTO_ALG_DH "DH"
|
#define WEBCRYPTO_ALG_DH "DH"
|
||||||
@ -247,6 +248,8 @@ NormalizeToken(const nsString& aName, nsString& aDest)
|
|||||||
aDest.AssignLiteral(WEBCRYPTO_ALG_RSASSA_PKCS1);
|
aDest.AssignLiteral(WEBCRYPTO_ALG_RSASSA_PKCS1);
|
||||||
} else if (NORMALIZED_EQUALS(aName, WEBCRYPTO_ALG_RSA_OAEP)) {
|
} else if (NORMALIZED_EQUALS(aName, WEBCRYPTO_ALG_RSA_OAEP)) {
|
||||||
aDest.AssignLiteral(WEBCRYPTO_ALG_RSA_OAEP);
|
aDest.AssignLiteral(WEBCRYPTO_ALG_RSA_OAEP);
|
||||||
|
} else if (NORMALIZED_EQUALS(aName, WEBCRYPTO_ALG_RSA_PSS)) {
|
||||||
|
aDest.AssignLiteral(WEBCRYPTO_ALG_RSA_PSS);
|
||||||
} else if (NORMALIZED_EQUALS(aName, WEBCRYPTO_ALG_ECDH)) {
|
} else if (NORMALIZED_EQUALS(aName, WEBCRYPTO_ALG_ECDH)) {
|
||||||
aDest.AssignLiteral(WEBCRYPTO_ALG_ECDH);
|
aDest.AssignLiteral(WEBCRYPTO_ALG_ECDH);
|
||||||
} else if (NORMALIZED_EQUALS(aName, WEBCRYPTO_ALG_ECDSA)) {
|
} else if (NORMALIZED_EQUALS(aName, WEBCRYPTO_ALG_ECDSA)) {
|
||||||
|
@ -2289,7 +2289,8 @@ GenerateAsymmetricKeyTask::GenerateAsymmetricKeyTask(
|
|||||||
// Construct an appropriate KeyAlorithm
|
// Construct an appropriate KeyAlorithm
|
||||||
uint32_t privateAllowedUsages = 0, publicAllowedUsages = 0;
|
uint32_t privateAllowedUsages = 0, publicAllowedUsages = 0;
|
||||||
if (mAlgName.EqualsLiteral(WEBCRYPTO_ALG_RSASSA_PKCS1) ||
|
if (mAlgName.EqualsLiteral(WEBCRYPTO_ALG_RSASSA_PKCS1) ||
|
||||||
mAlgName.EqualsLiteral(WEBCRYPTO_ALG_RSA_OAEP)) {
|
mAlgName.EqualsLiteral(WEBCRYPTO_ALG_RSA_OAEP) ||
|
||||||
|
mAlgName.EqualsLiteral(WEBCRYPTO_ALG_RSA_PSS)) {
|
||||||
RootedDictionary<RsaHashedKeyGenParams> params(aCx);
|
RootedDictionary<RsaHashedKeyGenParams> params(aCx);
|
||||||
mEarlyRv = Coerce(aCx, params, aAlgorithm);
|
mEarlyRv = Coerce(aCx, params, aAlgorithm);
|
||||||
if (NS_FAILED(mEarlyRv)) {
|
if (NS_FAILED(mEarlyRv)) {
|
||||||
@ -2392,6 +2393,7 @@ GenerateAsymmetricKeyTask::GenerateAsymmetricKeyTask(
|
|||||||
|
|
||||||
// Set key usages.
|
// Set key usages.
|
||||||
if (mAlgName.EqualsLiteral(WEBCRYPTO_ALG_RSASSA_PKCS1) ||
|
if (mAlgName.EqualsLiteral(WEBCRYPTO_ALG_RSASSA_PKCS1) ||
|
||||||
|
mAlgName.EqualsLiteral(WEBCRYPTO_ALG_RSA_PSS) ||
|
||||||
mAlgName.EqualsLiteral(WEBCRYPTO_ALG_ECDSA)) {
|
mAlgName.EqualsLiteral(WEBCRYPTO_ALG_ECDSA)) {
|
||||||
privateAllowedUsages = CryptoKey::SIGN;
|
privateAllowedUsages = CryptoKey::SIGN;
|
||||||
publicAllowedUsages = CryptoKey::VERIFY;
|
publicAllowedUsages = CryptoKey::VERIFY;
|
||||||
@ -2402,6 +2404,8 @@ GenerateAsymmetricKeyTask::GenerateAsymmetricKeyTask(
|
|||||||
mAlgName.EqualsLiteral(WEBCRYPTO_ALG_DH)) {
|
mAlgName.EqualsLiteral(WEBCRYPTO_ALG_DH)) {
|
||||||
privateAllowedUsages = CryptoKey::DERIVEKEY | CryptoKey::DERIVEBITS;
|
privateAllowedUsages = CryptoKey::DERIVEKEY | CryptoKey::DERIVEBITS;
|
||||||
publicAllowedUsages = 0;
|
publicAllowedUsages = 0;
|
||||||
|
} else {
|
||||||
|
MOZ_ASSERT(false); // This shouldn't happen.
|
||||||
}
|
}
|
||||||
|
|
||||||
mKeyPair->mPrivateKey.get()->SetExtractable(aExtractable);
|
mKeyPair->mPrivateKey.get()->SetExtractable(aExtractable);
|
||||||
@ -3349,6 +3353,7 @@ WebCryptoTask::CreateGenerateKeyTask(JSContext* aCx,
|
|||||||
return new GenerateSymmetricKeyTask(aCx, aAlgorithm, aExtractable, aKeyUsages);
|
return new GenerateSymmetricKeyTask(aCx, aAlgorithm, aExtractable, aKeyUsages);
|
||||||
} else if (algName.EqualsASCII(WEBCRYPTO_ALG_RSASSA_PKCS1) ||
|
} else if (algName.EqualsASCII(WEBCRYPTO_ALG_RSASSA_PKCS1) ||
|
||||||
algName.EqualsASCII(WEBCRYPTO_ALG_RSA_OAEP) ||
|
algName.EqualsASCII(WEBCRYPTO_ALG_RSA_OAEP) ||
|
||||||
|
algName.EqualsASCII(WEBCRYPTO_ALG_RSA_PSS) ||
|
||||||
algName.EqualsASCII(WEBCRYPTO_ALG_ECDH) ||
|
algName.EqualsASCII(WEBCRYPTO_ALG_ECDH) ||
|
||||||
algName.EqualsASCII(WEBCRYPTO_ALG_ECDSA) ||
|
algName.EqualsASCII(WEBCRYPTO_ALG_ECDSA) ||
|
||||||
algName.EqualsASCII(WEBCRYPTO_ALG_DH)) {
|
algName.EqualsASCII(WEBCRYPTO_ALG_DH)) {
|
||||||
|
@ -20,4 +20,5 @@ skip-if = toolkit == 'android' # bug 1200570
|
|||||||
[test_WebCrypto_PBKDF2.html]
|
[test_WebCrypto_PBKDF2.html]
|
||||||
[test_WebCrypto_Reject_Generating_Keys_Without_Usages.html]
|
[test_WebCrypto_Reject_Generating_Keys_Without_Usages.html]
|
||||||
[test_WebCrypto_RSA_OAEP.html]
|
[test_WebCrypto_RSA_OAEP.html]
|
||||||
|
[test_WebCrypto_RSA_PSS.html]
|
||||||
[test_WebCrypto_Wrap_Unwrap.html]
|
[test_WebCrypto_Wrap_Unwrap.html]
|
||||||
|
78
dom/crypto/test/test_WebCrypto_RSA_PSS.html
Normal file
78
dom/crypto/test/test_WebCrypto_RSA_PSS.html
Normal file
@ -0,0 +1,78 @@
|
|||||||
|
<!DOCTYPE html>
|
||||||
|
<html>
|
||||||
|
|
||||||
|
<head>
|
||||||
|
<title>WebCrypto Test Suite</title>
|
||||||
|
<meta http-equiv="Content-Type" content="text/html;charset=utf-8" />
|
||||||
|
<link rel="stylesheet" href="./test_WebCrypto.css"/>
|
||||||
|
<script src="/tests/SimpleTest/SimpleTest.js"></script>
|
||||||
|
|
||||||
|
<!-- Utilities for manipulating ABVs -->
|
||||||
|
<script src="util.js"></script>
|
||||||
|
|
||||||
|
<!-- A simple wrapper around IndexedDB -->
|
||||||
|
<script src="simpledb.js"></script>
|
||||||
|
|
||||||
|
<!-- Test vectors drawn from the literature -->
|
||||||
|
<script src="./test-vectors.js"></script>
|
||||||
|
|
||||||
|
<!-- General testing framework -->
|
||||||
|
<script src="./test-array.js"></script>
|
||||||
|
|
||||||
|
<script>/*<![CDATA[*/
|
||||||
|
"use strict";
|
||||||
|
|
||||||
|
// Generating 2048-bit keys takes some time.
|
||||||
|
SimpleTest.requestLongerTimeout(2);
|
||||||
|
|
||||||
|
// -----------------------------------------------------------------------------
|
||||||
|
TestArray.addTest(
|
||||||
|
"RSA-PSS key generation (SHA-1, 1024-bit)",
|
||||||
|
function () {
|
||||||
|
var that = this;
|
||||||
|
var alg = {
|
||||||
|
name: "RSA-PSS",
|
||||||
|
hash: "SHA-1",
|
||||||
|
modulusLength: 1024,
|
||||||
|
publicExponent: new Uint8Array([0x01, 0x00, 0x01])
|
||||||
|
};
|
||||||
|
|
||||||
|
crypto.subtle.generateKey(alg, false, ["sign", "verify"])
|
||||||
|
.then(complete(that), error(that));
|
||||||
|
}
|
||||||
|
);
|
||||||
|
/*]]>*/</script>
|
||||||
|
</head>
|
||||||
|
|
||||||
|
<body>
|
||||||
|
|
||||||
|
<div id="content">
|
||||||
|
<div id="head">
|
||||||
|
<b>Web</b>Crypto<br>
|
||||||
|
</div>
|
||||||
|
|
||||||
|
<div id="start" onclick="start();">RUN ALL</div>
|
||||||
|
|
||||||
|
<div id="resultDiv" class="content">
|
||||||
|
Summary:
|
||||||
|
<span class="pass"><span id="passN">0</span> passed, </span>
|
||||||
|
<span class="fail"><span id="failN">0</span> failed, </span>
|
||||||
|
<span class="pending"><span id="pendingN">0</span> pending.</span>
|
||||||
|
<br/>
|
||||||
|
<br/>
|
||||||
|
|
||||||
|
<table id="results">
|
||||||
|
<tr>
|
||||||
|
<th>Test</th>
|
||||||
|
<th>Result</th>
|
||||||
|
<th>Time</th>
|
||||||
|
</tr>
|
||||||
|
</table>
|
||||||
|
|
||||||
|
</div>
|
||||||
|
|
||||||
|
<div id="foot"></div>
|
||||||
|
</div>
|
||||||
|
|
||||||
|
</body>
|
||||||
|
</html>
|
Loading…
Reference in New Issue
Block a user