mirror of
https://github.com/openpgpjs/openpgpjs.git
synced 2026-03-18 22:28:56 +00:00
Add support for GnuPG type 1001 s2k extension
This is a Gnu extension for private keys with stripped secrets, which can be created by GnuPG's --export-secret-subkeys mode. Before this patch, "ERROR: unknown s2k type! 101" would be logged as an error (though other than that, things seemed to function normally).
This commit is contained in:
@@ -66,6 +66,23 @@ function openpgp_type_s2k() {
|
||||
this.s2kLength = 10;
|
||||
break;
|
||||
|
||||
case 101:
|
||||
if(input.substring(mypos+1, mypos+4) == "GNU") {
|
||||
this.hashAlgorithm = input[mypos++].charCodeAt();
|
||||
mypos += 3; // GNU
|
||||
var gnuExtType = 1000 + input[mypos++].charCodeAt();
|
||||
if(gnuExtType == 1001) {
|
||||
this.type = gnuExtType;
|
||||
this.s2kLength = 5;
|
||||
// GnuPG extension mode 1001 -- don't write secret key at all
|
||||
} else {
|
||||
util.print_error("unknown s2k gnu protection mode! "+this.type);
|
||||
}
|
||||
} else {
|
||||
util.print_error("unknown s2k type! "+this.type);
|
||||
}
|
||||
break;
|
||||
|
||||
case 2: // Reserved value
|
||||
default:
|
||||
util.print_error("unknown s2k type! "+this.type);
|
||||
|
||||
Reference in New Issue
Block a user