mirror of
https://github.com/moparisthebest/open-keychain
synced 2024-12-25 16:38:50 -05:00
Remove version 3 checks, no longer supported in import
This commit is contained in:
parent
fe2c17cdeb
commit
b08aa132e0
@ -27,7 +27,6 @@ import android.text.style.ForegroundColorSpan;
|
|||||||
import org.spongycastle.asn1.ASN1ObjectIdentifier;
|
import org.spongycastle.asn1.ASN1ObjectIdentifier;
|
||||||
import org.spongycastle.asn1.nist.NISTNamedCurves;
|
import org.spongycastle.asn1.nist.NISTNamedCurves;
|
||||||
import org.spongycastle.asn1.teletrust.TeleTrusTNamedCurves;
|
import org.spongycastle.asn1.teletrust.TeleTrusTNamedCurves;
|
||||||
import org.spongycastle.bcpg.ECPublicBCPGKey;
|
|
||||||
import org.spongycastle.bcpg.PublicKeyAlgorithmTags;
|
import org.spongycastle.bcpg.PublicKeyAlgorithmTags;
|
||||||
import org.spongycastle.util.encoders.Hex;
|
import org.spongycastle.util.encoders.Hex;
|
||||||
import org.sufficientlysecure.keychain.Constants;
|
import org.sufficientlysecure.keychain.Constants;
|
||||||
@ -156,9 +155,11 @@ public class PgpKeyHelper {
|
|||||||
return algorithmStr;
|
return algorithmStr;
|
||||||
}
|
}
|
||||||
|
|
||||||
// Return name of a curve. These are names, no need for translation
|
/**
|
||||||
|
* Return name of a curve. These are names, no need for translation
|
||||||
|
*/
|
||||||
public static String getCurveInfo(Context context, Curve curve) {
|
public static String getCurveInfo(Context context, Curve curve) {
|
||||||
switch(curve) {
|
switch (curve) {
|
||||||
case NIST_P256:
|
case NIST_P256:
|
||||||
return "NIST P-256";
|
return "NIST P-256";
|
||||||
case NIST_P384:
|
case NIST_P384:
|
||||||
@ -211,9 +212,7 @@ public class PgpKeyHelper {
|
|||||||
* @return
|
* @return
|
||||||
*/
|
*/
|
||||||
public static String convertFingerprintToHex(byte[] fingerprint) {
|
public static String convertFingerprintToHex(byte[] fingerprint) {
|
||||||
String hexString = Hex.toHexString(fingerprint).toLowerCase(Locale.ENGLISH);
|
return Hex.toHexString(fingerprint).toLowerCase(Locale.ENGLISH);
|
||||||
|
|
||||||
return hexString;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -327,10 +326,9 @@ public class PgpKeyHelper {
|
|||||||
md.update(bytes);
|
md.update(bytes);
|
||||||
byte[] digest = md.digest();
|
byte[] digest = md.digest();
|
||||||
|
|
||||||
int[] result = {((int) digest[0] + 256) % 256,
|
return new int[]{((int) digest[0] + 256) % 256,
|
||||||
((int) digest[1] + 256) % 256,
|
((int) digest[1] + 256) % 256,
|
||||||
((int) digest[2] + 256) % 256};
|
((int) digest[2] + 256) % 256};
|
||||||
return result;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
@ -124,9 +124,9 @@ public class PgpKeyOperation {
|
|||||||
*
|
*
|
||||||
* http://kbsriram.com/2013/01/generating-rsa-keys-with-bouncycastle.html
|
* http://kbsriram.com/2013/01/generating-rsa-keys-with-bouncycastle.html
|
||||||
*/
|
*/
|
||||||
|
private static final int SECRET_KEY_ENCRYPTOR_S2K_COUNT = 0x60;
|
||||||
private static final int SECRET_KEY_ENCRYPTOR_HASH_ALGO = HashAlgorithmTags.SHA512;
|
private static final int SECRET_KEY_ENCRYPTOR_HASH_ALGO = HashAlgorithmTags.SHA512;
|
||||||
private static final int SECRET_KEY_ENCRYPTOR_SYMMETRIC_ALGO = SymmetricKeyAlgorithmTags.AES_256;
|
private static final int SECRET_KEY_ENCRYPTOR_SYMMETRIC_ALGO = SymmetricKeyAlgorithmTags.AES_256;
|
||||||
private static final int SECRET_KEY_ENCRYPTOR_S2K_COUNT = 0x60;
|
|
||||||
|
|
||||||
public PgpKeyOperation(Progressable progress) {
|
public PgpKeyOperation(Progressable progress) {
|
||||||
super();
|
super();
|
||||||
@ -415,8 +415,7 @@ public class PgpKeyOperation {
|
|||||||
PGPSecretKey masterSecretKey = sKR.getSecretKey();
|
PGPSecretKey masterSecretKey = sKR.getSecretKey();
|
||||||
|
|
||||||
// Make sure the fingerprint matches
|
// Make sure the fingerprint matches
|
||||||
if (saveParcel.mFingerprint == null
|
if (saveParcel.mFingerprint == null || !Arrays.equals(saveParcel.mFingerprint,
|
||||||
|| !Arrays.equals(saveParcel.mFingerprint,
|
|
||||||
masterSecretKey.getPublicKey().getFingerprint())) {
|
masterSecretKey.getPublicKey().getFingerprint())) {
|
||||||
log.add(LogLevel.ERROR, LogType.MSG_MF_ERROR_FINGERPRINT, indent);
|
log.add(LogLevel.ERROR, LogType.MSG_MF_ERROR_FINGERPRINT, indent);
|
||||||
return new EditKeyResult(EditKeyResult.RESULT_ERROR, log, null);
|
return new EditKeyResult(EditKeyResult.RESULT_ERROR, log, null);
|
||||||
|
@ -207,21 +207,23 @@ public class UncachedPublicKey {
|
|||||||
return getAlgorithm() == PGPPublicKey.ECDH || getAlgorithm() == PGPPublicKey.ECDSA;
|
return getAlgorithm() == PGPPublicKey.ECDH || getAlgorithm() == PGPPublicKey.ECDSA;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Get all key usage flags
|
||||||
|
*
|
||||||
|
* TODO make this safe
|
||||||
|
*/
|
||||||
@SuppressWarnings("unchecked")
|
@SuppressWarnings("unchecked")
|
||||||
// TODO make this safe
|
|
||||||
public int getKeyUsage() {
|
public int getKeyUsage() {
|
||||||
if(mCacheUsage == null) {
|
if(mCacheUsage == null) {
|
||||||
mCacheUsage = 0;
|
mCacheUsage = 0;
|
||||||
if (mPublicKey.getVersion() >= 4) {
|
for (PGPSignature sig : new IterableIterator<PGPSignature>(mPublicKey.getSignatures())) {
|
||||||
for (PGPSignature sig : new IterableIterator<PGPSignature>(mPublicKey.getSignatures())) {
|
if (mPublicKey.isMasterKey() && sig.getKeyID() != mPublicKey.getKeyID()) {
|
||||||
if (mPublicKey.isMasterKey() && sig.getKeyID() != mPublicKey.getKeyID()) {
|
continue;
|
||||||
continue;
|
}
|
||||||
}
|
|
||||||
|
|
||||||
PGPSignatureSubpacketVector hashed = sig.getHashedSubPackets();
|
PGPSignatureSubpacketVector hashed = sig.getHashedSubPackets();
|
||||||
if (hashed != null) {
|
if (hashed != null) {
|
||||||
mCacheUsage |= hashed.getKeyFlags();
|
mCacheUsage |= hashed.getKeyFlags();
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -229,11 +231,11 @@ public class UncachedPublicKey {
|
|||||||
}
|
}
|
||||||
|
|
||||||
public boolean canAuthenticate() {
|
public boolean canAuthenticate() {
|
||||||
return mPublicKey.getVersion() <= 3 || (getKeyUsage() & KeyFlags.AUTHENTICATION) != 0;
|
return (getKeyUsage() & KeyFlags.AUTHENTICATION) != 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
public boolean canCertify() {
|
public boolean canCertify() {
|
||||||
return mPublicKey.getVersion() <= 3 || (getKeyUsage() & KeyFlags.CERTIFY_OTHER) != 0;
|
return (getKeyUsage() & KeyFlags.CERTIFY_OTHER) != 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
public boolean canEncrypt() {
|
public boolean canEncrypt() {
|
||||||
@ -250,9 +252,7 @@ public class UncachedPublicKey {
|
|||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
return mPublicKey.getVersion() <= 3 ||
|
return (getKeyUsage() & (KeyFlags.ENCRYPT_COMMS | KeyFlags.ENCRYPT_STORAGE)) != 0;
|
||||||
(getKeyUsage() & (KeyFlags.ENCRYPT_COMMS | KeyFlags.ENCRYPT_STORAGE)) != 0;
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public boolean canSign() {
|
public boolean canSign() {
|
||||||
@ -261,7 +261,7 @@ public class UncachedPublicKey {
|
|||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
return mPublicKey.getVersion() <= 3 || (getKeyUsage() & KeyFlags.SIGN_DATA) != 0;
|
return (getKeyUsage() & KeyFlags.SIGN_DATA) != 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
public byte[] getFingerprint() {
|
public byte[] getFingerprint() {
|
||||||
|
Loading…
Reference in New Issue
Block a user