Skip to content

Commit 471852b

Browse files
committed
rsa.go: check AiKeyAlg in ImportRSAPublicKeyBlob and ImportRSAPrivateKeyBlob.
1 parent f0c47f1 commit 471852b

File tree

1 file changed

+10
-0
lines changed

1 file changed

+10
-0
lines changed

wincrypto/rsa.go

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -85,6 +85,11 @@ func ImportRSAPublicKeyBlob(data []byte) (*rsa.PublicKey, error) {
8585
if bh.Version != curBlobVersion {
8686
return nil, errors.New("invalid blob version")
8787
}
88+
switch bh.AiKeyAlg {
89+
case cAlgRSASign, cAlgRSAKeyX:
90+
default:
91+
return nil, errors.New("invalid public key algorithm")
92+
}
8893
var rp rsaPubKey
8994
err = binary.Read(reader, binary.LittleEndian, &rp)
9095
if err != nil {
@@ -122,6 +127,11 @@ func ImportRSAPrivateKeyBlob(data []byte) (*rsa.PrivateKey, error) {
122127
if bh.Version != curBlobVersion {
123128
return nil, errors.New("invalid blob version")
124129
}
130+
switch bh.AiKeyAlg {
131+
case cAlgRSASign, cAlgRSAKeyX:
132+
default:
133+
return nil, errors.New("invalid private key algorithm")
134+
}
125135
var rp rsaPubKey
126136
err = binary.Read(reader, binary.LittleEndian, &rp)
127137
if err != nil {

0 commit comments

Comments
 (0)