Fix serializing GNU stripped-keys
This commit is contained in:
parent
735d6d088f
commit
c8729a0295
|
@ -224,7 +224,7 @@ SecretKey.prototype.write = function () {
|
||||||
// - [Optional] If secret data is encrypted (string-to-key usage octet
|
// - [Optional] If secret data is encrypted (string-to-key usage octet
|
||||||
// not zero), an Initial Vector (IV) of the same length as the
|
// not zero), an Initial Vector (IV) of the same length as the
|
||||||
// cipher's block size.
|
// cipher's block size.
|
||||||
if (this.s2k_usage) {
|
if (this.s2k_usage && this.s2k.type !== 'gnu-dummy') {
|
||||||
optionalFieldsArr.push(...this.iv);
|
optionalFieldsArr.push(...this.iv);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -385,6 +385,11 @@ SecretKey.prototype.generate = async function (bits, curve) {
|
||||||
* Clear private params, return to initial state
|
* Clear private params, return to initial state
|
||||||
*/
|
*/
|
||||||
SecretKey.prototype.clearPrivateParams = function () {
|
SecretKey.prototype.clearPrivateParams = function () {
|
||||||
|
if (this.s2k && this.s2k.type === 'gnu-dummy') {
|
||||||
|
this.isEncrypted = true;
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
if (!this.keyMaterial) {
|
if (!this.keyMaterial) {
|
||||||
throw new Error('If secret key is not encrypted, clearing private params is irreversible.');
|
throw new Error('If secret key is not encrypted, clearing private params is irreversible.');
|
||||||
}
|
}
|
||||||
|
|
|
@ -117,6 +117,10 @@ S2K.prototype.read = function (bytes) {
|
||||||
* @returns {Uint8Array} binary representation of s2k
|
* @returns {Uint8Array} binary representation of s2k
|
||||||
*/
|
*/
|
||||||
S2K.prototype.write = function () {
|
S2K.prototype.write = function () {
|
||||||
|
if (this.type === 'gnu-dummy') {
|
||||||
|
return new Uint8Array([101, 0, ...util.str_to_Uint8Array('GNU'), 1]);
|
||||||
|
}
|
||||||
|
|
||||||
const arr = [new Uint8Array([enums.write(enums.s2k, this.type), enums.write(enums.hash, this.algorithm)])];
|
const arr = [new Uint8Array([enums.write(enums.s2k, this.type), enums.write(enums.hash, this.algorithm)])];
|
||||||
|
|
||||||
switch (this.type) {
|
switch (this.type) {
|
||||||
|
|
Loading…
Reference in New Issue
Block a user