@breakside/jskit 2024.34.0 → 2024.41.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/Frameworks/DOM.jsframework/Info.json +2 -2
- package/Frameworks/DOM.jsframework/io.breakside.JSKit.DOM-bundle.js +2 -2
- package/Frameworks/FontKit.jsframework/Info.json +2 -2
- package/Frameworks/FontKit.jsframework/io.breakside.JSKit.FontKit-bundle.js +2 -2
- package/Frameworks/Foundation.jsframework/Info.json +2 -2
- package/Frameworks/Foundation.jsframework/JS/Foundation+HTML.js +3 -1
- package/Frameworks/Foundation.jsframework/JS/JSClass.js +4 -1
- package/Frameworks/Foundation.jsframework/JS/JSHTMLUserAgent.js +130 -0
- package/Frameworks/Foundation.jsframework/JS/JSNodeURLSessionStreamTask.js +1 -1
- package/Frameworks/Foundation.jsframework/io.breakside.JSKit.Foundation-bundle.js +2 -2
- package/Frameworks/Foundation.jsframework/sources.json +3 -1
- package/Frameworks/SecurityKit.jsframework/Info.json +2 -2
- package/Frameworks/SecurityKit.jsframework/JS/SECCBOR.js +4 -0
- package/Frameworks/SecurityKit.jsframework/JS/SECCOSE.js +135 -0
- package/Frameworks/SecurityKit.jsframework/JS/SECCipher+HTML.js +231 -70
- package/Frameworks/SecurityKit.jsframework/JS/SECCipher+Node.js +155 -60
- package/Frameworks/SecurityKit.jsframework/JS/SECCipher.js +125 -54
- package/Frameworks/SecurityKit.jsframework/JS/SECDataKey.js +5 -4
- package/Frameworks/SecurityKit.jsframework/JS/SECHMAC+HTML.js +15 -11
- package/Frameworks/SecurityKit.jsframework/JS/SECHMAC+Node.js +17 -3
- package/Frameworks/SecurityKit.jsframework/JS/SECHTMLDeviceAuthentication.js +206 -120
- package/Frameworks/SecurityKit.jsframework/JS/SECHTMLKey.js +17 -0
- package/Frameworks/SecurityKit.jsframework/JS/SECHash.js +1 -0
- package/Frameworks/SecurityKit.jsframework/JS/SECJSONWebAlgorithms.js +9 -1
- package/Frameworks/SecurityKit.jsframework/JS/SECJSONWebEncryption.js +391 -0
- package/Frameworks/SecurityKit.jsframework/JS/SECJSONWebToken.js +1 -1
- package/Frameworks/SecurityKit.jsframework/JS/SECKey.js +14 -1
- package/Frameworks/SecurityKit.jsframework/JS/SECNodeKey.js +66 -1
- package/Frameworks/SecurityKit.jsframework/JS/SECSign+HTML.js +2 -27
- package/Frameworks/SecurityKit.jsframework/JS/SECSign+Node.js +103 -278
- package/Frameworks/SecurityKit.jsframework/JS/SECSign.js +27 -0
- package/Frameworks/SecurityKit.jsframework/JS/SECVerify+Node.js +60 -57
- package/Frameworks/SecurityKit.jsframework/JS/SecurityKit.js +1 -0
- package/Frameworks/SecurityKit.jsframework/io.breakside.JSKit.SecurityKit-bundle.js +2 -2
- package/Frameworks/SecurityKit.jsframework/sources.json +6 -0
- package/Info.json +2 -2
- package/Node/KeyCommand.js +8 -1
- package/Node/io.breakside.jskit-bundle.js +2 -2
- package/Node/jskit +1 -0
- package/Root/Frameworks/APIKit/Info.yaml +1 -1
- package/Root/Frameworks/APIKitTesting/Info.yaml +1 -1
- package/Root/Frameworks/AuthKit/Info.yaml +1 -1
- package/Root/Frameworks/CSSOM/Info.yaml +1 -1
- package/Root/Frameworks/ChartKit/Info.yaml +1 -1
- package/Root/Frameworks/ConferenceKit/Info.yaml +1 -1
- package/Root/Frameworks/DBKit/DBEncryptedObject.js +2 -2
- package/Root/Frameworks/DBKit/Info.yaml +1 -1
- package/Root/Frameworks/DOM/Info.yaml +1 -1
- package/Root/Frameworks/Dispatch/Info.yaml +1 -1
- package/Root/Frameworks/FontKit/Info.yaml +1 -1
- package/Root/Frameworks/Foundation/Foundation+HTML.js +3 -1
- package/Root/Frameworks/Foundation/Info.yaml +1 -1
- package/Root/Frameworks/Foundation/JSClass.js +4 -1
- package/Root/Frameworks/Foundation/JSHTMLUserAgent.js +130 -0
- package/Root/Frameworks/Foundation/JSNodeURLSessionStreamTask.js +1 -1
- package/Root/Frameworks/ImageKit/Info.yaml +1 -1
- package/Root/Frameworks/MediaKit/Info.yaml +1 -1
- package/Root/Frameworks/MediaKitUI/Info.yaml +1 -1
- package/Root/Frameworks/NotificationKit/Info.yaml +1 -1
- package/Root/Frameworks/NotificationKit/NKWebPushService.js +2 -2
- package/Root/Frameworks/PDFKit/Info.yaml +1 -1
- package/Root/Frameworks/PDFKit/PDFEncryption.js +1 -1
- package/Root/Frameworks/QRKit/Info.yaml +1 -1
- package/Root/Frameworks/SearchKit/Info.yaml +1 -1
- package/Root/Frameworks/SecurityKit/Info.yaml +1 -1
- package/Root/Frameworks/SecurityKit/SECCBOR.js +4 -0
- package/Root/Frameworks/SecurityKit/SECCOSE.js +135 -0
- package/Root/Frameworks/SecurityKit/SECCipher+HTML.js +231 -70
- package/Root/Frameworks/SecurityKit/SECCipher+Node.js +155 -60
- package/Root/Frameworks/SecurityKit/SECCipher.js +125 -54
- package/Root/Frameworks/SecurityKit/SECDataKey.js +5 -4
- package/Root/Frameworks/SecurityKit/SECHMAC+HTML.js +15 -11
- package/Root/Frameworks/SecurityKit/SECHMAC+Node.js +17 -3
- package/Root/Frameworks/SecurityKit/SECHTMLDeviceAuthentication.js +206 -120
- package/Root/Frameworks/SecurityKit/SECHTMLKey.js +17 -0
- package/Root/Frameworks/SecurityKit/SECHash.js +1 -0
- package/Root/Frameworks/SecurityKit/SECJSONWebAlgorithms.js +9 -1
- package/Root/Frameworks/SecurityKit/SECJSONWebEncryption.js +391 -0
- package/Root/Frameworks/SecurityKit/SECJSONWebToken.js +1 -1
- package/Root/Frameworks/SecurityKit/SECKey.js +14 -1
- package/Root/Frameworks/SecurityKit/SECNodeKey.js +66 -1
- package/Root/Frameworks/SecurityKit/SECSign+HTML.js +2 -27
- package/Root/Frameworks/SecurityKit/SECSign+Node.js +103 -278
- package/Root/Frameworks/SecurityKit/SECSign.js +27 -0
- package/Root/Frameworks/SecurityKit/SECVerify+Node.js +60 -57
- package/Root/Frameworks/SecurityKit/SecurityKit.js +1 -0
- package/Root/Frameworks/ServerKit/Info.yaml +1 -1
- package/Root/Frameworks/ServerKitTesting/Info.yaml +1 -1
- package/Root/Frameworks/TestKit/Info.yaml +1 -1
- package/Root/Frameworks/UIKit/Info.yaml +1 -1
- package/Root/Frameworks/UIKit/UIPlatform+HTML.js +2 -1
- package/Root/Frameworks/UIKitTesting/Info.yaml +1 -1
- package/package.json +1 -1
- package/Root/Templates/workspace/.gitignore +0 -4
package/Info.json
CHANGED
|
@@ -1,12 +1,12 @@
|
|
|
1
1
|
{
|
|
2
2
|
"JSBundleType": "node",
|
|
3
3
|
"JSBundleIdentifier": "io.breakside.jskit",
|
|
4
|
-
"JSBundleVersion": "2024.
|
|
4
|
+
"JSBundleVersion": "2024.41.0",
|
|
5
5
|
"JSExecutableName": "jskit",
|
|
6
6
|
"NPMOrganization": "breakside",
|
|
7
7
|
"JSResources": [
|
|
8
8
|
"Tests/HTMLTestRunner.js",
|
|
9
9
|
"Tests/NodeTestRunner.js"
|
|
10
10
|
],
|
|
11
|
-
"GitRevision": "
|
|
11
|
+
"GitRevision": "bf643e90b060044223efa5a59f0d727332802563"
|
|
12
12
|
}
|
package/Node/KeyCommand.js
CHANGED
|
@@ -30,7 +30,14 @@ JSClass("KeyCommand", Command, {
|
|
|
30
30
|
|
|
31
31
|
run: async function(){
|
|
32
32
|
var workspaceURL = this.workingDirectoryURL;
|
|
33
|
-
var
|
|
33
|
+
var hmacAlgorithm = {
|
|
34
|
+
256: SECHMAC.Algorithm.sha256,
|
|
35
|
+
384: SECHMAC.Algorithm.sha384,
|
|
36
|
+
512: SECHMAC.Algorithm.sha512
|
|
37
|
+
}[this.arguments.bits];
|
|
38
|
+
var hmac = SECHMAC.initWithAlgorithm(hmacAlgorithm);
|
|
39
|
+
var key = await hmac.createKey();
|
|
40
|
+
var data = key.getData();
|
|
34
41
|
var printer = Printer.initWithLabel('key');
|
|
35
42
|
if (this.arguments.format === "jwk"){
|
|
36
43
|
var jwk = {
|
|
@@ -3,14 +3,14 @@ JSBundle.bundles['io.breakside.jskit'] = {
|
|
|
3
3
|
"Info": {
|
|
4
4
|
"JSBundleType": "node",
|
|
5
5
|
"JSBundleIdentifier": "io.breakside.jskit",
|
|
6
|
-
"JSBundleVersion": "2024.
|
|
6
|
+
"JSBundleVersion": "2024.41.0",
|
|
7
7
|
"JSExecutableName": "jskit",
|
|
8
8
|
"NPMOrganization": "breakside",
|
|
9
9
|
"JSResources": [
|
|
10
10
|
"Tests/HTMLTestRunner.js",
|
|
11
11
|
"Tests/NodeTestRunner.js"
|
|
12
12
|
],
|
|
13
|
-
"GitRevision": "
|
|
13
|
+
"GitRevision": "bf643e90b060044223efa5a59f0d727332802563"
|
|
14
14
|
},
|
|
15
15
|
"Resources": [
|
|
16
16
|
{
|
package/Node/jskit
CHANGED
|
@@ -156,6 +156,7 @@ require("./../Frameworks/SecurityKit.jsframework/JS/SECKeychain.js");
|
|
|
156
156
|
require("./../Frameworks/SecurityKit.jsframework/JS/SECHMAC.js");
|
|
157
157
|
require("./../Frameworks/SecurityKit.jsframework/JS/SECSign.js");
|
|
158
158
|
require("./../Frameworks/SecurityKit.jsframework/JS/SECJSONWebToken.js");
|
|
159
|
+
require("./../Frameworks/SecurityKit.jsframework/JS/SECJSONWebEncryption.js");
|
|
159
160
|
require("./../Frameworks/SecurityKit.jsframework/JS/SECPassword.js");
|
|
160
161
|
require("./../Frameworks/SecurityKit.jsframework/JS/SECASN1.js");
|
|
161
162
|
require("./../Frameworks/SecurityKit.jsframework/JS/SECASN1Parser.js");
|
|
@@ -65,7 +65,7 @@ JSClass("DBEncryptedObject", JSObject, {
|
|
|
65
65
|
if (!completion){
|
|
66
66
|
completion = Promise.completion(Promise.resolveTrue);
|
|
67
67
|
}
|
|
68
|
-
var cipher = SECCipher.initWithAlgorithm(algorithm, keyBitLength);
|
|
68
|
+
var cipher = SECCipher.initWithAlgorithm(algorithm, {keyBitLength: keyBitLength});
|
|
69
69
|
var key = cipher.createKeyFromKeystore(this.keystore, keyIdentifier, function(key){
|
|
70
70
|
if (key === null){
|
|
71
71
|
completion.call(target, false);
|
|
@@ -101,7 +101,7 @@ JSClass("DBEncryptedObject", JSObject, {
|
|
|
101
101
|
completion = Promise.completion(Promise.resolveNonNull);
|
|
102
102
|
}
|
|
103
103
|
if (this.object === null && this.encrypted !== null && this.keystore !== null){
|
|
104
|
-
var cipher = SECCipher.initWithAlgorithm(this.algorithm, this.keyBitLength);
|
|
104
|
+
var cipher = SECCipher.initWithAlgorithm(this.algorithm, {keyBitLength: this.keyBitLength});
|
|
105
105
|
cipher.createKeyFromKeystore(this.keystore, this.keyIdentifier, function(key){
|
|
106
106
|
if (key === null){
|
|
107
107
|
completion.call(target, null);
|
|
@@ -177,7 +177,10 @@ JSClass.prototype = {
|
|
|
177
177
|
}
|
|
178
178
|
if (result instanceof Promise){
|
|
179
179
|
return result.then(function(promiseResult){
|
|
180
|
-
|
|
180
|
+
if (promiseResult === undefined){
|
|
181
|
+
return obj;
|
|
182
|
+
}
|
|
183
|
+
return promiseResult;
|
|
181
184
|
});
|
|
182
185
|
}
|
|
183
186
|
return result;
|
|
@@ -0,0 +1,130 @@
|
|
|
1
|
+
// Copyright 2021 Breakside Inc.
|
|
2
|
+
//
|
|
3
|
+
// Licensed under the Breakside Public License, Version 1.0 (the "License");
|
|
4
|
+
// you may not use this file except in compliance with the License.
|
|
5
|
+
// If a copy of the License was not distributed with this file, you may
|
|
6
|
+
// obtain a copy at
|
|
7
|
+
//
|
|
8
|
+
// http://breakside.io/licenses/LICENSE-1.0.txt
|
|
9
|
+
//
|
|
10
|
+
// Unless required by applicable law or agreed to in writing, software
|
|
11
|
+
// distributed under the License is distributed on an "AS IS" BASIS,
|
|
12
|
+
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
13
|
+
// See the License for the specific language governing permissions and
|
|
14
|
+
// limitations under the License.
|
|
15
|
+
|
|
16
|
+
// #import "JSObject.js"
|
|
17
|
+
"use strict";
|
|
18
|
+
|
|
19
|
+
JSClass("JSHTMLUserAgent", JSObject, {
|
|
20
|
+
|
|
21
|
+
string: null,
|
|
22
|
+
products: null,
|
|
23
|
+
productsByIdentifier: null,
|
|
24
|
+
comments: null,
|
|
25
|
+
commentSet: null,
|
|
26
|
+
|
|
27
|
+
initWithString: function(string){
|
|
28
|
+
if (string === null || string === undefined){
|
|
29
|
+
return null;
|
|
30
|
+
}
|
|
31
|
+
this.string = string;
|
|
32
|
+
this.products = [];
|
|
33
|
+
this.productsByIdentifier = new Set();
|
|
34
|
+
this.comments = [];
|
|
35
|
+
this.commentSet = new Set();
|
|
36
|
+
this.parse();
|
|
37
|
+
},
|
|
38
|
+
|
|
39
|
+
parse: function(){
|
|
40
|
+
var str = this.string;
|
|
41
|
+
var i = 0;
|
|
42
|
+
var l = this.string.length;
|
|
43
|
+
var product = "";
|
|
44
|
+
var version = "";
|
|
45
|
+
var comment = "";
|
|
46
|
+
while (i < l){
|
|
47
|
+
while (str[i] == " " || str[i] == "\t"){
|
|
48
|
+
++i;
|
|
49
|
+
}
|
|
50
|
+
if (i < l){
|
|
51
|
+
if (str[i] == "("){
|
|
52
|
+
comment = "";
|
|
53
|
+
++i;
|
|
54
|
+
while (i < l && str[i] !== ")"){
|
|
55
|
+
if (str[i] == ";"){
|
|
56
|
+
comment = comment.trim();
|
|
57
|
+
if (comment !== ""){
|
|
58
|
+
this.addComment(comment);
|
|
59
|
+
}
|
|
60
|
+
comment = "";
|
|
61
|
+
}else{
|
|
62
|
+
comment += str[i];
|
|
63
|
+
}
|
|
64
|
+
++i;
|
|
65
|
+
}
|
|
66
|
+
comment = comment.trim();
|
|
67
|
+
if (comment !== ""){
|
|
68
|
+
this.addComment(comment);
|
|
69
|
+
}
|
|
70
|
+
if (i < l){
|
|
71
|
+
++i;
|
|
72
|
+
}
|
|
73
|
+
}else{
|
|
74
|
+
product = "";
|
|
75
|
+
version = "";
|
|
76
|
+
while (i < l && str[i] !== "/" && str[i] !== " " && str[i] !== "\t"){
|
|
77
|
+
product += str[i];
|
|
78
|
+
++i;
|
|
79
|
+
}
|
|
80
|
+
if (i < l && str[i] == "/"){
|
|
81
|
+
++i;
|
|
82
|
+
while (i < l && str[i] !== "(" && str[i] !== " " && str[i] !== "\t"){
|
|
83
|
+
version += str[i];
|
|
84
|
+
++i;
|
|
85
|
+
}
|
|
86
|
+
}
|
|
87
|
+
this.addProduct(product, version);
|
|
88
|
+
}
|
|
89
|
+
}
|
|
90
|
+
}
|
|
91
|
+
},
|
|
92
|
+
|
|
93
|
+
addProduct: function(name, version){
|
|
94
|
+
if (version === "" || version === undefined){
|
|
95
|
+
version = null;
|
|
96
|
+
}
|
|
97
|
+
var product = {name: name, version: version};
|
|
98
|
+
this.products.push(product);
|
|
99
|
+
this.productsByIdentifier[name] = product;
|
|
100
|
+
if (version !== null){
|
|
101
|
+
this.productsByIdentifier["%s/%s".sprintf(name, version)] = product;
|
|
102
|
+
}
|
|
103
|
+
},
|
|
104
|
+
|
|
105
|
+
addComment: function(comment){
|
|
106
|
+
this.comments.push(comment);
|
|
107
|
+
this.commentSet.add(comment);
|
|
108
|
+
},
|
|
109
|
+
|
|
110
|
+
containsProduct: function(name, version){
|
|
111
|
+
if (version === undefined || version === null || version === ""){
|
|
112
|
+
return name in this.productsByIdentifier;
|
|
113
|
+
}
|
|
114
|
+
return "%s/%s".sprintf(name, version) in this.productsByIdentifier;
|
|
115
|
+
},
|
|
116
|
+
|
|
117
|
+
versionOfProduct: function(name){
|
|
118
|
+
var product = this.productsByIdentifier[name];
|
|
119
|
+
if (product){
|
|
120
|
+
return product.version;
|
|
121
|
+
}
|
|
122
|
+
return null;
|
|
123
|
+
},
|
|
124
|
+
|
|
125
|
+
containsComment: function(comment){
|
|
126
|
+
return this.commentSet.has(comment);
|
|
127
|
+
}
|
|
128
|
+
|
|
129
|
+
});
|
|
130
|
+
|
|
@@ -92,7 +92,7 @@ JSClass("JSNodeURLSessionStreamTask", JSURLSessionStreamTask, {
|
|
|
92
92
|
},
|
|
93
93
|
|
|
94
94
|
write: function(data){
|
|
95
|
-
this.socket.write(data.nodeBuffer);
|
|
95
|
+
this.socket.write(data.nodeBuffer());
|
|
96
96
|
},
|
|
97
97
|
|
|
98
98
|
// ----------------------------------------------------------------------
|
|
@@ -162,12 +162,12 @@ JSClass("NKWebPushService", JSObject, {
|
|
|
162
162
|
}).then(function(keyAndNonce){
|
|
163
163
|
var keyData = keyAndNonce[0].subdataInRange(JSRange(0, 16));
|
|
164
164
|
var nonceData = keyAndNonce[1].subdataInRange(JSRange(0, 12));
|
|
165
|
-
var cipher = SECCipher.initWithAlgorithm(SECCipher.Algorithm.aesGCM, 128);
|
|
165
|
+
var cipher = SECCipher.initWithAlgorithm(SECCipher.Algorithm.aesGCM, {keyBitLength: 128, iv: nonceData});
|
|
166
166
|
return cipher.createKeyWithData(keyData).then(function(key){
|
|
167
167
|
if (key === null){
|
|
168
168
|
return;
|
|
169
169
|
}
|
|
170
|
-
return cipher.
|
|
170
|
+
return cipher.encrypt(JSData.initWithChunks([plaintext, JSData.initWithArray([0x02])]), key);
|
|
171
171
|
});
|
|
172
172
|
}).then(function(encrypted){
|
|
173
173
|
var ciphertext = encrypted.subdataInRange(JSRange(12, encrypted.length - 12));
|
|
@@ -226,7 +226,7 @@ JSClass("PDFEncryption", JSObject, {
|
|
|
226
226
|
}
|
|
227
227
|
|
|
228
228
|
var keyData = this._generateObjectKeyData(stream.indirect.objectID, stream.indirect.generation, cipherAlgorithm);
|
|
229
|
-
var cipher = SECCipher.initWithAlgorithm(cipherAlgorithm);
|
|
229
|
+
var cipher = SECCipher.initWithAlgorithm(cipherAlgorithm, {keyBitLength: 128});
|
|
230
230
|
cipher.createKeyWithData(keyData, function(key){
|
|
231
231
|
if (key === null){
|
|
232
232
|
completion.call(target, null);
|
|
@@ -44,6 +44,9 @@ JSClass("SECCBORParser", JSObject, {
|
|
|
44
44
|
},
|
|
45
45
|
|
|
46
46
|
readNext: function(){
|
|
47
|
+
if (this.offset >= this.data.length){
|
|
48
|
+
return null;
|
|
49
|
+
}
|
|
47
50
|
var b = this.data[this.offset++];
|
|
48
51
|
var info = b & 0x1F;
|
|
49
52
|
var majorType = (b & 0xE0) >> 5;
|
|
@@ -65,6 +68,7 @@ JSClass("SECCBORParser", JSObject, {
|
|
|
65
68
|
case SECCBOR.MajorType.other:
|
|
66
69
|
return this.readOther(info);
|
|
67
70
|
}
|
|
71
|
+
return null;
|
|
68
72
|
},
|
|
69
73
|
|
|
70
74
|
readUnsignedInteger: function(info){
|
|
@@ -0,0 +1,135 @@
|
|
|
1
|
+
// #import Foundation
|
|
2
|
+
// #import "SECCBOR.js"
|
|
3
|
+
// #import "SECJSONWebAlgorithms.js"
|
|
4
|
+
"use strict";
|
|
5
|
+
|
|
6
|
+
(function(){
|
|
7
|
+
|
|
8
|
+
JSClass("SECCOSE", JSObject, {
|
|
9
|
+
|
|
10
|
+
dictionary: null,
|
|
11
|
+
|
|
12
|
+
initWithData: function(data){
|
|
13
|
+
var parser = SECCBORParser.initWithData(data);
|
|
14
|
+
this.dictionary = parser.readNext();
|
|
15
|
+
},
|
|
16
|
+
|
|
17
|
+
attribute: function(attr){
|
|
18
|
+
return this.dictionary[attr] || null;
|
|
19
|
+
},
|
|
20
|
+
|
|
21
|
+
derRepresentation: function(){
|
|
22
|
+
return JSData.init();
|
|
23
|
+
},
|
|
24
|
+
|
|
25
|
+
jwkRepresentation: function(){
|
|
26
|
+
var jwk = {};
|
|
27
|
+
switch (this.attribute(SECCOSE.Attribute.kty)){
|
|
28
|
+
case SECCOSE.KeyType.ellipticCurve:
|
|
29
|
+
jwk.kty = SECJSONWebAlgorithms.KeyType.ellipticCurve;
|
|
30
|
+
switch (this.attribute(SECCOSE.Attribute.alg)){
|
|
31
|
+
case SECCOSE.Algorithm.ellipticCurveSHA256:
|
|
32
|
+
jwk.alg = SECJSONWebAlgorithms.Algorithm.ellipticCurveSHA256;
|
|
33
|
+
break;
|
|
34
|
+
case SECCOSE.Algorithm.ellipticCurveSHA384:
|
|
35
|
+
jwk.alg = SECJSONWebAlgorithms.Algorithm.ellipticCurveSHA384;
|
|
36
|
+
break;
|
|
37
|
+
case SECCOSE.Algorithm.ellipticCurveSHA512:
|
|
38
|
+
jwk.alg = SECJSONWebAlgorithms.Algorithm.ellipticCurveSHA512;
|
|
39
|
+
break;
|
|
40
|
+
default:
|
|
41
|
+
return null;
|
|
42
|
+
}
|
|
43
|
+
switch (this.attribute(SECCOSE.Attribute.ellipticCurve_crv)){
|
|
44
|
+
case SECCOSE.EllipticCurve.p256:
|
|
45
|
+
jwk.crv = SECJSONWebAlgorithms.EllipticCurve.p256;
|
|
46
|
+
break;
|
|
47
|
+
case SECCOSE.EllipticCurve.p384:
|
|
48
|
+
jwk.crv = SECJSONWebAlgorithms.EllipticCurve.p384;
|
|
49
|
+
break;
|
|
50
|
+
case SECCOSE.EllipticCurve.p521:
|
|
51
|
+
jwk.crv = SECJSONWebAlgorithms.EllipticCurve.p521;
|
|
52
|
+
break;
|
|
53
|
+
default:
|
|
54
|
+
return null;
|
|
55
|
+
}
|
|
56
|
+
jwk.x = this.attribute(SECCOSE.Attribute.ellipticCurve_x).base64URLStringRepresentation();
|
|
57
|
+
jwk.y = this.attribute(SECCOSE.Attribute.ellipticCurve_y).base64URLStringRepresentation();
|
|
58
|
+
break;
|
|
59
|
+
case SECCOSE.KeyType.rsa:
|
|
60
|
+
jwk.kty = SECJSONWebAlgorithms.KeyType.rsa;
|
|
61
|
+
switch (this.attribute(SECCOSE.Attribute.alg)){
|
|
62
|
+
case SECCOSE.Algorithm.rsaSHA256:
|
|
63
|
+
jwk.alg = SECJSONWebAlgorithms.Algorithm.rsaSHA256;
|
|
64
|
+
break;
|
|
65
|
+
case SECCOSE.Algorithm.rsaSHA384:
|
|
66
|
+
jwk.alg = SECJSONWebAlgorithms.Algorithm.rsaSHA384;
|
|
67
|
+
break;
|
|
68
|
+
case SECCOSE.Algorithm.rsaSHA512:
|
|
69
|
+
jwk.alg = SECJSONWebAlgorithms.Algorithm.rsaSHA512;
|
|
70
|
+
break;
|
|
71
|
+
default:
|
|
72
|
+
return null;
|
|
73
|
+
}
|
|
74
|
+
jwk.n = this.attribute(SECCOSE.Attribute.rsa_n).base64URLStringRepresentation();
|
|
75
|
+
jwk.e = this.attribute(SECCOSE.Attribute.rsa_e).base64URLStringRepresentation();
|
|
76
|
+
break;
|
|
77
|
+
default:
|
|
78
|
+
return null;
|
|
79
|
+
}
|
|
80
|
+
return jwk;
|
|
81
|
+
}
|
|
82
|
+
|
|
83
|
+
});
|
|
84
|
+
|
|
85
|
+
SECCOSE.KeyType = {
|
|
86
|
+
ellipticCurve: 2,
|
|
87
|
+
rsa: 3,
|
|
88
|
+
symmetric: 4,
|
|
89
|
+
};
|
|
90
|
+
|
|
91
|
+
SECCOSE.Algorithm = {
|
|
92
|
+
rsaSHA256: -257,
|
|
93
|
+
rsaSHA384: -258,
|
|
94
|
+
rsaSHA512: -259,
|
|
95
|
+
ellipticCurveSHA256: -7,
|
|
96
|
+
ellipticCurveSHA384: -35,
|
|
97
|
+
ellipticCurveSHA512: -36,
|
|
98
|
+
};
|
|
99
|
+
|
|
100
|
+
SECCOSE.EllipticCurve = {
|
|
101
|
+
p256: 1,
|
|
102
|
+
p384: 2,
|
|
103
|
+
p521: 3
|
|
104
|
+
};
|
|
105
|
+
|
|
106
|
+
SECCOSE.Attribute = {
|
|
107
|
+
kty: 1,
|
|
108
|
+
kid: 2,
|
|
109
|
+
alg: 3,
|
|
110
|
+
key_ops: 4,
|
|
111
|
+
|
|
112
|
+
ellipticCurve_crv: -1,
|
|
113
|
+
ellipticCurve_x: -2,
|
|
114
|
+
ellipticCurve_y: -3,
|
|
115
|
+
ellipticCurve_d: -4,
|
|
116
|
+
|
|
117
|
+
rsa_n: -1,
|
|
118
|
+
rsa_e: -2,
|
|
119
|
+
rsa_d: -3,
|
|
120
|
+
rsa_p: -4,
|
|
121
|
+
rsa_q: -5,
|
|
122
|
+
rsa_dP: -6,
|
|
123
|
+
rsa_dQ: -7,
|
|
124
|
+
rsa_qInv: -8,
|
|
125
|
+
rsa_other: -9,
|
|
126
|
+
rsa_r_i: -10,
|
|
127
|
+
rsa_d_i: -11,
|
|
128
|
+
rsa_t_i: -12,
|
|
129
|
+
|
|
130
|
+
symmetric_k: -1
|
|
131
|
+
|
|
132
|
+
};
|
|
133
|
+
|
|
134
|
+
|
|
135
|
+
})();
|