0
任何人都可以告訴我,如何獲得rsa私鑰的p,q,dp,dq和u組件? 加載密鑰:M2Crypto.rsa私鑰關鍵組件
string = open(keyfile,"rb").read();
bio = BIO.MemoryBuffer(string);
rsa = RSA.load_key_bio(bio);
接下來我該做什麼?
任何人都可以告訴我,如何獲得rsa私鑰的p,q,dp,dq和u組件? 加載密鑰:M2Crypto.rsa私鑰關鍵組件
string = open(keyfile,"rb").read();
bio = BIO.MemoryBuffer(string);
rsa = RSA.load_key_bio(bio);
接下來我該做什麼?
M2Crypto
不支持直接讀取rsa參數,對不起。
你可以從res.pub()
(種,因爲第一個字節不是它的一部分)得到e(公開指數)和n(模數)。
上另一方面Crypto
API支持讀取多個參數:
string = open(keyfile,"rb").read()
import Crypto.PublicKey.RSA
crsa = Crypto.PublicKey.RSA.importKey(string)
print(crsa.n, crsa.e, crsa.d, crsa.p, crsa.q, crsa.u)