public class Util extends Object
Modifier and Type | Field and Description |
---|---|
static int |
ENC_MODE
Deprecated.
Mode for KDF.
|
static int |
MAC_MODE
Deprecated.
Mode for KDF.
|
static int |
PACE_MODE
Deprecated.
Mode for KDF.
|
Modifier and Type | Method and Description |
---|---|
static byte[] |
alignKeyDataToSize(byte[] keyData,
int size)
Deprecated.
|
static BigInteger |
computeAffineY(BigInteger affineX,
ECParameterSpec params)
Deprecated.
This just solves the curve equation for y.
|
static byte[] |
computeKeySeed(String documentNumber,
String dateOfBirth,
String dateOfExpiry,
String digestAlg,
boolean doTruncate)
Deprecated.
Computes the static key seed, based on information from the MRZ.
|
static long |
computeSendSequenceCounter(byte[] rndICC,
byte[] rndIFD)
Deprecated.
|
static PublicKey |
decodePublicKeyFromSmartCard(byte[] encodedPublicKey,
AlgorithmParameterSpec params)
Deprecated.
|
static SecretKey |
deriveKey(byte[] keySeed,
int mode)
Deprecated.
Derives the ENC or MAC key for BAC from the keySeed.
|
static SecretKey |
deriveKey(byte[] keySeed,
String cipherAlg,
int keyLength,
byte[] nonce,
int counter)
Deprecated.
Derives a shared key.
|
static SecretKey |
deriveKey(byte[] keySeed,
String cipherAlgName,
int keyLength,
int mode)
Deprecated.
Derives the ENC or MAC key for BAC or PACE
|
static byte[] |
encodePublicKeyDataObject(String oid,
PublicKey publicKey)
Deprecated.
Based on TR-SAC 1.01 4.5.1 and 4.5.2.
|
static byte[] |
encodePublicKeyDataObject(String oid,
PublicKey publicKey,
boolean isContextKnown)
Deprecated.
Based on TR-SAC 1.01 4.5.1 and 4.5.2.
|
static byte[] |
encodePublicKeyForSmartCard(PublicKey publicKey)
Deprecated.
Write uncompressed coordinates (for EC) or public value (DH).
|
static String |
getCurveName(ECParameterSpec params)
Deprecated.
Gets the curve name if known (or null).
|
static String |
getDetailedPublicKeyAlgorithm(PublicKey publicKey)
Deprecated.
The public key algorithm (like RSA or) with some extra information (like 1024 bits).
|
static BigInteger |
getPrime(AlgorithmParameterSpec params)
Deprecated.
|
static byte[] |
getRawECDSASignature(byte[] signedData,
int keySize)
Deprecated.
For ECDSA the EAC 1.11 specification requires the signature to be stripped down from any ASN.1 wrappers, as so.
|
static byte[] |
i2os(BigInteger val)
Deprecated.
Converts an integer to an octet string.
|
static byte[] |
i2os(BigInteger val,
int length)
Deprecated.
Converts an integer to an octet string.
|
static String |
inferDigestAlgorithmFromCipherAlgorithmForKeyDerivation(String cipherAlg,
int keyLength)
Deprecated.
|
static String |
inferDigestAlgorithmFromSignatureAlgorithm(String signatureAlgorithm)
Deprecated.
Infers a digest algorithm mnemonic from a signature algorithm mnemonic.
|
static String |
inferKeyAgreementAlgorithm(PublicKey publicKey)
Deprecated.
|
static String |
inferProtocolIdentifier(PublicKey publicKey)
Deprecated.
Infer an EAC object identifier for an EC or DH public key.
|
static boolean |
isValid(ECPoint ecPoint,
ECParameterSpec params)
Deprecated.
|
static AlgorithmParameterSpec |
mapNonceGM(byte[] nonceS,
byte[] sharedSecretH,
AlgorithmParameterSpec params)
Deprecated.
|
static AlgorithmParameterSpec |
mapNonceIM(byte[] nonceS,
byte[] nonceT,
byte[] sharedSecretH,
AlgorithmParameterSpec params)
Deprecated.
|
static ECPoint |
multiply(BigInteger s,
ECPoint point,
ECParameterSpec params)
Deprecated.
|
static ECPoint |
normalize(ECPoint ecPoint,
ECParameterSpec params)
Deprecated.
|
static BigInteger |
os2fe(byte[] bytes,
BigInteger p)
Deprecated.
Convert an octet string to field element via OS2FE as specified in BSI TR-03111.
|
static BigInteger |
os2i(byte[] bytes)
Deprecated.
Converts an octet string to an integer.
|
static BigInteger |
os2i(byte[] bytes,
int offset,
int length)
Deprecated.
Converts an octet string to an integer.
|
static byte[] |
padWithCAN(byte[] in,
int blockSize)
Deprecated.
|
static byte[] |
padWithCAN(byte[] in,
int offset,
int length,
int blockSize)
Deprecated.
|
static byte[] |
padWithMRZ(byte[] in)
Deprecated.
Pads the input
in according to ISO9797-1 padding method 2. |
static byte[] |
padWithMRZ(byte[] in,
int offset,
int length)
Deprecated.
|
static byte[] |
publicKeyECPointToOS(ECPoint point)
Deprecated.
Encode an EC public key point.
|
static PublicKey |
reconstructPublicKey(PublicKey publicKey)
Deprecated.
Reconstructs the public key to use explicit domain params for EC public keys
|
static byte[] |
recoverMessage(int digestLength,
byte[] plaintext)
Deprecated.
Recovers the M1 part of the message sent back by the AA protocol
(INTERNAL AUTHENTICATE command).
|
static org.bouncycastle.jce.spec.ECNamedCurveSpec |
toECNamedCurveSpec(org.bouncycastle.jce.spec.ECNamedCurveParameterSpec namedParamSpec)
Deprecated.
Translates internal BC named curve spec to BC provided JCA compliant named curve spec.
|
static DHParameterSpec |
toExplicitDHParameterSpec(org.bouncycastle.crypto.params.DHParameters params)
Deprecated.
|
static ECParameterSpec |
toExplicitECParameterSpec(org.bouncycastle.jce.spec.ECNamedCurveParameterSpec parameterSpec)
Deprecated.
|
static ECParameterSpec |
toExplicitECParameterSpec(ECParameterSpec params)
Deprecated.
Translates (named) curve spec to JCA compliant explicit param spec.
|
static PublicKey |
toPublicKey(org.bouncycastle.asn1.x509.SubjectPublicKeyInfo subjectPublicKeyInfo)
Deprecated.
|
static org.bouncycastle.asn1.x509.SubjectPublicKeyInfo |
toSubjectPublicKeyInfo(PublicKey publicKey)
Deprecated.
|
static byte[] |
unpad(byte[] in)
Deprecated.
|
static byte[] |
unwrapDO(byte expectedTag,
byte[] wrappedData)
Deprecated.
|
static byte[] |
wrapDO(byte tag,
byte[] data)
Deprecated.
|
public static final int ENC_MODE
public static final int MAC_MODE
public static final int PACE_MODE
public static SecretKey deriveKey(byte[] keySeed, int mode) throws GeneralSecurityException
keySeed
- the key seed.mode
- either ENC_MODE
or MAC_MODE
GeneralSecurityException
- on security errorpublic static SecretKey deriveKey(byte[] keySeed, String cipherAlgName, int keyLength, int mode) throws GeneralSecurityException
keySeed
- the key seed.cipherAlgName
- either AES or DESedekeyLength
- key length in bitsmode
- either ENC_MODE
, MAC_MODE
, or PACE_MODE
GeneralSecurityException
- on security errorpublic static SecretKey deriveKey(byte[] keySeed, String cipherAlg, int keyLength, byte[] nonce, int counter) throws GeneralSecurityException
keySeed
- the shared secret, as octetscipherAlg
- in Java mnemonic notation (for example "DESede", "AES")keyLength
- length in bitsnonce
- optional nonce or null
counter
- counter or modeGeneralSecurityException
- if something went wrongpublic static byte[] computeKeySeed(String documentNumber, String dateOfBirth, String dateOfExpiry, String digestAlg, boolean doTruncate) throws GeneralSecurityException
documentNumber
- a string containing the document numberdateOfBirth
- a string containing the date of birth (YYMMDD)dateOfExpiry
- a string containing the date of expiry (YYMMDD)digestAlg
- a Java mnemonic algorithm string to indicate the digest algorithm (typically SHA-1)doTruncate
- whether to truncate the resulting output to 16 bytesGeneralSecurityException
- on security errorpublic static byte[] padWithMRZ(byte[] in)
in
according to ISO9797-1 padding method 2.in
- inputpublic static byte[] padWithCAN(byte[] in, int blockSize)
public static byte[] padWithMRZ(byte[] in, int offset, int length)
public static byte[] padWithCAN(byte[] in, int offset, int length, int blockSize)
public static long computeSendSequenceCounter(byte[] rndICC, byte[] rndIFD)
public static byte[] unpad(byte[] in) throws BadPaddingException
BadPaddingException
public static byte[] recoverMessage(int digestLength, byte[] plaintext)
digestLength
- should be 20plaintext
- response from card, already 'decrypted' (using the
AA public key)public static byte[] getRawECDSASignature(byte[] signedData, int keySize) throws IOException
signedData
- signed datakeySize
- key sizeIOException
- on errorpublic static byte[] alignKeyDataToSize(byte[] keyData, int size)
public static byte[] i2os(BigInteger val, int length)
val
- positive integerlength
- lengthpublic static byte[] i2os(BigInteger val)
val
- positive integerpublic static BigInteger os2i(byte[] bytes)
bytes
- octet stringpublic static BigInteger os2i(byte[] bytes, int offset, int length)
bytes
- octet stringoffset
- offset of octet stringlength
- length of octet stringpublic static BigInteger os2fe(byte[] bytes, BigInteger p)
bytes
- octet stringp
- moduluspublic static byte[] publicKeyECPointToOS(ECPoint point)
0x04
(without a length).point
- public key pointpublic static String inferDigestAlgorithmFromSignatureAlgorithm(String signatureAlgorithm)
signatureAlgorithm
- a signature algorithmpublic static String inferDigestAlgorithmFromCipherAlgorithmForKeyDerivation(String cipherAlg, int keyLength)
public static DHParameterSpec toExplicitDHParameterSpec(org.bouncycastle.crypto.params.DHParameters params)
public static String getDetailedPublicKeyAlgorithm(PublicKey publicKey)
publicKey
- a public keypublic static String getCurveName(ECParameterSpec params)
params
- an specification of the curvepublic static ECParameterSpec toExplicitECParameterSpec(org.bouncycastle.jce.spec.ECNamedCurveParameterSpec parameterSpec)
public static ECParameterSpec toExplicitECParameterSpec(ECParameterSpec params)
params
- an EC parameter spec, possibly namedpublic static org.bouncycastle.jce.spec.ECNamedCurveSpec toECNamedCurveSpec(org.bouncycastle.jce.spec.ECNamedCurveParameterSpec namedParamSpec)
namedParamSpec
- a named EC parameter specpublic static org.bouncycastle.asn1.x509.SubjectPublicKeyInfo toSubjectPublicKeyInfo(PublicKey publicKey)
public static PublicKey toPublicKey(org.bouncycastle.asn1.x509.SubjectPublicKeyInfo subjectPublicKeyInfo)
public static PublicKey reconstructPublicKey(PublicKey publicKey)
publicKey
- the public keypublic static byte[] encodePublicKeyDataObject(String oid, PublicKey publicKey) throws InvalidKeyException
oid
- object identifierpublicKey
- public keyInvalidKeyException
- when public key is not DH or ECpublic static byte[] encodePublicKeyDataObject(String oid, PublicKey publicKey, boolean isContextKnown) throws InvalidKeyException
oid
- object identifierpublicKey
- public keyisContextKnown
- whether context of public key is known to receiver (we will not include domain parameters in that case).InvalidKeyException
- when public key is not DH or ECpublic static byte[] encodePublicKeyForSmartCard(PublicKey publicKey) throws InvalidKeyException
publicKey
- public keyInvalidKeyException
- if the key type is not EC or DHpublic static PublicKey decodePublicKeyFromSmartCard(byte[] encodedPublicKey, AlgorithmParameterSpec params)
public static String inferProtocolIdentifier(PublicKey publicKey)
publicKey
- a public keypublic static AlgorithmParameterSpec mapNonceGM(byte[] nonceS, byte[] sharedSecretH, AlgorithmParameterSpec params)
public static AlgorithmParameterSpec mapNonceIM(byte[] nonceS, byte[] nonceT, byte[] sharedSecretH, AlgorithmParameterSpec params)
public static ECPoint multiply(BigInteger s, ECPoint point, ECParameterSpec params)
public static BigInteger getPrime(AlgorithmParameterSpec params)
public static byte[] wrapDO(byte tag, byte[] data)
public static byte[] unwrapDO(byte expectedTag, byte[] wrappedData)
public static String inferKeyAgreementAlgorithm(PublicKey publicKey)
public static BigInteger computeAffineY(BigInteger affineX, ECParameterSpec params)
affineX
- the x coord of a point on the curveparams
- EC parameters for curve over Fppublic static boolean isValid(ECPoint ecPoint, ECParameterSpec params)
public static ECPoint normalize(ECPoint ecPoint, ECParameterSpec params)
Copyright © 2016. All rights reserved.