Example usage for org.bouncycastle.asn1.nist NISTNamedCurves getOID

List of usage examples for org.bouncycastle.asn1.nist NISTNamedCurves getOID

Introduction

In this page you can find the example usage for org.bouncycastle.asn1.nist NISTNamedCurves getOID.

Prototype

public static ASN1ObjectIdentifier getOID(String name) 

Source Link

Document

return the object identifier signified by the passed in name.

Usage

From source file:org.sufficientlysecure.keychain.securitytoken.ECKeyFormat.java

License:Open Source License

public void addToSaveKeyringParcel(SaveKeyringParcel keyring, int keyFlags) {
    final X9ECParameters params = NISTNamedCurves.getByOID(mECCurveOID);
    final ECCurve curve = params.getCurve();

    SaveKeyringParcel.Algorithm algo = SaveKeyringParcel.Algorithm.ECDSA;
    if (((keyFlags & KeyFlags.ENCRYPT_COMMS) == KeyFlags.ENCRYPT_COMMS)
            || ((keyFlags & KeyFlags.ENCRYPT_STORAGE) == KeyFlags.ENCRYPT_STORAGE)) {
        algo = SaveKeyringParcel.Algorithm.ECDH;
    }//from w w w .  j ava 2s  .c  o  m

    SaveKeyringParcel.Curve scurve;
    if (mECCurveOID.equals(NISTNamedCurves.getOID("P-256"))) {
        scurve = SaveKeyringParcel.Curve.NIST_P256;
    } else if (mECCurveOID.equals(NISTNamedCurves.getOID("P-384"))) {
        scurve = SaveKeyringParcel.Curve.NIST_P384;
    } else if (mECCurveOID.equals(NISTNamedCurves.getOID("P-521"))) {
        scurve = SaveKeyringParcel.Curve.NIST_P521;
    } else {
        throw new IllegalArgumentException("Unsupported curve " + mECCurveOID);
    }

    keyring.mAddSubKeys.add(new SaveKeyringParcel.SubkeyAdd(algo, curve.getFieldSize(), scurve, keyFlags, 0L));
}

From source file:org.sufficientlysecure.keychain.securitytoken.KeyFormat.java

License:Open Source License

public static KeyFormat fromCreationKeyType(CreateSecurityTokenAlgorithmFragment.SupportedKeyType t,
        boolean forEncryption) {
    final int elen = 17; //65537
    final ECKeyFormat.ECAlgorithmFormat kf = forEncryption ? ECKeyFormat.ECAlgorithmFormat.ECDH_WITH_PUBKEY
            : ECKeyFormat.ECAlgorithmFormat.ECDSA_WITH_PUBKEY;

    switch (t) {/*from  ww  w .j  a  v  a 2 s  .  com*/
    case RSA_2048:
        return new RSAKeyFormat(2048, elen, RSAKeyFormat.RSAAlgorithmFormat.CRT_WITH_MODULUS);
    case RSA_3072:
        return new RSAKeyFormat(3072, elen, RSAKeyFormat.RSAAlgorithmFormat.CRT_WITH_MODULUS);
    case RSA_4096:
        return new RSAKeyFormat(4096, elen, RSAKeyFormat.RSAAlgorithmFormat.CRT_WITH_MODULUS);
    case ECC_P256:
        return new ECKeyFormat(NISTNamedCurves.getOID("P-256"), kf);
    case ECC_P384:
        return new ECKeyFormat(NISTNamedCurves.getOID("P-384"), kf);
    case ECC_P521:
        return new ECKeyFormat(NISTNamedCurves.getOID("P-521"), kf);
    }

    throw new IllegalArgumentException("Unsupported Algorithm id " + t);
}

From source file:org.xipki.security.p11.iaik.IaikP11Slot.java

License:Open Source License

private static ASN1ObjectIdentifier getCurveId(final String curveNameOrOid) {
    ASN1ObjectIdentifier curveId;//from  ww  w .  j av  a  2 s.c  o m

    try {
        curveId = new ASN1ObjectIdentifier(curveNameOrOid);
        return curveId;
    } catch (Exception e) {
    }

    curveId = X962NamedCurves.getOID(curveNameOrOid);

    if (curveId == null) {
        curveId = SECNamedCurves.getOID(curveNameOrOid);
    }

    if (curveId == null) {
        curveId = TeleTrusTNamedCurves.getOID(curveNameOrOid);
    }

    if (curveId == null) {
        curveId = NISTNamedCurves.getOID(curveNameOrOid);
    }

    return curveId;
}

From source file:org.xipki.security.p11.sun.SunNamedCurveExtender.java

License:Open Source License

private static ASN1ObjectIdentifier getCurveId(final String curveName) {
    ASN1ObjectIdentifier curveId = X962NamedCurves.getOID(curveName);

    if (curveId == null) {
        curveId = SECNamedCurves.getOID(curveName);
    }/*from  w ww  .  j a v a 2 s  .  c om*/

    if (curveId == null) {
        curveId = TeleTrusTNamedCurves.getOID(curveName);
    }

    if (curveId == null) {
        curveId = NISTNamedCurves.getOID(curveName);
    }

    return curveId;
}