Skip to content

Commit 0dddafb

Browse files
committed
Fix Rot to use decrypted Keys before trying to decrypt other keys
1 parent 668cd47 commit 0dddafb

File tree

2 files changed

+18
-3
lines changed

2 files changed

+18
-3
lines changed

go/keys.go

+17-2
Original file line numberDiff line numberDiff line change
@@ -49,8 +49,6 @@ func (c *cfg) decryptPrivateKey(ctx context.Context) errs.Err {
4949
return errNotInitialized
5050
}
5151

52-
c.decryptKeysEncrypted(ctx)
53-
5452
var err error
5553

5654
var out []byte
@@ -69,6 +67,23 @@ func (c *cfg) decryptPrivateKey(ctx context.Context) errs.Err {
6967
}
7068
}
7169

70+
if c.privateKey.IsNil() {
71+
c.decryptKeysEncrypted(ctx)
72+
keys := c.keys.Keys()
73+
74+
for i := range c.DecryptKeys {
75+
out, err = c.DecryptKeys[i].PrivateKey.Decrypt(keys)
76+
if err == nil {
77+
k, err := cryptolib.ParseKey[cryptolib.KeyProviderPrivate](string(out))
78+
if err == nil {
79+
c.privateKey = k
80+
81+
break
82+
}
83+
}
84+
}
85+
}
86+
7287
if err != nil {
7388
return logger.Error(ctx, errs.ErrReceiver.Wrap(err))
7489
}

shared

Submodule shared updated from 7866111 to 771629e

0 commit comments

Comments
 (0)