Package anbxj
Class AnB_Crypto_Wrapper
java.lang.Object
anbxj.AnB_Crypto_Wrapper
- Direct Known Subclasses:
AnB_Session
Cryptographic API: implements a class supporting cryptographic operations (a
wrapper for the cryptographic engine)
-
Field Summary
FieldsModifier and TypeFieldDescriptionprotected Crypto_EncryptionEngine
the cryptographic engineprotected final Crypto_KeyStoreType
the crypto store typeprotected AnBx_Agent
the identity of the agent -
Constructor Summary
ConstructorsConstructorDescriptionCreate a AnB_Crypto_Wrapper for a specified cryptographic engineCreate a AnB_Crypto_Wrapper for a specified key store setting mapAnB_Crypto_Wrapper
(Crypto_KeyStoreSettings_Map kssd, Crypto_Config config) Create a AnB_Crypto_Wrapper for a specified key store setting map and cryptographic configuration -
Method Summary
Modifier and TypeMethodDescriptionboolean
aliasExists
(String alias) Check is an agent's alias is stored in the key stores accessible to the cryptographic engineboolean
checkHmac
(Object object, Crypto_ByteArray hmac, SecretKey sk) Check a hmac value of a given object computed with the default hashing algorithm and a specified secret keyDecrypts a Crypto_SealedPair with the private key from the default key store associated to current agentdecrypt
(Crypto_SealedPair sc, Crypto_KeyPair kp) Decrypts a Crypto_SealedPair with the private key from a specified key pairDecrypts a Crypto_SealedPair with the private key from a specified key store associated to current agentdecrypt
(SealedObject so, SecretKey symmetricKey) Decrypts a SealedObject with a specified symmetric keyencrypt
(Object object, Crypto_KeyPair kp) Encrypts an object with the public key of a specified key pairEncrypts an object with a public key retrieved from the default key store associated to an user identified by an aliasencrypt
(Object object, String alias, Crypto_KeyStoreType pk) Encrypts an object with a public key retrieved from a specified key store associated to an user identified by an aliasEncrypts an object with a specified public keyEncrypts an object with a specified symmetric keyGenerates a HMAC secret keystatic void
getInfo()
Prints information about the cryptographic engine including supported algorithmsGenerates a key exchange key pair for the default key agreement algorithmgetKeyEx_PublicKey
(KeyPair keyPair) Retrieves the public key from a specified key exchange key pairgetKeyEx_SecretKey
(PublicKey publicKey, KeyPair keyPair) Retrieves the secret key from a specified key exchange key pair and associated public keyGenerates a key pair for the default public key algorithmRetrieve the default Crypto_KeyStoreSettings_Map for the current cryptographic engineprotected AnBx_Agent
Retrieve the identity of the current agentgetName()
Returns the agent name associated with this for the current AnB_Crypto_WrappergetNonce()
Generates a fresh noncegetPublicKey
(Crypto_KeyPair pair) Retrieves the public key from a specified key pairgetPublicKey
(String alias, Crypto_KeyStoreType kst) Retrieve a public key associated to an agent's alias for a specified Crypto_KeyStoreTypeprotected Certificate
getRemoteCertificate
(String alias, Crypto_KeyStoreType kst) Retrieve the certificate associated to an agent's alias for a specified Crypto_KeyStoreTypeprotected Map
<Crypto_KeyStoreType, Certificate> getRemoteCertificates
(String alias) Retrieve the certificates associated to an agent's aliasGenerates a sequence numberGenerates a symmetric keygetSymmetricKeyPBE
(String password, String salt) Generates a symmetric key for Password Based Encryption (PBE)Generates a time stampstatic boolean
Checks whether logging is currently enabled.makeDigest
(Object object) Computes the hash of a given object with the default hashing algorithmComputes the hmac of a given object with the default hashing algorithm and a specified secret keystatic Object
readObject
(String filename) Writes a serialised object from the file systemprotected Object
Receive an object from a channelprotected AnBx_Agent
Receive the identity of an agent from a channelprotected void
Send
(Object obj, Channel_Abstraction c) Send an object over a channelprotected void
Send_Id
(AnBx_Agent id, Channel_Abstraction c) Send the identity of an agent over a channelstatic void
setLoggingExecTimeEnabled
(boolean enabled) Sets the logging state for performance measurements.protected void
Set the identity of the current agentvoid
Setup a AnB_Crypto_Wrapper for a specified key store setting mapvoid
Setup
(Crypto_KeyStoreSettings_Map kssd, Crypto_Config config) Setup a AnB_Crypto_Wrapper for a specified key store setting map and cryptographic configurationSigns an object with the private key of the current agent retrieved from the default key storesign
(Object object, Crypto_KeyPair kp) Signs an object with a private key retrieved from the specified key pairsign
(Object object, Crypto_KeyStoreType sk) Signs an object with the private key of the current agent retrieved from a specified key storeverify
(SignedObject so, String alias) Verifies a SignedObject with a private key retrieved from the default key store associated to an agent identified by an aliasverify
(SignedObject so, String alias, Crypto_KeyStoreType sk) Verifies a SignedObject with a private key retrieved from a specified key store associated to an agent identified by an aliasverify
(SignedObject so, PublicKey pk) Verifies a SignedObject with a specified public keystatic void
writeObject
(Object object, String filename) Writes a serialised object to the file systemxor
(Crypto_ByteArray x1, Crypto_ByteArray x2) Computes the xor of two Crypto_ByteArrays
-
Field Details
-
ee
the cryptographic engine -
me
the identity of the agent -
ident_ks
the crypto store type
-
-
Constructor Details
-
AnB_Crypto_Wrapper
Create a AnB_Crypto_Wrapper for a specified cryptographic engine- Parameters:
ee
- the specified cryptographic engine- See Also:
-
AnB_Crypto_Wrapper
Create a AnB_Crypto_Wrapper for a specified key store setting map- Parameters:
kssd
- the specified key store setting map- See Also:
-
AnB_Crypto_Wrapper
Create a AnB_Crypto_Wrapper for a specified key store setting map and cryptographic configuration- Parameters:
kssd
- the specified key store setting mapconfig
- the specified cryptographic configuration- See Also:
-
-
Method Details
-
setLoggingExecTimeEnabled
public static void setLoggingExecTimeEnabled(boolean enabled) Sets the logging state for performance measurements.- Parameters:
enabled
-true
to enable logging,false
to disable logging.
-
isLoggingExecTimeEnabled
public static boolean isLoggingExecTimeEnabled()Checks whether logging is currently enabled.- Returns:
true
if logging is enabled,false
otherwise.
-
getInfo
public static void getInfo()Prints information about the cryptographic engine including supported algorithms- See Also:
-
Setup
Setup a AnB_Crypto_Wrapper for a specified key store setting map- Parameters:
kssd
- the specified key store setting map
-
Setup
Setup a AnB_Crypto_Wrapper for a specified key store setting map and cryptographic configuration- Parameters:
kssd
- the specified key store setting mapconfig
- the specified cryptographic configuration- See Also:
-
getKeyStoreSettings_Map
Retrieve the default Crypto_KeyStoreSettings_Map for the current cryptographic engine- Returns:
- the Crypto_KeyStoreSettings_Map
- See Also:
-
getName
Returns the agent name associated with this for the current AnB_Crypto_Wrapper- Returns:
- the agent's name
-
aliasExists
Check is an agent's alias is stored in the key stores accessible to the cryptographic engine- Parameters:
alias
- the agent's alias- Returns:
- true if the agent's alias exists
-
getPublicKey
Retrieve a public key associated to an agent's alias for a specified Crypto_KeyStoreType- Parameters:
alias
- the agent's aliaskst
- the crypto key store type- Returns:
- the public key
-
getRemoteCertificate
Retrieve the certificate associated to an agent's alias for a specified Crypto_KeyStoreType- Parameters:
alias
- the agent's aliaskst
- the crypto key store type- Returns:
- the certificate
-
getRemoteCertificates
Retrieve the certificates associated to an agent's alias- Parameters:
alias
- the agent's alias- Returns:
- the certificates
-
getMyIdentity
Retrieve the identity of the current agent- Returns:
- the identity
-
setMyIdentity
protected void setMyIdentity()Set the identity of the current agent -
Send
Send an object over a channel- Parameters:
obj
- the objectc
- the channel abstraction
-
Receive
Receive an object from a channel- Parameters:
c
- the channel abstraction- Returns:
- the object
-
Send_Id
Send the identity of an agent over a channel- Parameters:
id
- the agent idc
- the channel abstraction
-
Receive_RemoteId
Receive the identity of an agent from a channel- Parameters:
c
- the channel abstraction- Returns:
- the agent identity
-
encrypt
Encrypts an object with a public key retrieved from the default key store associated to an user identified by an alias- Parameters:
object
- the object to encryptalias
- the identifier of the agent- Returns:
- the encrypted object as Crypto_SealedPair
- See Also:
-
encrypt
Encrypts an object with a public key retrieved from a specified key store associated to an user identified by an alias- Parameters:
object
- the object to encryptalias
- the identifier of the agentpk
- the specified key store- Returns:
- the encrypted object as Crypto_SealedPair
- See Also:
-
encrypt
Encrypts an object with the public key of a specified key pair- Parameters:
object
- the object to encryptkp
- the specified key pair- Returns:
- the encrypted object as Crypto_SealedPair
- See Also:
-
encrypt
Encrypts an object with a specified public key- Parameters:
object
- the object to encryptpublicKey
- the specified public key- Returns:
- the encrypted object as Crypto_SealedPair
- See Also:
-
decrypt
Decrypts a Crypto_SealedPair with the private key from the default key store associated to current agent- Parameters:
sc
- the Crypto_SealedPair to decrypt- Returns:
- the decrypted object
- See Also:
-
decrypt
Decrypts a Crypto_SealedPair with the private key from a specified key store associated to current agent- Parameters:
sc
- the Crypto_SealedPair to decryptpk
- the specified key store- Returns:
- the decrypted object
- See Also:
-
decrypt
Decrypts a Crypto_SealedPair with the private key from a specified key pair- Parameters:
sc
- the Crypto_SealedPair to decryptkp
- the specified key pair- Returns:
- the decrypted object
- See Also:
-
encrypt
Encrypts an object with a specified symmetric key- Parameters:
object
- the object to encryptsymmetricKey
- the specified symmetric key- Returns:
- the encrypted object as SealedObject
-
decrypt
Decrypts a SealedObject with a specified symmetric key- Parameters:
so
- the SealedObject to encryptsymmetricKey
- the specified symmetric key- Returns:
- the encrypted object as SealedObject
-
sign
Signs an object with the private key of the current agent retrieved from the default key store- Parameters:
object
- the object to sign- Returns:
- the signed object as SignedObject
-
sign
Signs an object with the private key of the current agent retrieved from a specified key store- Parameters:
object
- the object to signsk
- the specified key store- Returns:
- the signed object as SignedObject
- See Also:
-
sign
Signs an object with a private key retrieved from the specified key pair- Parameters:
object
- the object to signkp
- the specified key pair- Returns:
- the signed object as SignedObject
- See Also:
-
verify
Verifies a SignedObject with a private key retrieved from the default key store associated to an agent identified by an alias- Parameters:
so
- the SignedObject to verifyalias
- the identifier of the agent- Returns:
- the verified object
- See Also:
-
verify
Verifies a SignedObject with a private key retrieved from a specified key store associated to an agent identified by an alias- Parameters:
so
- the SignedObject to verifyalias
- the identifier of the agentsk
- the specified key store- Returns:
- the verified object
- See Also:
-
verify
Verifies a SignedObject with a specified public key- Parameters:
so
- the SignedObject to verifypk
- the specified public key- Returns:
- the verified object
-
getNonce
Generates a fresh nonce- Returns:
- the fresh nonce
-
getSeqNumber
Generates a sequence number- Returns:
- the sequence number
-
getSymmetricKey
Generates a symmetric key- Returns:
- the symmetric key
-
getHmacKey
Generates a HMAC secret key- Returns:
- the HMAC secret key
-
getTimeStamp
Generates a time stamp- Returns:
- the time stamp
-
getSymmetricKeyPBE
Generates a symmetric key for Password Based Encryption (PBE)- Parameters:
password
- the passwordsalt
- the salting argument- Returns:
- the symmetric key
-
getKeyEx_KeyPair
Generates a key exchange key pair for the default key agreement algorithm- Returns:
- the key exchange key pair
-
getKeyEx_PublicKey
Retrieves the public key from a specified key exchange key pair- Parameters:
keyPair
- the specified key pair- Returns:
- the key pair
-
getKeyEx_SecretKey
Retrieves the secret key from a specified key exchange key pair and associated public key- Parameters:
publicKey
- the associated public keykeyPair
- the specified key pair- Returns:
- the (symmetric) secret key
-
getKeyPair
Generates a key pair for the default public key algorithm- Returns:
- the key pair
- See Also:
-
getPublicKey
Retrieves the public key from a specified key pair- Parameters:
pair
- the specified key pair- Returns:
- the public key
- See Also:
-
makeDigest
Computes the hash of a given object with the default hashing algorithm- Parameters:
object
- the given object- Returns:
- the hash value as Crypto_ByteArray
-
makeHmac
Computes the hmac of a given object with the default hashing algorithm and a specified secret key- Parameters:
object
- the given objectsk
- the secret key- Returns:
- the hmac value as Crypto_ByteArray
- See Also:
-
checkHmac
Check a hmac value of a given object computed with the default hashing algorithm and a specified secret key- Parameters:
object
- the given objecthmac
- the hmac valuesk
- the secret key- Returns:
- the hmac value as Crypto_ByteArray
- See Also:
-
xor
Computes the xor of two Crypto_ByteArrays- Parameters:
x1
- the first Crypto_ByteArray argumentx2
- the second Crypto_ByteArray argument- Returns:
- the computed xor value
- See Also:
-
writeObject
Writes a serialised object to the file system- Parameters:
object
- the given objectfilename
- the specified destination file
-
readObject
Writes a serialised object from the file system- Parameters:
filename
- the specified source file- Returns:
- the retrieved object
-