public class Crypto extends Object
| Modifier and Type | Class and Description |
|---|---|
static class |
Crypto.ECCKeyPair |
static class |
Crypto.RsaKeyPair |
| Constructor and Description |
|---|
Crypto() |
| Modifier and Type | Method and Description |
|---|---|
static byte[] |
asymEncrypt(TPMT_PUBLIC _pub,
byte[] data,
String encodingParms) |
static byte[] |
cfbEncrypt(boolean _encrypt,
TPM_ALG_ID _algId,
byte[] _key,
byte[] _iv,
byte[] _x) |
static Crypto.ECCKeyPair |
createECCKey(TPM_ECC_CURVE curveId,
TPM_ALG_ID alg) |
static Crypto.RsaKeyPair |
createRsaKey(int keySize,
int exponent) |
static org.bouncycastle.jce.interfaces.ECPublicKey |
decodeKey(byte[] encoded) |
static int |
digestSize(TPM_ALG_ID alg)
Return the size in bytes of a hash algorithm based on the TPM algId
|
static org.bouncycastle.crypto.Digest |
getDigest(TPM_ALG_ID alg)
Gets a Bouncy Castle Digest object that matches the TPM_ALG_ID hash algId
|
static TPM_ALG_ID |
getSigningHashAlg(TPMT_PUBLIC pub)
Extract the signing hash algorithm from various supported schemes
|
static byte[] |
hash(TPM_ALG_ID alg,
byte[] data)
Hash data
|
static byte[] |
hmac(TPM_ALG_ID alg,
byte[] key,
byte[] data)
hmac data
|
static byte[] |
KDFa(TPM_ALG_ID hmacHash,
byte[] hmacKey,
String label,
byte[] contextU,
byte[] contextV,
int numBitsRequired)
Perform the TPM key derivation procedure KDFa
|
static byte[] |
oaepEncrypt(TPMS_RSA_PARMS parms,
TPM2B_PUBLIC_KEY_RSA key,
byte[] data,
TPM_ALG_ID hashAlg,
String encodingLabel)
RSA encrypt using the OAEP encoding
|
static boolean |
validateQuote(TPMT_PUBLIC pubKey,
PCR_ReadResponse expectedPcrs,
byte[] nonce,
QuoteResponse quote)
Validate a TPM quote against a set of PCR and a nonce.
|
static boolean |
validateSignature(TPMT_PUBLIC _pubKey,
byte[] _dataThatWasSigned,
TPMU_SIGNATURE _signature)
Validate a TPM signature.
|
public static int digestSize(TPM_ALG_ID alg)
alg - The algorithmpublic static byte[] hash(TPM_ALG_ID alg, byte[] data)
alg - The hash algorithmdata - The data to hashpublic static byte[] hmac(TPM_ALG_ID alg, byte[] key, byte[] data)
alg - The hash algorithmkey - The HMAC keydata - The data to hashpublic static boolean validateSignature(TPMT_PUBLIC _pubKey, byte[] _dataThatWasSigned, TPMU_SIGNATURE _signature)
_pubKey - The TPM public key_dataThatWasSigned - The data that was hashed then signed_signature - The signature returned by the TPMpublic static boolean validateQuote(TPMT_PUBLIC pubKey, PCR_ReadResponse expectedPcrs, byte[] nonce, QuoteResponse quote)
pubKey - The public key to use to validate the QuoteexpectedPcrs - PCR values expectednonce - The noncequote - The TPM generated quotepublic static org.bouncycastle.jce.interfaces.ECPublicKey decodeKey(byte[] encoded)
throws InvalidKeySpecException,
NoSuchAlgorithmException,
NoSuchProviderException
public static org.bouncycastle.crypto.Digest getDigest(TPM_ALG_ID alg)
alg - The TPM hash algIdpublic static byte[] KDFa(TPM_ALG_ID hmacHash, byte[] hmacKey, String label, byte[] contextU, byte[] contextV, int numBitsRequired)
hmacHash - The underlying hash algorithmhmacKey - The HMAC key to use for key derivationlabel - The label value (note: the label is the zero-terminated UTC-encoded string)contextU - The first context valuecontextV - The second context valuenumBitsRequired - The number of bits to return (must be a whole number of bytes)public static byte[] oaepEncrypt(TPMS_RSA_PARMS parms, TPM2B_PUBLIC_KEY_RSA key, byte[] data, TPM_ALG_ID hashAlg, String encodingLabel)
parms - The encryption parameters to usekey - The public key to usedata - The data to encrypthashAlg - The hash algorithm to use in the OAEP encodingencodingLabel - The label to use (the label will be the zero-terminated UTC-encoded string)public static byte[] asymEncrypt(TPMT_PUBLIC _pub, byte[] data, String encodingParms)
public static TPM_ALG_ID getSigningHashAlg(TPMT_PUBLIC pub)
pub - The public area to examinepublic static byte[] cfbEncrypt(boolean _encrypt,
TPM_ALG_ID _algId,
byte[] _key,
byte[] _iv,
byte[] _x)
public static Crypto.RsaKeyPair createRsaKey(int keySize, int exponent)
public static Crypto.ECCKeyPair createECCKey(TPM_ECC_CURVE curveId, TPM_ALG_ID alg)
Copyright © 2017. All rights reserved.