reduce visibility where unnecessary
This commit is contained in:
@@ -21,7 +21,8 @@ import org.sufficientlysecure.keychain.securitytoken.usb.UsbTransportException;
|
||||
|
||||
import java.nio.ByteBuffer;
|
||||
|
||||
public class CardCapabilities {
|
||||
@SuppressWarnings("WeakerAccess")
|
||||
class CardCapabilities {
|
||||
private static final int MASK_CHAINING = 1 << 7;
|
||||
private static final int MASK_EXTENDED = 1 << 6;
|
||||
|
||||
|
||||
@@ -25,18 +25,18 @@ import org.sufficientlysecure.keychain.ui.CreateSecurityTokenAlgorithmFragment;
|
||||
|
||||
public abstract class KeyFormat {
|
||||
|
||||
public enum KeyFormatType {
|
||||
enum KeyFormatType {
|
||||
RSAKeyFormatType,
|
||||
ECKeyFormatType
|
||||
};
|
||||
}
|
||||
|
||||
private final KeyFormatType mKeyFormatType;
|
||||
|
||||
public KeyFormat(final KeyFormatType keyFormatType) {
|
||||
KeyFormat(final KeyFormatType keyFormatType) {
|
||||
mKeyFormatType = keyFormatType;
|
||||
}
|
||||
|
||||
public final KeyFormatType keyFormatType() {
|
||||
final KeyFormatType keyFormatType() {
|
||||
return mKeyFormatType;
|
||||
}
|
||||
|
||||
|
||||
@@ -21,7 +21,8 @@ import java.io.IOException;
|
||||
import java.util.HashMap;
|
||||
import java.util.Map;
|
||||
|
||||
public class OpenPgpCapabilities {
|
||||
@SuppressWarnings("unused") // just expose all included data
|
||||
class OpenPgpCapabilities {
|
||||
private final static int MASK_SM = 1 << 7;
|
||||
private final static int MASK_KEY_IMPORT = 1 << 5;
|
||||
private final static int MASK_ATTRIBUTES_CHANGABLE = 1 << 2;
|
||||
@@ -40,12 +41,12 @@ public class OpenPgpCapabilities {
|
||||
|
||||
private Map<KeyType, KeyFormat> mKeyFormats;
|
||||
|
||||
public OpenPgpCapabilities(byte[] data) throws IOException {
|
||||
OpenPgpCapabilities(byte[] data) throws IOException {
|
||||
mKeyFormats = new HashMap<>();
|
||||
updateWithData(data);
|
||||
}
|
||||
|
||||
public void updateWithData(byte[] data) throws IOException {
|
||||
void updateWithData(byte[] data) throws IOException {
|
||||
Iso7816TLV[] tlvs = Iso7816TLV.readList(data, true);
|
||||
if (tlvs.length == 1 && tlvs[0].mT == 0x6E) {
|
||||
tlvs = ((Iso7816TLV.Iso7816CompositeTLV) tlvs[0]).mSubs;
|
||||
@@ -114,47 +115,47 @@ public class OpenPgpCapabilities {
|
||||
mMaxRspLen = (v[8] << 8) + v[9];
|
||||
}
|
||||
|
||||
public boolean isPw1ValidForMultipleSignatures() {
|
||||
boolean isPw1ValidForMultipleSignatures() {
|
||||
return mPw1ValidForMultipleSignatures;
|
||||
}
|
||||
|
||||
public byte[] getAid() {
|
||||
byte[] getAid() {
|
||||
return mAid;
|
||||
}
|
||||
|
||||
public byte[] getHistoricalBytes() {
|
||||
byte[] getHistoricalBytes() {
|
||||
return mHistoricalBytes;
|
||||
}
|
||||
|
||||
public boolean isHasSM() {
|
||||
boolean isHasSM() {
|
||||
return mHasSM;
|
||||
}
|
||||
|
||||
public boolean isAttributesChangable() {
|
||||
boolean isAttributesChangable() {
|
||||
return mAttriburesChangable;
|
||||
}
|
||||
|
||||
public boolean isHasKeyImport() {
|
||||
boolean isHasKeyImport() {
|
||||
return mHasKeyImport;
|
||||
}
|
||||
|
||||
public boolean isHasAESSM() {
|
||||
boolean isHasAESSM() {
|
||||
return isHasSM() && ((mSMType == 1) || (mSMType == 2));
|
||||
}
|
||||
|
||||
public boolean isHasSCP11bSM() {
|
||||
boolean isHasSCP11bSM() {
|
||||
return isHasSM() && (mSMType == 3);
|
||||
}
|
||||
|
||||
public int getMaxCmdLen() {
|
||||
int getMaxCmdLen() {
|
||||
return mMaxCmdLen;
|
||||
}
|
||||
|
||||
public int getMaxRspLen() {
|
||||
int getMaxRspLen() {
|
||||
return mMaxRspLen;
|
||||
}
|
||||
|
||||
public KeyFormat getFormatForKeyType(KeyType keyType) {
|
||||
KeyFormat getFormatForKeyType(KeyType keyType) {
|
||||
return mKeyFormats.get(keyType);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -24,6 +24,7 @@ import com.google.auto.value.AutoValue;
|
||||
|
||||
/** A response APDU as defined in ISO/IEC 7816-4. */
|
||||
@AutoValue
|
||||
@SuppressWarnings("WeakerAccess")
|
||||
public abstract class ResponseApdu {
|
||||
private static final int APDU_SW_SUCCESS = 0x9000;
|
||||
|
||||
|
||||
@@ -150,7 +150,7 @@ class SCP11bSecureMessaging implements SecureMessaging {
|
||||
&& (mMacChaining != null);
|
||||
}
|
||||
|
||||
private static final ECParameterSpec getAlgorithmParameterSpec(final ECKeyFormat kf)
|
||||
private static ECParameterSpec getAlgorithmParameterSpec(final ECKeyFormat kf)
|
||||
throws NoSuchProviderException, NoSuchAlgorithmException, InvalidParameterSpecException {
|
||||
final AlgorithmParameters algoParams = AlgorithmParameters.getInstance(SCP11B_KEY_AGREEMENT_KEY_ALGO, PROVIDER);
|
||||
|
||||
@@ -273,7 +273,7 @@ class SCP11bSecureMessaging implements SecureMessaging {
|
||||
}
|
||||
|
||||
|
||||
public static void establish(final SecurityTokenConnection t, final Context ctx, OpenPgpCommandApduFactory commandFactory)
|
||||
static void establish(final SecurityTokenConnection t, final Context ctx, OpenPgpCommandApduFactory commandFactory)
|
||||
throws SecureMessagingException, IOException {
|
||||
|
||||
CommandAPDU cmd;
|
||||
|
||||
@@ -33,8 +33,8 @@ import java.security.interfaces.ECPrivateKey;
|
||||
import java.security.interfaces.ECPublicKey;
|
||||
import java.security.interfaces.RSAPrivateCrtKey;
|
||||
|
||||
public class SecurityTokenUtils {
|
||||
public static byte[] attributesFromSecretKey(final KeyType slot, final CanonicalizedSecretKey secretKey) throws IOException, PgpGeneralException {
|
||||
class SecurityTokenUtils {
|
||||
static byte[] attributesFromSecretKey(final KeyType slot, final CanonicalizedSecretKey secretKey) throws IOException, PgpGeneralException {
|
||||
if (secretKey.isRSA()) {
|
||||
final int mModulusLength = secretKey.getBitStrength();
|
||||
final int mExponentLength = secretKey.getSecurityTokenRSASecretKey().getPublicExponent().bitLength();
|
||||
@@ -46,7 +46,7 @@ public class SecurityTokenUtils {
|
||||
attrs[i++] = (byte) (mModulusLength & 0xff);
|
||||
attrs[i++] = (byte) ((mExponentLength >> 8) & 0xff);
|
||||
attrs[i++] = (byte) (mExponentLength & 0xff);
|
||||
attrs[i++] = RSAKeyFormat.RSAAlgorithmFormat.CRT_WITH_MODULUS.getValue();
|
||||
attrs[i] = RSAKeyFormat.RSAAlgorithmFormat.CRT_WITH_MODULUS.getValue();
|
||||
|
||||
return attrs;
|
||||
} else if (secretKey.isEC()) {
|
||||
@@ -70,8 +70,8 @@ public class SecurityTokenUtils {
|
||||
}
|
||||
|
||||
|
||||
public static byte[] createRSAPrivKeyTemplate(RSAPrivateCrtKey secretKey, KeyType slot,
|
||||
RSAKeyFormat format) throws IOException {
|
||||
static byte[] createRSAPrivKeyTemplate(RSAPrivateCrtKey secretKey, KeyType slot,
|
||||
RSAKeyFormat format) throws IOException {
|
||||
ByteArrayOutputStream stream = new ByteArrayOutputStream(),
|
||||
template = new ByteArrayOutputStream(),
|
||||
data = new ByteArrayOutputStream(),
|
||||
@@ -138,8 +138,8 @@ public class SecurityTokenUtils {
|
||||
return res.toByteArray();
|
||||
}
|
||||
|
||||
public static byte[] createECPrivKeyTemplate(ECPrivateKey secretKey, ECPublicKey publicKey, KeyType slot,
|
||||
ECKeyFormat format) throws IOException {
|
||||
static byte[] createECPrivKeyTemplate(ECPrivateKey secretKey, ECPublicKey publicKey, KeyType slot,
|
||||
ECKeyFormat format) throws IOException {
|
||||
ByteArrayOutputStream stream = new ByteArrayOutputStream(),
|
||||
template = new ByteArrayOutputStream(),
|
||||
data = new ByteArrayOutputStream(),
|
||||
@@ -184,7 +184,7 @@ public class SecurityTokenUtils {
|
||||
return res.toByteArray();
|
||||
}
|
||||
|
||||
public static byte[] encodeLength(int len) {
|
||||
static byte[] encodeLength(int len) {
|
||||
if (len < 0) {
|
||||
throw new IllegalArgumentException("length is negative");
|
||||
} else if (len >= 16777216) {
|
||||
@@ -214,7 +214,7 @@ public class SecurityTokenUtils {
|
||||
return res;
|
||||
}
|
||||
|
||||
public static void writeBits(ByteArrayOutputStream stream, BigInteger value, int width) {
|
||||
static void writeBits(ByteArrayOutputStream stream, BigInteger value, int width) {
|
||||
if (value.signum() == -1) {
|
||||
throw new IllegalArgumentException("value is negative");
|
||||
} else if (width <= 0) {
|
||||
|
||||
Reference in New Issue
Block a user