Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

remove A*GCMKW support #161

Merged
merged 4 commits into from
Jan 31, 2018
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 1 addition & 4 deletions lib/algorithms/aes-gcm.js
Original file line number Diff line number Diff line change
Expand Up @@ -326,10 +326,7 @@ var aesGcm = {};
[
"A128GCM",
"A192GCM",
"A256GCM",
"A128GCMKW",
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'd rather keep these in here, and rely on their removal from the supported algorithms list in jwk/octkey.js

"A192GCMKW",
"A256GCMKW"
"A256GCM"
].forEach(function(alg) {
var size = parseInt(/A(\d+)GCM(?:KW)?/g.exec(alg)[1]);
aesGcm[alg] = {
Expand Down
4 changes: 0 additions & 4 deletions lib/jwk/octkey.js
Original file line number Diff line number Diff line change
Expand Up @@ -32,9 +32,6 @@ var WRAP_ALGS = [
"A128KW",
"A192KW",
"A256KW",
"A128GCMKW",
"A192GCMKW",
"A256GCMKW",
"PBES2-HS256+A128KW",
"PBES2-HS384+A192KW",
"PBES2-HS512+A256KW",
Expand Down Expand Up @@ -147,7 +144,6 @@ var JWKOctetCfg = {
case "unwrap":
return WRAP_ALGS.filter(function(a) {
return (a === ("A" + len + "KW")) ||
(a === ("A" + len + "GCMKW")) ||
(a.indexOf("PBES2-") === 0) ||
(a === "dir");
});
Expand Down
1 change: 0 additions & 1 deletion test/jwe/jwe-test.js
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,6 @@ var fixtures = {
"5_4.key_agreement_with_key_wrapping_using_ecdh-es_and_aes-keywrap_with_aes-gcm": cloneDeep(require("jose-cookbook/jwe/5_4.key_agreement_with_key_wrapping_using_ecdh-es_and_aes-keywrap_with_aes-gcm.json")),
"5_5.key_agreement_using_ecdh-es_with_aes-cbc-hmac-sha2": cloneDeep(require("jose-cookbook/jwe/5_5.key_agreement_using_ecdh-es_with_aes-cbc-hmac-sha2.json")),
"5_6.direct_encryption_using_aes-gcm": cloneDeep(require("jose-cookbook/jwe/5_6.direct_encryption_using_aes-gcm.json")),
"5_7.key_wrap_using_aes-gcm_keywrap_with_aes-cbc-hmac-sha2": cloneDeep(require("jose-cookbook/jwe/5_7.key_wrap_using_aes-gcm_keywrap_with_aes-cbc-hmac-sha2.json")),
"5_8.key_wrap_using_aes-keywrap_with_aes-gcm": cloneDeep(require("jose-cookbook/jwe/5_8.key_wrap_using_aes-keywrap_with_aes-gcm.json")),
"5_9.compressed_content": cloneDeep(require("jose-cookbook/jwe/5_9.compressed_content.json")),
"5_10.including_additional_authentication_data": cloneDeep(require("jose-cookbook/jwe/5_10.including_additional_authentication_data.json"))
Expand Down
48 changes: 24 additions & 24 deletions test/jwk/octkey-test.js
Original file line number Diff line number Diff line change
Expand Up @@ -270,35 +270,35 @@ describe("jwk/oct", function() {
public: {
"kid": "somekey",
"use": "enc",
"alg": "A128GCMKW"
"alg": "A128GCM"
},
private: {
"kid": "somekey",
"use": "enc",
"alg": "A128GCMKW",
"alg": "A128GCM",
"k": util.base64url.decode("Obdi7uR-5mc3Zbo0HtI-CQ"),
"length": 128
}
};

var result = JWK.OCTET.config.wrapKey("A128GCMKW", keys);
var result = JWK.OCTET.config.wrapKey("A128GCM", keys);
assert.equal(result, keys.private.k);
});
it("returns undefined for missing key value", function() {
var keys = {
public: {
"kid": "somekey",
"use": "enc",
"alg": "A128GCMKW"
"alg": "A128GCM"
},
private: {
"kid": "somekey",
"use": "enc",
"alg": "A128GCMKW"
"alg": "A128GCM"
}
};

var result = JWK.OCTET.config.wrapKey("A128GCMKW", keys);
var result = JWK.OCTET.config.wrapKey("A128GCM", keys);
assert.isUndefined(result);
});
});
Expand All @@ -311,7 +311,7 @@ describe("jwk/oct", function() {
iv: "f0uE_M5yFBbwGhHy",
stuff: "hello"
};
adjusted = JWK.OCTET.config.wrapProps("A128GCMKW", props);
adjusted = JWK.OCTET.config.wrapProps("A128GCM", props);
assert.ok(Buffer.isBuffer(adjusted.iv));
assert.equal(util.base64url.encode(adjusted.iv), "f0uE_M5yFBbwGhHy");
assert.equal(adjusted.stuff, "hello");
Expand All @@ -325,7 +325,7 @@ describe("jwk/oct", function() {
iv: util.base64url.decode("f0uE_M5yFBbwGhHy"),
stuff: "hello"
};
adjusted = JWK.OCTET.config.wrapProps("A128GCMKW", props);
adjusted = JWK.OCTET.config.wrapProps("A128GCM", props);
assert.ok(Buffer.isBuffer(adjusted.iv));
assert.equal(util.base64url.encode(adjusted.iv), "f0uE_M5yFBbwGhHy");
assert.equal(adjusted.stuff, "hello");
Expand All @@ -338,35 +338,35 @@ describe("jwk/oct", function() {
public: {
"kid": "somekey",
"use": "enc",
"alg": "A128GCMKW"
"alg": "A128GCM"
},
private: {
"kid": "somekey",
"use": "enc",
"alg": "A128GCMKW",
"alg": "A128GCM",
"k": util.base64url.decode("Obdi7uR-5mc3Zbo0HtI-CQ"),
"length": 128
}
};

var result = JWK.OCTET.config.unwrapKey("A128GCMKW", keys);
var result = JWK.OCTET.config.unwrapKey("A128GCM", keys);
assert.equal(result, keys.private.k);
});
it("returns undefined for missing key value", function() {
var keys = {
public: {
"kid": "somekey",
"use": "enc",
"alg": "A128GCMKW"
"alg": "A128GCM"
},
private: {
"kid": "somekey",
"use": "enc",
"alg": "A128GCMKW"
"alg": "A128GCM"
}
};

var result = JWK.OCTET.config.unwrapKey("A128GCMKW", keys);
var result = JWK.OCTET.config.unwrapKey("A128GCM", keys);
assert.isUndefined(result);
});
});
Expand All @@ -379,7 +379,7 @@ describe("jwk/oct", function() {
iv: "f0uE_M5yFBbwGhHy",
tag: "ZnNSux6e4oz6r85VHTE8jw"
};
adjusted = JWK.OCTET.config.unwrapProps("A128GCMKW", props);
adjusted = JWK.OCTET.config.unwrapProps("A128GCM", props);
assert.ok(Buffer.isBuffer(adjusted.iv));
assert.equal(util.base64url.encode(adjusted.iv), "f0uE_M5yFBbwGhHy");
assert.ok(Buffer.isBuffer(adjusted.tag));
Expand All @@ -393,7 +393,7 @@ describe("jwk/oct", function() {
iv: util.base64url.decode("f0uE_M5yFBbwGhHy"),
tag: util.base64url.decode("ZnNSux6e4oz6r85VHTE8jw")
};
adjusted = JWK.OCTET.config.unwrapProps("A128GCMKW", props);
adjusted = JWK.OCTET.config.unwrapProps("A128GCM", props);
assert.ok(Buffer.isBuffer(adjusted.iv));
assert.equal(util.base64url.encode(adjusted.iv), "f0uE_M5yFBbwGhHy");
assert.ok(Buffer.isBuffer(adjusted.tag));
Expand Down Expand Up @@ -506,9 +506,9 @@ describe("jwk/oct", function() {
assert.deepEqual(algs, ["A128GCM"]);

algs = JWK.OCTET.config.algorithms(keys, "wrap");
assert.deepEqual(algs, ["A128KW", "A128GCMKW", "PBES2-HS256+A128KW", "PBES2-HS384+A192KW", "PBES2-HS512+A256KW", "dir"]);
assert.deepEqual(algs, ["A128KW", "PBES2-HS256+A128KW", "PBES2-HS384+A192KW", "PBES2-HS512+A256KW", "dir"]);
algs = JWK.OCTET.config.algorithms(keys, "unwrap");
assert.deepEqual(algs, ["A128KW", "A128GCMKW", "PBES2-HS256+A128KW", "PBES2-HS384+A192KW", "PBES2-HS512+A256KW", "dir"]);
assert.deepEqual(algs, ["A128KW", "PBES2-HS256+A128KW", "PBES2-HS384+A192KW", "PBES2-HS512+A256KW", "dir"]);
});
it("returns the suite for 192-bit", function() {
var keys = generateKeys(192);
Expand All @@ -525,9 +525,9 @@ describe("jwk/oct", function() {
assert.deepEqual(algs, ["A192GCM"]);

algs = JWK.OCTET.config.algorithms(keys, "wrap");
assert.deepEqual(algs, ["A192KW", "A192GCMKW", "PBES2-HS256+A128KW", "PBES2-HS384+A192KW", "PBES2-HS512+A256KW", "dir"]);
assert.deepEqual(algs, ["A192KW", "PBES2-HS256+A128KW", "PBES2-HS384+A192KW", "PBES2-HS512+A256KW", "dir"]);
algs = JWK.OCTET.config.algorithms(keys, "unwrap");
assert.deepEqual(algs, ["A192KW", "A192GCMKW", "PBES2-HS256+A128KW", "PBES2-HS384+A192KW", "PBES2-HS512+A256KW", "dir"]);
assert.deepEqual(algs, ["A192KW", "PBES2-HS256+A128KW", "PBES2-HS384+A192KW", "PBES2-HS512+A256KW", "dir"]);
});
it("returns the suite for 256-bit", function() {
var keys = generateKeys(256);
Expand All @@ -544,9 +544,9 @@ describe("jwk/oct", function() {
assert.deepEqual(algs, ["A256GCM", "A128CBC-HS256", "A128CBC+HS256"]);

algs = JWK.OCTET.config.algorithms(keys, "wrap");
assert.deepEqual(algs, ["A256KW", "A256GCMKW", "PBES2-HS256+A128KW", "PBES2-HS384+A192KW", "PBES2-HS512+A256KW", "dir"]);
assert.deepEqual(algs, ["A256KW", "PBES2-HS256+A128KW", "PBES2-HS384+A192KW", "PBES2-HS512+A256KW", "dir"]);
algs = JWK.OCTET.config.algorithms(keys, "unwrap");
assert.deepEqual(algs, ["A256KW", "A256GCMKW", "PBES2-HS256+A128KW", "PBES2-HS384+A192KW", "PBES2-HS512+A256KW", "dir"]);
assert.deepEqual(algs, ["A256KW", "PBES2-HS256+A128KW", "PBES2-HS384+A192KW", "PBES2-HS512+A256KW", "dir"]);
});
it("returns the suite for 384-bit", function() {
var keys = generateKeys(384);
Expand Down Expand Up @@ -656,7 +656,7 @@ describe("jwk/oct", function() {
kty: "oct",
kid: "someid",
use: "enc",
alg: "A128GCMKW",
alg: "A128GCM",
k: util.base64url.encode("e98b72a9881a84ca6b76e0f43e68647a", "hex")
};
return keystore.add(jwk);
Expand Down Expand Up @@ -722,7 +722,7 @@ describe("jwk/oct", function() {
kid: "someid",
k: util.base64url.encode("e98b72a9881a84ca6b76e0f43e68647a", "hex"),
use: "enc",
alg: "A128GCMKW"
alg: "A128GCM"
});
return key.thumbprint();
});
Expand Down