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:
Brian Bloniarz
2013-02-06 08:36:56 -08:00
parent a2f343995a
commit 4a99ed0dfa
5 changed files with 108 additions and 27 deletions

View File

@@ -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);