Single retrieval of RSA_PKCS1 cipher instance
This commit is contained in:
parent
f1d0c6f276
commit
04404d6a4e
@ -39,9 +39,12 @@ public final class PGPKey {
|
|||||||
|
|
||||||
private KeyPair keys;
|
private KeyPair keys;
|
||||||
|
|
||||||
|
private final Cipher cipher_rsa_pkcs1;
|
||||||
|
|
||||||
protected PGPKey() {
|
protected PGPKey() {
|
||||||
|
|
||||||
|
cipher_rsa_pkcs1 = Cipher.getInstance(Cipher.ALG_RSA_PKCS1, false);
|
||||||
|
|
||||||
fingerprint = new Fingerprint();
|
fingerprint = new Fingerprint();
|
||||||
generation_date = new byte[Constants.GENERATION_DATE_SIZE];
|
generation_date = new byte[Constants.GENERATION_DATE_SIZE];
|
||||||
|
|
||||||
@ -470,10 +473,9 @@ public final class PGPKey {
|
|||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
final Cipher cipher = Cipher.getInstance(Cipher.ALG_RSA_PKCS1, false);
|
cipher_rsa_pkcs1.init(priv, Cipher.MODE_ENCRYPT);
|
||||||
cipher.init(priv, Cipher.MODE_ENCRYPT);
|
|
||||||
|
|
||||||
off = cipher.doFinal(buf, (short)0, lc,
|
off = cipher_rsa_pkcs1.doFinal(buf, (short)0, lc,
|
||||||
buf, (short)lc);
|
buf, (short)lc);
|
||||||
|
|
||||||
return Util.arrayCopyNonAtomic(buf, (short)lc,
|
return Util.arrayCopyNonAtomic(buf, (short)lc,
|
||||||
@ -511,10 +513,9 @@ public final class PGPKey {
|
|||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
final Cipher cipher = Cipher.getInstance(Cipher.ALG_RSA_PKCS1, false);
|
cipher_rsa_pkcs1.init(priv, Cipher.MODE_DECRYPT);
|
||||||
cipher.init(priv, Cipher.MODE_DECRYPT);
|
|
||||||
|
|
||||||
final short len = cipher.doFinal(buf, (short)1, (short)(lc - 1),
|
final short len = cipher_rsa_pkcs1.doFinal(buf, (short)1, (short)(lc - 1),
|
||||||
buf, (short)lc);
|
buf, (short)lc);
|
||||||
|
|
||||||
off = Util.arrayCopyNonAtomic(buf, lc,
|
off = Util.arrayCopyNonAtomic(buf, lc,
|
||||||
|
Loading…
x
Reference in New Issue
Block a user