public class RSAKey extends Object implements Key
The RSA Key https://blog.csdn.net/seccloud/article/details/8188812 https://blog.csdn.net/zntsbkhhh/article/details/109581852 https://www.zhihu.com/question/54779059 (1)选择两个不同的大素数p和q (2)计算公共模数(n=pq)和欧拉数(eular=(p-1)(q-1)) (3)选择公钥指数e (4)计算inverse(d) (5)生成公钥和私钥 公钥KU: n:两素数p和q的乘积(p和q必须保密)(n为模值) e:与(p-1)*(q-1)互质(e称为公钥指数) 私钥KR: n:两素数p和q的乘积(p和q必须保密)(n为模值) d:满足(d*e) mod ((p-1)*(q-1)) = 1(d称为私钥指数) 加密过程 C=M^e mod n (C为密文) 解密过程 M=C^d mod n (M为明文)
RSAKeyPairGenerator| 限定符和类型 | 字段和说明 |
|---|---|
BigInteger |
coeff |
BigInteger |
d |
BigInteger |
e |
BigInteger |
n |
BigInteger |
p |
BigInteger |
pe |
BigInteger |
q |
BigInteger |
qe |
static int |
RSA_F4 |
boolean |
secret |
| 构造器和说明 |
|---|
RSAKey(BigInteger n,
BigInteger e) |
RSAKey(BigInteger n,
BigInteger e,
BigInteger d,
BigInteger p,
BigInteger q,
BigInteger pe,
BigInteger qe,
BigInteger coeff) |
RSAKey(int keySize) |
RSAKey(int keySize,
int e) |
| 限定符和类型 | 方法和说明 |
|---|---|
static cn.ponfee.commons.jce.implementation.rsa.RSAKey.KeyPair |
generateKey(int keySize,
int e)
Generate the key pair
|
RSAKey |
getPublic()
get the public key
|
boolean |
isPublic() |
boolean |
isSecret() |
RSAKey |
readKey(InputStream in) |
void |
writeKey(OutputStream out) |
public static final int RSA_F4
public final BigInteger n
public final BigInteger e
public final BigInteger d
public final BigInteger p
public final BigInteger q
public final BigInteger pe
public final BigInteger qe
public final BigInteger coeff
public final boolean secret
public RSAKey(int keySize)
public RSAKey(int keySize,
int e)
public RSAKey(BigInteger n, BigInteger e, BigInteger d, BigInteger p, BigInteger q, BigInteger pe, BigInteger qe, BigInteger coeff)
public RSAKey(BigInteger n, BigInteger e)
public boolean isSecret()
public void writeKey(OutputStream out) throws IOException
writeKey 在接口中 KeyIOExceptionpublic RSAKey readKey(InputStream in) throws IOException
readKey 在接口中 KeyIOExceptionpublic static cn.ponfee.commons.jce.implementation.rsa.RSAKey.KeyPair generateKey(int keySize,
int e)
keySize - e - Copyright © 2023. All rights reserved.