Package anbxj
Class Crypto_Config
java.lang.Object
anbxj.Crypto_Config
An abstract class for encryption configuration.
-
Field Summary
FieldsModifier and TypeFieldDescriptionprotected StringThe asymmetric cipher scheme block.protected StringThe provider for signature algorithm.protected StringThe cipher scheme.protected StringThe provider for cipher scheme.protected intThe Diffie-Hellman random exponent size.protected StringThe Elliptic Curve.protected StringThe HMAC algorithm.protected intThe HMAC algorithm key size.protected StringThe provider for HMAC algorithm.protected StringThe key agreement algorithm.protected StringThe key pair generation for key agreement algorithm.protected StringThe provider for key agreement algorithm.protected StringThe key generation scheme.protected StringThe key generation scheme for password-based encryption (PBE).protected StringThe provider for PBE key generation.protected StringThe provider for key generation.protected ints The key generation size.protected StringThe key pair generation scheme.protected StringThe provider for key pair generation.protected intThe key pair generation size.protected intThe key size.Mapping of key algorithm names to cipher transformation strings.Mapping of asymmetric key algorithm names to signature algorithm names.protected StringThe message digest algorithm.protected StringThe provider for message digest algorithm.protected StringThe message digest algorithm.protected booleanFlag indicating whether multi-threaded execution is enabled.protected longIdle timeout in milliseconds for the multi-threaded server.protected intNonce length in bytes for protocol-level nonces and sequence numbers.protected intNumber of parallel clientsprotected longSleep interval in milliseconds between two consecutive parallel client sessions.protected StringThe secure random algorithm.protected StringThe provider for secure random algorithm.protected StringThe global security provider.protected longNumber of sessionsprotected StringThe provider for signature algorithm.protected StringThe SSL context.protected StringThe provider for ssl context.protected booleanThe protocol uses key exchangeprotected booleanThe protocol uses key a key storeprotected booleanWarmUp crypto engine flag -
Constructor Summary
ConstructorsConstructorDescriptionConstructs a Crypto_Config object with default values.Crypto_Config(String cipherScheme, int keySize, String keyGenerationScheme, String keyGenerationSchemePBE, int keyGenerationSize, String keyPairGenerationScheme, int keyPairGenerationSize, String secureRandomAlgorithm, int nonceSize, String hmacAlgorithm, int hmacKeySize, String messageDigestAlgorithm, String messageDigestSignatureAlgorithm, String keyAgreementAlgorithm, String keyAgreementKeyPairGenerationScheme, int dhModulusSize, String ecGenParameterSpec, String asymCipherSchemeBlock, String sslContext, String keyTypeToCipher, String keyTypeToSignature, String securityProvider) Constructs a Crypto_Config object with a global provider.Crypto_Config(String cipherScheme, int keySize, String keyGenerationScheme, String keyGenerationSchemePBE, int keyGenerationSize, String keyPairGenerationScheme, int keyPairGenerationSize, String secureRandomAlgorithm, int nonceSize, String hmacAlgorithm, int hmacKeySize, String messageDigestAlgorithm, String messageDigestSignatureAlgorithm, String keyAgreementAlgorithm, String keyAgreementKeyPairGenerationScheme, int dhModulusSize, String ecGenParameterSpec, String asymCipherSchemeBlock, String sslContext, String keyTypeToCipher, String keyTypeToSignature, String securityProvider, String cipherSchemeProvider, String keyGenerationSchemeProvider, String keyGenerationSchemePBEProvider, String keyPairGenerationSchemeProvider, String secureRandomProvider, String hmacProvider, String messageDigestProvider, String signatureProvider, String asymEncProvider, String keyAgreementProvider, String sslContextProvider) Constructs a Crypto_Config object with all the fine-grained providers.Crypto_Config(Properties configFile) Constructs a Crypto_Config object from the properties specified in the given configuration file. -
Method Summary
Modifier and TypeMethodDescriptionReturns the asymmetric cipher scheme block.Returns the provider for asymmetric encryption algorithm.Returns the asymmetric Key type to Cipher MapReturns the asymmetric Key type to Signature MapReturns the cipher scheme.Returns the provider for the cipher scheme.intReturns the Diffie-Hellman random exponent size.Returns the Elliptic Curve.Returns the HMAC algorithm.Returns the provider for HMAC algorithm.voidgetInfo()Prints debug information about the crypto configuration.Returns the key agreement algorithm.Returns the key pair generation scheme for key agreement algorithm.Returns the provider for key agreement algorithm.Returns the key generation scheme.Returns the provider for PBE key generation.Returns the provider for key generation.intReturns the key generation size.Returns the provider for key pair generation.Returns the key pair generation scheme.intReturns the key pair generation size.intReturns the key size.Returns the message digest algorithm.Returns the provider for message digest algorithm.Returns the message digest signature algorithm.longReturns the idle timeout (in milliseconds) for the multi-threaded server.intReturns the nonce length in bytes.intReturns the configured number of parallel clients.longReturns the sleep interval (in milliseconds) between two consecutive parallel client sessions.Returns the secure random algorithm.Returns the provider for secure random algorithm.Returns the global security provider.longReturns the number of sequential sessions to be executed.Returns the provider for signature algorithm.Returns the SSL context.Returns the provider for SSL context.booleanReturns whether the protocol uses key exchange (e.g., Diffie-Hellman).booleanReturns whether the protocol uses a key store (for asymmetric keys).booleanReturns whether multi-threaded execution is enabled.voidsetProtocolFeatures(boolean useWarmUp, boolean useKeyEx, boolean useKeyStore, long sessions, int parallelClients, long parellelClientsInterval, boolean multiThreaded, long multiThreadedTimeout) Configures the protocol usage parameters in one call.voidsetSessions(long sessions) Sets the number of sequential sessions to be executed.voidsetUseKeyEx(boolean useKeyEx) Sets whether the protocol uses key exchange (e.g., Diffie-Hellman).voidsetUseKeyStore(boolean useKeyStore) Sets whether the protocol uses a key store (for asymmetric keys).static booleanChecks if a string is not null and not empty.
-
Field Details
-
cipherScheme
The cipher scheme. -
keySize
protected int keySizeThe key size. -
keyGenerationScheme
The key generation scheme. -
keyGenerationSize
protected int keyGenerationSizes The key generation size. -
keyGenerationSchemePBE
The key generation scheme for password-based encryption (PBE). -
keyPairGenerationScheme
The key pair generation scheme. -
keyPairGenerationSize
protected int keyPairGenerationSizeThe key pair generation size. -
secureRandomAlgorithm
The secure random algorithm. -
nonceSize
protected int nonceSizeNonce length in bytes for protocol-level nonces and sequence numbers. -
hmacAlgorithm
The HMAC algorithm. -
hmacKeySize
protected int hmacKeySizeThe HMAC algorithm key size. -
messageDigestAlgorithm
The message digest algorithm. -
messageDigestSignatureAlgorithm
The message digest algorithm. -
keyAgreementAlgorithm
The key agreement algorithm. -
keyAgreementKeyPairGenerationScheme
The key pair generation for key agreement algorithm. -
dhModulusSize
protected int dhModulusSizeThe Diffie-Hellman random exponent size. -
ecGenParameterSpec
The Elliptic Curve. -
asymCipherSchemeBlock
The asymmetric cipher scheme block. -
sslContext
The SSL context. -
keyTypeToCipherMap
Mapping of key algorithm names to cipher transformation strings. This map is pre-populated with the default entries defined inCrypto_Config_Default.defaultKeyTypeToCipherMap. You can override or extend it via your configuration file (e.g. properties entry "keyTypeToCipher") to handle any custom or provider-specific cipher transformations per key type. -
keyTypeToSignatureMap
Mapping of asymmetric key algorithm names to signature algorithm names. This map is pre-populated with the default entries defined inCrypto_Config_Default.defaultKeyTypeToSignatureMap. You can override or extend it via your configuration file (e.g. properties entry "keyTypeToSignature") to handle any special or non-standard algorithm naming cases. -
securityProvider
The global security provider. -
cipherSchemeProvider
The provider for cipher scheme. -
keyGenerationSchemeProvider
The provider for key generation. -
keyGenerationSchemePBEProvider
The provider for PBE key generation. -
keyPairGenerationSchemeProvider
The provider for key pair generation. -
secureRandomProvider
The provider for secure random algorithm. -
hmacProvider
The provider for HMAC algorithm. -
messageDigestProvider
The provider for message digest algorithm. -
signatureProvider
The provider for signature algorithm. -
asymEncProvider
The provider for signature algorithm. -
keyAgreementProvider
The provider for key agreement algorithm. -
sslContextProvider
The provider for ssl context. -
useKeyEx
protected boolean useKeyExThe protocol uses key exchange -
useKeyStore
protected boolean useKeyStoreThe protocol uses key a key store -
sessions
protected long sessionsNumber of sessions -
parallelClients
protected int parallelClientsNumber of parallel clients -
multiThreadedTimeout
protected long multiThreadedTimeoutIdle timeout in milliseconds for the multi-threaded server. After this period of inactivity the server stops accepting new connections. Default value is 5000 (5 seconds). -
parellelClientsInterval
protected long parellelClientsIntervalSleep interval in milliseconds between two consecutive parallel client sessions. This delay is applied after each session to avoid overwhelming the system. Default value is 100. -
multiThreaded
protected boolean multiThreadedFlag indicating whether multi-threaded execution is enabled. When true the engine may start servers or parallel clients depending on the channel configuration. Default value is false. -
useWarmUp
protected boolean useWarmUpWarmUp crypto engine flag
-
-
Constructor Details
-
Crypto_Config
public Crypto_Config()Constructs a Crypto_Config object with default values. -
Crypto_Config
public Crypto_Config(String cipherScheme, int keySize, String keyGenerationScheme, String keyGenerationSchemePBE, int keyGenerationSize, String keyPairGenerationScheme, int keyPairGenerationSize, String secureRandomAlgorithm, int nonceSize, String hmacAlgorithm, int hmacKeySize, String messageDigestAlgorithm, String messageDigestSignatureAlgorithm, String keyAgreementAlgorithm, String keyAgreementKeyPairGenerationScheme, int dhModulusSize, String ecGenParameterSpec, String asymCipherSchemeBlock, String sslContext, String keyTypeToCipher, String keyTypeToSignature, String securityProvider) Constructs a Crypto_Config object with a global provider.- Parameters:
cipherScheme- The cipher scheme.keySize- The key size.keyGenerationScheme- The key generation scheme.keyGenerationSchemePBE- The key generation scheme for password-based encryption (PBE).keyGenerationSize- The key generation size.keyPairGenerationScheme- The key pair generation scheme.keyPairGenerationSize- The key pair generation size.secureRandomAlgorithm- The secure random algorithm.nonceSize- The nonce size in bytes.hmacAlgorithm- The HMAC algorithm.hmacKeySize- The HMAC algorithm key size.messageDigestAlgorithm- The message digest algorithm.messageDigestSignatureAlgorithm- The message digest algorithm for signature.keyAgreementAlgorithm- The key agreement algorithm.keyAgreementKeyPairGenerationScheme- The key pair generation scheme for key agreement algorithmdhModulusSize- The Diffie-Hellman random exponent size.ecGenParameterSpec- The elliptic curveasymCipherSchemeBlock- The asymmetric cipher scheme block.sslContext- The SSL context.keyTypeToCipher- The key type to cipher mapping.keyTypeToSignature- The key type to signature algorithm mapping.securityProvider- The security provider.
-
Crypto_Config
public Crypto_Config(String cipherScheme, int keySize, String keyGenerationScheme, String keyGenerationSchemePBE, int keyGenerationSize, String keyPairGenerationScheme, int keyPairGenerationSize, String secureRandomAlgorithm, int nonceSize, String hmacAlgorithm, int hmacKeySize, String messageDigestAlgorithm, String messageDigestSignatureAlgorithm, String keyAgreementAlgorithm, String keyAgreementKeyPairGenerationScheme, int dhModulusSize, String ecGenParameterSpec, String asymCipherSchemeBlock, String sslContext, String keyTypeToCipher, String keyTypeToSignature, String securityProvider, String cipherSchemeProvider, String keyGenerationSchemeProvider, String keyGenerationSchemePBEProvider, String keyPairGenerationSchemeProvider, String secureRandomProvider, String hmacProvider, String messageDigestProvider, String signatureProvider, String asymEncProvider, String keyAgreementProvider, String sslContextProvider) Constructs a Crypto_Config object with all the fine-grained providers.- Parameters:
cipherScheme- The cipher scheme.keySize- The key size.keyGenerationScheme- The key generation scheme.keyGenerationSchemePBE- The key generation scheme for password-based encryption (PBE).keyGenerationSize- The key generation size.keyPairGenerationScheme- The key pair generation scheme.keyPairGenerationSize- The key pair generation size.secureRandomAlgorithm- The secure random algorithm.nonceSize- The nonce size in bytes.hmacAlgorithm- The HMAC algorithm.hmacKeySize- The HMAC algorithm key size.messageDigestAlgorithm- The message digest algorithm.messageDigestSignatureAlgorithm- The message digest signature algorithm.keyAgreementAlgorithm- The key agreement algorithm.keyAgreementKeyPairGenerationScheme- The key pair generation scheme for key agreement algorithmdhModulusSize- The Diffie-Hellman random exponent size.ecGenParameterSpec- The elliptic curveasymCipherSchemeBlock- The asymmetric cipher scheme block.sslContext- The SSL context.keyTypeToCipher- The key type to cipher mapping.keyTypeToSignature- The key type to signature algorithm mapping.securityProvider- The global security provider.cipherSchemeProvider- The provider for cipher scheme.keyGenerationSchemeProvider- The provider for key generation.keyGenerationSchemePBEProvider- The provider for PBE key generation.keyPairGenerationSchemeProvider- The provider for key pair generation.secureRandomProvider- The provider for secure random algorithm.hmacProvider- The provider for HMAC algorithm.messageDigestProvider- The provider for message digest algorithm.signatureProvider- The provider for SignatureasymEncProvider- The provider for asymmetric encryption.keyAgreementProvider- The provider for key agreement algorithm.sslContextProvider- The provider for SSL context.
-
Crypto_Config
Constructs a Crypto_Config object from the properties specified in the given configuration file.- Parameters:
configFile- The properties configuration file.
-
-
Method Details
-
testStr
Checks if a string is not null and not empty.- Parameters:
str- The string to test.- Returns:
trueif the string is not null and not empty;falseotherwise.
-
getInfo
public void getInfo()Prints debug information about the crypto configuration. -
getCipherScheme
Returns the cipher scheme.- Returns:
- The cipher scheme.
-
getKeySize
public int getKeySize()Returns the key size.- Returns:
- The key size.
-
getKeyGenerationScheme
Returns the key generation scheme.- Returns:
- The key generation scheme.
-
getKeyGenerationSize
public int getKeyGenerationSize()Returns the key generation size.- Returns:
- The key generation size.
-
getKeyPairGenerationScheme
Returns the key pair generation scheme.- Returns:
- The key pair generation scheme.
-
getKeyPairGenerationSize
public int getKeyPairGenerationSize()Returns the key pair generation size.- Returns:
- The key pair generation size.
-
getSecureRandomAlgorithm
Returns the secure random algorithm.- Returns:
- The secure random algorithm.
-
getNonceSize
public int getNonceSize()Returns the nonce length in bytes.- Returns:
- the nonce size in bytes
-
getHmacAlgorithm
Returns the HMAC algorithm.- Returns:
- The HMAC algorithm.
-
getMessageDigestAlgorithm
Returns the message digest algorithm.- Returns:
- The message digest algorithm.
-
getMessageDigestSignatureAlgorithm
Returns the message digest signature algorithm.- Returns:
- The message digest signature algorithm.
-
getKeyAgreementAlgorithm
Returns the key agreement algorithm.- Returns:
- The key agreement algorithm.
-
getKeyAgreementKeyPairGenerationScheme
Returns the key pair generation scheme for key agreement algorithm.- Returns:
- The key pair generation scheme for key agreement algorithm.
-
getdhModulusSize
public int getdhModulusSize()Returns the Diffie-Hellman random exponent size.- Returns:
- The Diffie-Hellman random exponent size.
-
getEcGenParameterSpec
Returns the Elliptic Curve.- Returns:
- The Elliptic Curve
-
getAsymCipherSchemeBlock
Returns the asymmetric cipher scheme block.- Returns:
- The asymmetric cipher scheme block.
-
getSslContext
Returns the SSL context.- Returns:
- The SSL context.
-
getAsymKeyTypeToCipherMap
Returns the asymmetric Key type to Cipher Map- Returns:
- the asymmetric Key type to Cipher Map
-
getAsymKeyTypeToSignatureMap
Returns the asymmetric Key type to Signature Map- Returns:
- the asymmetric Key type to Signature Map
-
getSecurityProvider
Returns the global security provider.- Returns:
- The global security provider.
-
getCipherSchemeProvider
Returns the provider for the cipher scheme.- Returns:
- The provider for the cipher scheme.
-
getkeyGenerationSchemeProvider
Returns the provider for key generation.- Returns:
- The provider for key generation.
-
getkeyGenerationSchemePBEProvider
Returns the provider for PBE key generation.- Returns:
- The provider for PBE key generation.
-
getKeyPairGenerationProvider
Returns the provider for key pair generation.- Returns:
- The provider for key pair generation.
-
getSecureRandomProvider
Returns the provider for secure random algorithm.- Returns:
- The provider for secure random algorithm.
-
getHmacProvider
Returns the provider for HMAC algorithm.- Returns:
- The provider for HMAC algorithm.
-
getMessageDigestProvider
Returns the provider for message digest algorithm.- Returns:
- The provider for message digest algorithm.
-
getSignatureProvider
Returns the provider for signature algorithm.- Returns:
- The provider for signature algorithm.
-
getAsymEncProvider
Returns the provider for asymmetric encryption algorithm.- Returns:
- The provider for asymmetric encryption algorithm.
-
getKeyAgreementProvider
Returns the provider for key agreement algorithm.- Returns:
- The provider for key agreement algorithm.
-
getSslContextProvider
Returns the provider for SSL context.- Returns:
- The provider for SSL context.
-
setUseKeyEx
public void setUseKeyEx(boolean useKeyEx) Sets whether the protocol uses key exchange (e.g., Diffie-Hellman).- Parameters:
useKeyEx-trueif the protocol uses key exchange,falseotherwise
-
setUseKeyStore
public void setUseKeyStore(boolean useKeyStore) Sets whether the protocol uses a key store (for asymmetric keys).- Parameters:
useKeyStore-trueif the protocol uses a key store,falseotherwise
-
setSessions
public void setSessions(long sessions) Sets the number of sequential sessions to be executed.- Parameters:
sessions- the number of sessions (must be >= 1)
-
getUseKeyEx
public boolean getUseKeyEx()Returns whether the protocol uses key exchange (e.g., Diffie-Hellman).- Returns:
trueif the protocol uses key exchange,falseotherwise
-
getUseKeyStore
public boolean getUseKeyStore()Returns whether the protocol uses a key store (for asymmetric keys).- Returns:
trueif the protocol uses a key store,falseotherwise
-
getSessions
public long getSessions()Returns the number of sequential sessions to be executed.- Returns:
- the number of sessions
-
getParallelClients
public int getParallelClients()Returns the configured number of parallel clients.- Returns:
- the parallelClients
-
isMultiThreaded
public boolean isMultiThreaded()Returns whether multi-threaded execution is enabled.- Returns:
- the multiThreaded
-
getmultiThreadedTimeout
public long getmultiThreadedTimeout()Returns the idle timeout (in milliseconds) for the multi-threaded server.- Returns:
- the multiThreadedTimeout
-
getParellelClientsInterval
public long getParellelClientsInterval()Returns the sleep interval (in milliseconds) between two consecutive parallel client sessions.- Returns:
- the parellelClientsInterval
-
setProtocolFeatures
public void setProtocolFeatures(boolean useWarmUp, boolean useKeyEx, boolean useKeyStore, long sessions, int parallelClients, long parellelClientsInterval, boolean multiThreaded, long multiThreadedTimeout) Configures the protocol usage parameters in one call.- Parameters:
useWarmUp- true to enable cryptographic engine warm-up, false otherwiseuseKeyEx- true if the crypto engine uses key exchange, false otherwiseuseKeyStore- true if the protocol uses a key store (for asymmetric keys), false otherwisesessions- the number of sequential sessions to be executed (must be >= 1)parallelClients- the number of parallel client sessionsparellelClientsInterval- the sleep interval in milliseconds between two consecutive parallel client sessionsmultiThreaded- true to enable multi-threaded execution, false otherwisemultiThreadedTimeout- the idle timeout in milliseconds for the multi-threaded server
-