Rename methods related only to security tokens

This commit is contained in:
Arnaud Fontaine 2017-01-05 11:01:14 +01:00
parent 3a20dee36f
commit 42b5e291ca
4 changed files with 11 additions and 11 deletions

View file

@ -203,7 +203,7 @@ public class CanonicalizedPublicKey extends UncachedPublicKey {
}
// For use only in card export; returns the public key.
public ECPublicKey getECPublicKey()
public ECPublicKey getSecurityTokenECPublicKey()
throws PgpGeneralException {
JcaPGPKeyConverter keyConverter = new JcaPGPKeyConverter();
PublicKey retVal;
@ -216,7 +216,7 @@ public class CanonicalizedPublicKey extends UncachedPublicKey {
return (ECPublicKey) retVal;
}
public ASN1ObjectIdentifier getHashAlgorithm()
public ASN1ObjectIdentifier getSecurityTokenHashAlgorithm()
throws PGPException {
if (!isEC()) {
throw new PGPException("Key encryption OID is valid only for EC key!");
@ -236,7 +236,7 @@ public class CanonicalizedPublicKey extends UncachedPublicKey {
}
}
public int getSymmetricKeySize()
public int getSecurityTokenSymmetricKeySize()
throws PGPException {
if (!isEC()) {
throw new PGPException("Key encryption OID is valid only for EC key!");

View file

@ -300,7 +300,7 @@ public class CanonicalizedSecretKey extends CanonicalizedPublicKey {
}
// For use only in card export; returns the secret key in Chinese Remainder Theorem format.
public RSAPrivateCrtKey getCrtSecretKey() throws PgpGeneralException {
public RSAPrivateCrtKey getSecurityTokenRSASecretKey() throws PgpGeneralException {
if (mPrivateKeyState == PRIVATE_KEY_STATE_LOCKED) {
throw new PgpGeneralException("Cannot get secret key attributes while key is locked.");
}
@ -321,7 +321,7 @@ public class CanonicalizedSecretKey extends CanonicalizedPublicKey {
}
// For use only in card export; returns the secret key.
public ECPrivateKey getECSecretKey()
public ECPrivateKey getSecurityTokenECSecretKey()
throws PgpGeneralException {
if (mPrivateKeyState == PRIVATE_KEY_STATE_LOCKED) {
throw new PgpGeneralException("Cannot get secret key attributes while key is locked.");

View file

@ -338,7 +338,7 @@ public class SecurityTokenHelper {
System.arraycopy(encryptedSessionKey, 2 + pLen + 1, keyEnc, 0, keyEnc.length);
try {
final MessageDigest kdf = MessageDigest.getInstance(MessageDigestUtils.getDigestName(publicKey.getHashAlgorithm()));
final MessageDigest kdf = MessageDigest.getInstance(MessageDigestUtils.getDigestName(publicKey.getSecurityTokenHashAlgorithm()));
kdf.update(new byte[]{ (byte)0, (byte)0, (byte)0, (byte)1 });
kdf.update(data);
@ -347,7 +347,7 @@ public class SecurityTokenHelper {
final byte[] kek = kdf.digest();
final Cipher c = Cipher.getInstance("AESWrap");
c.init(Cipher.UNWRAP_MODE, new SecretKeySpec(kek, 0, publicKey.getSymmetricKeySize() / 8, "AES"));
c.init(Cipher.UNWRAP_MODE, new SecretKeySpec(kek, 0, publicKey.getSecurityTokenSymmetricKeySize() / 8, "AES"));
final Key paddedSessionKey = c.unwrap(keyEnc, "Session", Cipher.SECRET_KEY);
@ -489,7 +489,7 @@ public class SecurityTokenHelper {
if (!secretKey.isRSA()) {
throw new IOException("Security Token not configured for RSA key.");
}
crtSecretKey = secretKey.getCrtSecretKey();
crtSecretKey = secretKey.getSecurityTokenRSASecretKey();
// Should happen only rarely; all GnuPG keys since 2006 use public exponent 65537.
if (!crtSecretKey.getPublicExponent().equals(new BigInteger("65537"))) {
@ -506,8 +506,8 @@ public class SecurityTokenHelper {
}
secretKey.unlock(passphrase);
ecSecretKey = secretKey.getECSecretKey();
ecPublicKey = secretKey.getECPublicKey();
ecSecretKey = secretKey.getSecurityTokenECSecretKey();
ecPublicKey = secretKey.getSecurityTokenECPublicKey();
keyBytes = SecurityTokenUtils.createECPrivKeyTemplate(ecSecretKey, ecPublicKey, slot,
(ECKeyFormat) (mOpenPgpCapabilities.getFormatForKeyType(slot)));

View file

@ -37,7 +37,7 @@ public class SecurityTokenUtils {
public static byte[] attributesFromSecretKey(final KeyType slot, final CanonicalizedSecretKey secretKey) throws IOException, PgpGeneralException {
if (secretKey.isRSA()) {
final int mModulusLength = secretKey.getBitStrength();
final int mExponentLength = secretKey.getCrtSecretKey().getPublicExponent().bitLength();
final int mExponentLength = secretKey.getSecurityTokenRSASecretKey().getPublicExponent().bitLength();
final byte[] attrs = new byte[6];
int i = 0;