Skip to content

Commit

Permalink
Fixed Subkey Identity Crash
Browse files Browse the repository at this point in the history
  • Loading branch information
racerxdl committed Jan 17, 2019
1 parent e384fdd commit e6a866a
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 17 deletions.
25 changes: 11 additions & 14 deletions RemoteSigner/KeyRingManager.cs
Original file line number Diff line number Diff line change
Expand Up @@ -39,13 +39,18 @@ public void AddKey(string publicKey, bool nonErasable = false) {


public void AddKey(PgpPublicKey publicKey, bool nonErasable = false) {
var fingerPrint = Tools.H16FP(publicKey.KeyId.ToString("X16"));
var fingerPrint = publicKey.KeyId.ToString("X16");
if (!publicKeys.ContainsKey(fingerPrint)) {
publicKeys[fingerPrint] = publicKey;
FP8TO16[Tools.H8FP(fingerPrint)] = fingerPrint;
var identities = publicKey.GetUserIds().Cast<string>();
var identity = "";
if (identities.Any()) {
identity = identities.First();
}
publicKeysInfo[fingerPrint] = new KeyInfo {
FingerPrint = fingerPrint,
Identifier = publicKey.GetUserIds().Cast<string>().First(),
Identifier = identity,
Bits = publicKey.BitStrength,
ContainsPrivateKey = false,
PrivateKeyDecrypted = false
Expand Down Expand Up @@ -78,24 +83,16 @@ public PgpPublicKey GetKey(string fingerPrint) {
return null;
}
AddKey(key);
using (var s = Tools.GenerateStreamFromString(key)) {
var pgpPub = new PgpPublicKeyRing(PgpUtilities.GetDecoderStream(s));
foreach (PgpPublicKey pubKey in pgpPub.GetPublicKeys()) {
return pubKey;
}
}
}

fingerPrint = fingerPrint.ToUpperInvariant();

return fingerPrint.Length == 8 ? publicKeys[FP8TO16[fingerPrint]] : publicKeys[fingerPrint];
}

public PgpPublicKey this[string key] {
get {
return GetKey(key);
}
set {
AddKey(value);
}
get => GetKey(key);
set => AddKey(value);
}
}
}
4 changes: 1 addition & 3 deletions RemoteSigner/PGPManager.cs
Original file line number Diff line number Diff line change
Expand Up @@ -329,9 +329,7 @@ public bool VerifySignature(byte[] data, string signature, PgpPublicKey publicKe

var sig = p3[0];
if (publicKey == null) {
string keyId = sig.KeyId.ToString("X16").ToUpper();
string fingerPrint =
keyId.Length < 16 ? Tools.H8FP(keyId) : Tools.H16FP(sig.KeyId.ToString("X16").ToUpper());
string fingerPrint = sig.KeyId.ToString("X16").ToUpper();
publicKey = krm[fingerPrint];
if (publicKey == null) {
throw new KeyNotLoadedException(fingerPrint);
Expand Down

0 comments on commit e6a866a

Please sign in to comment.