Package com.dyadicsec.advapi
Class SDEKey
java.lang.Object
com.dyadicsec.advapi.SDEKey
public final class SDEKey
extends java.lang.Object
This class includes the methods for application level encryption, see Application-Level Encryption in the UKC Developers Guide for more information.
-
Field Summary
Fields Modifier and Type Field Description static int
PURPOSE_CREDIT_CARD_ENC
Use this session key purpose for credit card number format preserving encryptionstatic int
PURPOSE_EMAIL_ENC
Use this session key purpose for email format preserving encryptionstatic int
PURPOSE_ONE_WAY
Use this session key purpose for one way encryption (PRF)static int
PURPOSE_OP_ENC
Use this session key purpose for order preserving encryptionstatic int
PURPOSE_SP_ENC
Use this session key purpose for generic type preserving encryption (besides String)static int
PURPOSE_SSN_ENC
Use this session key purpose for SSN format preserving encryptionstatic int
PURPOSE_STRING_ENC
Use this session key purpose for String format preserving encryption (type and size)static int
PURPOSE_US_PHONE_ENC
Use this session key purpose for US phone format preserving encryption -
Method Summary
Modifier and Type Method Description byte[]
decrypt(byte[] aad, byte[] in)
Generic decryption function, implements strong AES-GCM none-deterministic encryption and also takes care of key versioning by appending key UID to the cipher text.java.lang.String
decryptCreditCard(java.lang.String tweak, java.lang.String in)
Decrypt a credit card number, where the encrypted value is also a credit card numberjava.lang.String
decryptCreditCard(java.lang.String tweak, java.lang.String in, java.lang.String format)
Decrypt a credit card number, where the encrypted value is also a credit card numberjava.lang.String
decryptEMailAddress(java.lang.String tweak, java.lang.String in)
Decrypt an encrypted email address, where the encrypted value is also an email address.int
decryptOrderPreserving(java.lang.String tweak, long encData)
Decrypt an integer value encrypted with order preserving encryptionjava.lang.String
decryptOrderPreserving(java.lang.String tweak, java.lang.String encDataStr)
Decrypt a string value encrypted with order preserving encryptionjava.sql.Timestamp
decryptOrderPreservingTS(java.lang.String tweak, java.lang.String encDataStr)
Decrypt a Timestamp value encrypted with order preserving encryptionjava.lang.String
decryptSSN(java.lang.String tweak, java.lang.String in, java.lang.String format)
Decrypt an encrypted SSN, where the encrypted value is also SSNboolean
decryptTypePreserving(java.lang.String tweak, boolean encData)
Decrypt an encryptyed boolean valuebyte[]
decryptTypePreserving(java.lang.String tweak, byte[] encData)
Decrypt a byte arraydouble
decryptTypePreserving(java.lang.String tweak, double encData)
Decrypt an encryptyed double valuefloat
decryptTypePreserving(java.lang.String tweak, float encData)
Decrypt an encryptyed float valueint
decryptTypePreserving(java.lang.String tweak, int encData)
Decrypt an encryptyed integer valuelong
decryptTypePreserving(java.lang.String tweak, long encData)
Decrypt an encryptyed long valueshort
decryptTypePreserving(java.lang.String tweak, short encData)
Decrypt an encryptyed short valuejava.lang.String
decryptTypePreserving(java.lang.String tweak, java.lang.String encData)
Decrypt an encryptyed string valuejava.math.BigDecimal
decryptTypePreserving(java.lang.String tweak, java.math.BigDecimal encData)
Decrypt an encryptyed BigDecimal valuejava.sql.Blob
decryptTypePreserving(java.lang.String tweak, java.sql.Blob encData)
Decrypt an encryptyed Blob valuejava.sql.Clob
decryptTypePreserving(java.lang.String tweak, java.sql.Clob encData)
Decrypt an encryptyed Clob valuejava.sql.Date
decryptTypePreserving(java.lang.String tweak, java.sql.Date encData)
Decrypt an encryptyed Date valuejava.sql.Time
decryptTypePreserving(java.lang.String tweak, java.sql.Time encData)
Decrypt an encryptyed Time valuejava.sql.Timestamp
decryptTypePreserving(java.lang.String tweak, java.sql.Timestamp encData)
Decrypt an encryptyed Timestamp valuejava.lang.String
decryptUSPhone(java.lang.String tweak, java.lang.String in, java.lang.String format)
Decrypt an encrypted US phone number, where the encrypted value is also a US phone numbervoid
destroy()
byte[]
encrypt(byte[] aad, byte[] in)
Generic encryption function, implements strong AES-GCM none-deterministic encryption and also takes care of key versioning by appending key UID to the cipher text.java.lang.String
encryptCreditCard(java.lang.String tweak, java.lang.String in)
Encrypt a credit card number in format preserving form, where the encrypted value is also a legitimate credit card number.java.lang.String
encryptCreditCard(java.lang.String tweak, java.lang.String in, java.lang.String format)
Encrypt a credit card number in format preserving form, where the encrypted value is also a legitimate credit card number.java.lang.String
encryptEMailAddress(java.lang.String tweak, java.lang.String in, int maxSize)
Encrypt an email address in format preserving form, where the encrypted value is also a legitimate email address.
It can contain these characters: A-Z, a-z, 0-9, .!#$%&*+-/={|}~(),:;<>[]
It must contain an @ as a separator and cannot contain spaces.long
encryptOrderPreserving(java.lang.String tweak, int data)
Encrypt an integer value in order preserving form, encrypted value is of type longlong
encryptOrderPreserving(java.lang.String tweak, short data)
Encrypt a short value in order preserving form, where the return value is of type longjava.lang.String
encryptOrderPreserving(java.lang.String tweak, java.lang.String data, int size)
Encrypt a string value in order preserving formjava.lang.String
encryptOrderPreserving(java.lang.String tweak, java.sql.Timestamp data)
Encrypt a Timestamp value in order preserving form, encrypted value is of string typebyte[]
encryptPRF(java.lang.String tweak, byte[] data)
Creates a unique searchable token from a byte arrayjava.lang.String
encryptSSN(java.lang.String tweak, java.lang.String in, java.lang.String format)
Encrypt an SSN in format preserving form, where the encrypted value is also a legitimate SSN.
The SSN can be all numbers except:
- Numbers with all zeros in any digit group (000-##-####, ###-00-####, ###-##-0000).
- Numbers with 666 or 900-999 (Individual Taxpayer Identification Number) in the first digit group.boolean
encryptTypePreserving(java.lang.String tweak, boolean data)
Encrypt a boolean valuebyte[]
encryptTypePreserving(java.lang.String tweak, byte[] data)
Encrypt a byte arraydouble
encryptTypePreserving(java.lang.String tweak, double data)
Encrypt a double valuefloat
encryptTypePreserving(java.lang.String tweak, float data)
Encrypt a float valueint
encryptTypePreserving(java.lang.String tweak, int data)
Encrypt a integer valuelong
encryptTypePreserving(java.lang.String tweak, long data)
Encrypt a long valueshort
encryptTypePreserving(java.lang.String tweak, short data)
Encrypt a short valuejava.lang.String
encryptTypePreserving(java.lang.String tweak, java.lang.String data)
Encrypt a string valuejava.math.BigDecimal
encryptTypePreserving(java.lang.String tweak, java.math.BigDecimal data)
Encrypt a BigDecimal valuejava.sql.Blob
encryptTypePreserving(java.lang.String tweak, java.sql.Blob data)
Encrypt a Blob valuejava.sql.Clob
encryptTypePreserving(java.lang.String tweak, java.sql.Clob data)
Encrypt a Clob valuejava.sql.Date
encryptTypePreserving(java.lang.String tweak, java.sql.Date data)
Encrypt a Date valuejava.sql.Time
encryptTypePreserving(java.lang.String tweak, java.sql.Time data)
Encrypt a Time valuejava.sql.Timestamp
encryptTypePreserving(java.lang.String tweak, java.sql.Timestamp data)
Encrypt a Timestamp valuejava.lang.String
encryptUSPhone(java.lang.String tweak, java.lang.String in, java.lang.String format)
Encrypt a US phone in format preserving form, where the encrypted value is also a legitimate US phone number.
The number is 10 digits.protected void
finalize()
static SDEKey
findKey(long uid)
Find an application level encryption key, located by its UIDstatic SDEKey
findKey(java.lang.String name)
Find an application level encryption key, located by its namestatic SDEKey
findKey(java.lang.String slotName, long uid)
Find an application level encryption key in a specific EKM partition.static SDEKey
findKey(java.lang.String slotName, java.lang.String name)
Find an application level encryption key in a specific EKM partition.static SDEKey
generate(com.unbound.client.Partition partition, java.lang.String keyName)
SDESessionKey
generateSessionKey(int purpose, java.lang.String tweak)
Generate a session key which can be used for multiple encryption operations Use the proper purpose per the values and encryption modes which you will use this key withSDEKey
getPreviousKey()
Return the previous key used for encryption in case Re-Key was usedlong
getUID()
Get the unique identifier of a key, can be used in future time to decrypt with a specific key versionMethods inherited from class java.lang.Object
clone, equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
-
Field Details
-
PURPOSE_ONE_WAY
public static final int PURPOSE_ONE_WAYUse this session key purpose for one way encryption (PRF)- See Also:
- Constant Field Values
-
PURPOSE_SP_ENC
public static final int PURPOSE_SP_ENCUse this session key purpose for generic type preserving encryption (besides String)- See Also:
- Constant Field Values
-
PURPOSE_OP_ENC
public static final int PURPOSE_OP_ENCUse this session key purpose for order preserving encryption- See Also:
- Constant Field Values
-
PURPOSE_EMAIL_ENC
public static final int PURPOSE_EMAIL_ENCUse this session key purpose for email format preserving encryption- See Also:
- Constant Field Values
-
PURPOSE_CREDIT_CARD_ENC
public static final int PURPOSE_CREDIT_CARD_ENCUse this session key purpose for credit card number format preserving encryption- See Also:
- Constant Field Values
-
PURPOSE_US_PHONE_ENC
public static final int PURPOSE_US_PHONE_ENCUse this session key purpose for US phone format preserving encryption- See Also:
- Constant Field Values
-
PURPOSE_SSN_ENC
public static final int PURPOSE_SSN_ENCUse this session key purpose for SSN format preserving encryption- See Also:
- Constant Field Values
-
PURPOSE_STRING_ENC
public static final int PURPOSE_STRING_ENCUse this session key purpose for String format preserving encryption (type and size)- See Also:
- Constant Field Values
-
-
Method Details
-
destroy
public void destroy() -
generate
-
finalize
protected void finalize() throws java.lang.Throwable- Overrides:
finalize
in classjava.lang.Object
- Throws:
java.lang.Throwable
-
findKey
Find an application level encryption key, located by its name- Parameters:
name
- The key name- Returns:
- The key handle or null if the key is not found
-
findKey
Find an application level encryption key in a specific EKM partition. The key is located based on its name- Parameters:
slotName
- The partition namename
- The key name- Returns:
- The key handle or null if the key is not found
-
getUID
public long getUID()Get the unique identifier of a key, can be used in future time to decrypt with a specific key version- Returns:
- The unique ID of the key
-
getPreviousKey
Return the previous key used for encryption in case Re-Key was used- Returns:
- The previous key handle or null if no previous key exists
-
findKey
Find an application level encryption key, located by its UID- Parameters:
uid
- The key UID- Returns:
- The key handle or null if the key is not found
-
findKey
Find an application level encryption key in a specific EKM partition. The key is located based on its UID- Parameters:
slotName
- The partition nameuid
- The key UID- Returns:
- The key handle or null if the key is not found
-
encrypt
public byte[] encrypt(byte[] aad, byte[] in) throws java.lang.SecurityExceptionGeneric encryption function, implements strong AES-GCM none-deterministic encryption and also takes care of key versioning by appending key UID to the cipher text. This encryption mode is not size preserving- Parameters:
aad
- Additional Authentication Data, can be used to further authenticate the cipher text, see reference at https://en.wikipedia.org/wiki/Galois/Counter_Modein
- The data to encrypt- Returns:
- Encrypted cipher text
- Throws:
java.lang.SecurityException
- In case of operation error
-
decrypt
public byte[] decrypt(byte[] aad, byte[] in) throws java.lang.SecurityExceptionGeneric decryption function, implements strong AES-GCM none-deterministic encryption and also takes care of key versioning by appending key UID to the cipher text. This encryption mode is not size preserving- Parameters:
aad
- Additional Authentication Data, can be used to further authenticate the cipher text, see reference at https://en.wikipedia.org/wiki/Galois/Counter_Modein
- The data to encrypt- Returns:
- Encrypted cipher text
- Throws:
java.lang.SecurityException
- In case of operation error
-
generateSessionKey
public SDESessionKey generateSessionKey(int purpose, java.lang.String tweak) throws java.lang.SecurityExceptionGenerate a session key which can be used for multiple encryption operations Use the proper purpose per the values and encryption modes which you will use this key with- Parameters:
purpose
- Determines the type and mode of encryption to be used with this session keytweak
- The tweak associated with this session key- Returns:
- The derived session key
- Throws:
java.lang.SecurityException
- In case of operation error
-
encryptPRF
public byte[] encryptPRF(java.lang.String tweak, byte[] data) throws java.lang.SecurityExceptionCreates a unique searchable token from a byte array- Parameters:
tweak
- The tweak used for the processdata
- The input data- Returns:
- Searchable token of size 16 bytes
- Throws:
java.lang.SecurityException
- In case of encryption error
-
encryptTypePreserving
public byte[] encryptTypePreserving(java.lang.String tweak, byte[] data) throws java.lang.SecurityException, java.lang.IllegalArgumentExceptionEncrypt a byte array- Parameters:
tweak
- The tweak used for the encryptiondata
- The data to encrypt, where the length of the array should be even or at least 16 bytes- Returns:
- The encrypted value, where the size of the encrypted data equals to the size of the input
- Throws:
java.lang.SecurityException
- In case of encryption errorjava.lang.IllegalArgumentException
- In case data length is odd and length is smaller than 16
-
decryptTypePreserving
public byte[] decryptTypePreserving(java.lang.String tweak, byte[] encData) throws java.lang.SecurityException, java.lang.IllegalArgumentExceptionDecrypt a byte array- Parameters:
tweak
- The tweak used for encryptionencData
- The encrypted data- Returns:
- Decrryped byte array
- Throws:
java.lang.SecurityException
- In case of decryption errorjava.lang.IllegalArgumentException
-
encryptTypePreserving
public java.lang.String encryptTypePreserving(java.lang.String tweak, java.lang.String data) throws java.lang.SecurityExceptionEncrypt a string value- Parameters:
tweak
- The tweak used for the encryptiondata
- The data to encrypt- Returns:
- Encrypted value
- Throws:
java.lang.SecurityException
- In case of encryption error
-
decryptTypePreserving
public java.lang.String decryptTypePreserving(java.lang.String tweak, java.lang.String encData) throws java.lang.SecurityExceptionDecrypt an encryptyed string value- Parameters:
tweak
- The tweak used for the processencData
- The encrypted value- Returns:
- String value in plain
- Throws:
java.lang.SecurityException
- In case of decryption error
-
encryptOrderPreserving
public java.lang.String encryptOrderPreserving(java.lang.String tweak, java.lang.String data, int size) throws java.lang.SecurityExceptionEncrypt a string value in order preserving form- Parameters:
tweak
- The tweak used for the encryptiondata
- The data to encryptsize
- Maximum size of values that should be compared with this value- Returns:
- Encrypted value
- Throws:
java.lang.SecurityException
- In case of encryption error
-
decryptOrderPreserving
public java.lang.String decryptOrderPreserving(java.lang.String tweak, java.lang.String encDataStr) throws java.lang.SecurityExceptionDecrypt a string value encrypted with order preserving encryption- Parameters:
tweak
- The tweak used for the decryptionencDataStr
- The encrypted value- Returns:
- String value in plain
- Throws:
java.lang.SecurityException
- In case of decryption error
-
encryptTypePreserving
public long encryptTypePreserving(java.lang.String tweak, long data) throws java.lang.SecurityExceptionEncrypt a long value- Parameters:
tweak
- The tweak used for the encryptiondata
- The data to encrypt- Returns:
- Encrypted value
- Throws:
java.lang.SecurityException
- In case of encryption error
-
decryptTypePreserving
public long decryptTypePreserving(java.lang.String tweak, long encData) throws java.lang.SecurityExceptionDecrypt an encryptyed long value- Parameters:
tweak
- The tweak used for the processencData
- The encrypted value- Returns:
- long value in plain
- Throws:
java.lang.SecurityException
- In case of decryption error
-
encryptTypePreserving
public int encryptTypePreserving(java.lang.String tweak, int data) throws java.lang.SecurityExceptionEncrypt a integer value- Parameters:
tweak
- The tweak used for the encryptiondata
- The data to encrypt- Returns:
- Encrypted value
- Throws:
java.lang.SecurityException
- In case of encryption error
-
decryptTypePreserving
public int decryptTypePreserving(java.lang.String tweak, int encData) throws java.lang.SecurityExceptionDecrypt an encryptyed integer value- Parameters:
tweak
- The tweak used for the processencData
- The encrypted value- Returns:
- long value in plain
- Throws:
java.lang.SecurityException
- In case of decryption error
-
encryptOrderPreserving
public long encryptOrderPreserving(java.lang.String tweak, int data) throws java.lang.SecurityExceptionEncrypt an integer value in order preserving form, encrypted value is of type long- Parameters:
tweak
- The tweak used for the encryptiondata
- The data to encrypt- Returns:
- Encrypted value
- Throws:
java.lang.SecurityException
- In case of encryption error
-
decryptOrderPreserving
public int decryptOrderPreserving(java.lang.String tweak, long encData) throws java.lang.SecurityExceptionDecrypt an integer value encrypted with order preserving encryption- Parameters:
tweak
- The tweak used for the decryptionencData
- The encrypted value- Returns:
- Integer value in plain
- Throws:
java.lang.SecurityException
- In case of decryption error
-
encryptTypePreserving
public short encryptTypePreserving(java.lang.String tweak, short data) throws java.lang.SecurityExceptionEncrypt a short value- Parameters:
tweak
- The tweak used for the encryptiondata
- The data to encrypt- Returns:
- Encrypted value
- Throws:
java.lang.SecurityException
- In case of encryption error
-
decryptTypePreserving
public short decryptTypePreserving(java.lang.String tweak, short encData) throws java.lang.SecurityExceptionDecrypt an encryptyed short value- Parameters:
tweak
- The tweak used for the processencData
- The encrypted value- Returns:
- String value in plain
- Throws:
java.lang.SecurityException
- In case of decryption error
-
encryptOrderPreserving
public long encryptOrderPreserving(java.lang.String tweak, short data) throws java.lang.SecurityExceptionEncrypt a short value in order preserving form, where the return value is of type long- Parameters:
tweak
- The tweak used for the encryptiondata
- The value to encrypt- Returns:
- Encrypted value
- Throws:
java.lang.SecurityException
- In case of encryption error
-
encryptTypePreserving
public float encryptTypePreserving(java.lang.String tweak, float data) throws java.lang.SecurityExceptionEncrypt a float value- Parameters:
tweak
- The tweak used for the encryptiondata
- The value to encrypt- Returns:
- Encrypted value
- Throws:
java.lang.SecurityException
- In case of encryption error
-
decryptTypePreserving
public float decryptTypePreserving(java.lang.String tweak, float encData) throws java.lang.SecurityExceptionDecrypt an encryptyed float value- Parameters:
tweak
- The tweak used for the processencData
- The encrypted value- Returns:
- Float value in plain
- Throws:
java.lang.SecurityException
- In case of decryption error
-
encryptTypePreserving
public double encryptTypePreserving(java.lang.String tweak, double data) throws java.lang.SecurityExceptionEncrypt a double value- Parameters:
tweak
- The tweak used for the encryptiondata
- The value to encrypt- Returns:
- Encrypted value
- Throws:
java.lang.SecurityException
- In case of encryption error
-
decryptTypePreserving
public double decryptTypePreserving(java.lang.String tweak, double encData) throws java.lang.SecurityExceptionDecrypt an encryptyed double value- Parameters:
tweak
- The tweak used for the processencData
- The encrypted value- Returns:
- Double value in plain
- Throws:
java.lang.SecurityException
- In case of decryption error
-
encryptTypePreserving
public java.sql.Date encryptTypePreserving(java.lang.String tweak, java.sql.Date data) throws java.lang.SecurityExceptionEncrypt a Date value- Parameters:
tweak
- The tweak used for the encryptiondata
- The data to encrypt- Returns:
- Encrypted value
- Throws:
java.lang.SecurityException
- In case of encryption error
-
decryptTypePreserving
public java.sql.Date decryptTypePreserving(java.lang.String tweak, java.sql.Date encData) throws java.lang.SecurityExceptionDecrypt an encryptyed Date value- Parameters:
tweak
- The tweak used for the processencData
- The encrypted value- Returns:
- Date value in plain
- Throws:
java.lang.SecurityException
- In case of decryption error
-
encryptTypePreserving
public java.sql.Time encryptTypePreserving(java.lang.String tweak, java.sql.Time data) throws java.lang.SecurityExceptionEncrypt a Time value- Parameters:
tweak
- The tweak used for the encryptiondata
- The data to encrypt- Returns:
- Encrypted value
- Throws:
java.lang.SecurityException
- In case of encryption error
-
decryptTypePreserving
public java.sql.Time decryptTypePreserving(java.lang.String tweak, java.sql.Time encData) throws java.lang.SecurityExceptionDecrypt an encryptyed Time value- Parameters:
tweak
- The tweak used for the processencData
- The encrypted value- Returns:
- Time value in plain
- Throws:
java.lang.SecurityException
- In case of decryption error
-
encryptTypePreserving
public java.sql.Timestamp encryptTypePreserving(java.lang.String tweak, java.sql.Timestamp data) throws java.lang.SecurityExceptionEncrypt a Timestamp value- Parameters:
tweak
- The tweak used for the encryptiondata
- The data to encrypt- Returns:
- Encrypted value
- Throws:
java.lang.SecurityException
- In case of encryption error
-
decryptTypePreserving
public java.sql.Timestamp decryptTypePreserving(java.lang.String tweak, java.sql.Timestamp encData) throws java.lang.SecurityExceptionDecrypt an encryptyed Timestamp value- Parameters:
tweak
- The tweak used for the processencData
- The encrypted value- Returns:
- Timestamp value in plain
- Throws:
java.lang.SecurityException
- In case of decryption error
-
encryptOrderPreserving
public java.lang.String encryptOrderPreserving(java.lang.String tweak, java.sql.Timestamp data) throws java.lang.SecurityExceptionEncrypt a Timestamp value in order preserving form, encrypted value is of string type- Parameters:
tweak
- The tweak used for the encryptiondata
- The data to encrypt- Returns:
- Encrypted value
- Throws:
java.lang.SecurityException
- In case of encryption error
-
decryptOrderPreservingTS
public java.sql.Timestamp decryptOrderPreservingTS(java.lang.String tweak, java.lang.String encDataStr) throws java.lang.SecurityExceptionDecrypt a Timestamp value encrypted with order preserving encryption- Parameters:
tweak
- The tweak used for the decryptionencDataStr
- The encrypted value- Returns:
- Timestamp value in plain
- Throws:
java.lang.SecurityException
- In case of decryption error
-
encryptTypePreserving
public boolean encryptTypePreserving(java.lang.String tweak, boolean data) throws java.lang.SecurityExceptionEncrypt a boolean value- Parameters:
tweak
- The tweak used for the encryptiondata
- The data to encrypt- Returns:
- Encrypted value
- Throws:
java.lang.SecurityException
- In case of encryption error
-
decryptTypePreserving
public boolean decryptTypePreserving(java.lang.String tweak, boolean encData) throws java.lang.SecurityExceptionDecrypt an encryptyed boolean value- Parameters:
tweak
- The tweak used for the processencData
- The encrypted value- Returns:
- Boolean value in plain
- Throws:
java.lang.SecurityException
- In case of decryption error
-
encryptTypePreserving
public java.sql.Blob encryptTypePreserving(java.lang.String tweak, java.sql.Blob data) throws java.lang.SecurityExceptionEncrypt a Blob value- Parameters:
tweak
- The tweak used for the encryptiondata
- The data to encrypt- Returns:
- Encrypted value
- Throws:
java.lang.SecurityException
- In case of encryption error
-
decryptTypePreserving
public java.sql.Blob decryptTypePreserving(java.lang.String tweak, java.sql.Blob encData) throws java.lang.SecurityExceptionDecrypt an encryptyed Blob value- Parameters:
tweak
- The tweak used for the processencData
- The encrypted value- Returns:
- Blob value in plain
- Throws:
java.lang.SecurityException
- In case of decryption error
-
encryptTypePreserving
public java.sql.Clob encryptTypePreserving(java.lang.String tweak, java.sql.Clob data) throws java.lang.SecurityExceptionEncrypt a Clob value- Parameters:
tweak
- The tweak used for the encryptiondata
- The data to encrypt- Returns:
- Encrypted value
- Throws:
java.lang.SecurityException
- In case of encryption error
-
decryptTypePreserving
public java.sql.Clob decryptTypePreserving(java.lang.String tweak, java.sql.Clob encData) throws java.lang.SecurityExceptionDecrypt an encryptyed Clob value- Parameters:
tweak
- The tweak used for the processencData
- The encrypted value- Returns:
- Clob value in plain
- Throws:
java.lang.SecurityException
- In case of decryption error
-
encryptTypePreserving
public java.math.BigDecimal encryptTypePreserving(java.lang.String tweak, java.math.BigDecimal data) throws java.lang.SecurityExceptionEncrypt a BigDecimal value- Parameters:
tweak
- The tweak used for the encryptiondata
- The data to encrypt- Returns:
- Encrypted value
- Throws:
java.lang.SecurityException
- In case of encryption error
-
decryptTypePreserving
public java.math.BigDecimal decryptTypePreserving(java.lang.String tweak, java.math.BigDecimal encData) throws java.lang.SecurityExceptionDecrypt an encryptyed BigDecimal value- Parameters:
tweak
- The tweak used for the processencData
- The encrypted value- Returns:
- BigDecimal value in plain
- Throws:
java.lang.SecurityException
- In case of decryption error
-
encryptEMailAddress
public java.lang.String encryptEMailAddress(java.lang.String tweak, java.lang.String in, int maxSize) throws java.lang.SecurityExceptionEncrypt an email address in format preserving form, where the encrypted value is also a legitimate email address.
It can contain these characters: A-Z, a-z, 0-9, .!#$%&*+-/={|}~(),:;<>[]
It must contain an @ as a separator and cannot contain spaces.- Parameters:
tweak
- The tweak used for the encryptionin
- Email address to encryptmaxSize
- Maximum size of all email addresses encrypted- Returns:
- The encrypted value
- Throws:
java.lang.SecurityException
- In case of encryption error
-
decryptEMailAddress
public java.lang.String decryptEMailAddress(java.lang.String tweak, java.lang.String in) throws java.lang.SecurityExceptionDecrypt an encrypted email address, where the encrypted value is also an email address.- Parameters:
tweak
- The tweak used for the decryptionin
- The encrypted value- Returns:
- Original plain email address
- Throws:
java.lang.SecurityException
- In case of decryption error
-
encryptCreditCard
public java.lang.String encryptCreditCard(java.lang.String tweak, java.lang.String in) throws java.lang.SecurityExceptionEncrypt a credit card number in format preserving form, where the encrypted value is also a legitimate credit card number. Encryption uses a Luhn algorithm to verify valid credit card numbers.- Parameters:
tweak
- The tweak used for the encryptionin
- Credit card number to encrypt- Returns:
- The encrypted value
- Throws:
java.lang.SecurityException
- In case of encryption error
-
encryptCreditCard
public java.lang.String encryptCreditCard(java.lang.String tweak, java.lang.String in, java.lang.String format) throws java.lang.SecurityExceptionEncrypt a credit card number in format preserving form, where the encrypted value is also a legitimate credit card number. Encryption uses a Luhn algorithm to verify valid credit card numbers.- Parameters:
tweak
- The tweak used for the encryptionin
- Credit card number to encryptformat
- The credit card number, where the # characters get encrypted, the ? characters are passed as plain text, and other characters are passed as-is to the output. For example, for "????-####-####-####", the first 4 numbers are plain and the rest of the credit card number is encrypted.- Returns:
- The encrypted value
- Throws:
java.lang.SecurityException
- In case of encryption error
-
decryptCreditCard
public java.lang.String decryptCreditCard(java.lang.String tweak, java.lang.String in) throws java.lang.SecurityExceptionDecrypt a credit card number, where the encrypted value is also a credit card number- Parameters:
tweak
- The tweak used for the decryptionin
- The encrypted value- Returns:
- Original plain credit card
- Throws:
java.lang.SecurityException
- In case of decryption error
-
decryptCreditCard
public java.lang.String decryptCreditCard(java.lang.String tweak, java.lang.String in, java.lang.String format) throws java.lang.SecurityExceptionDecrypt a credit card number, where the encrypted value is also a credit card number- Parameters:
tweak
- The tweak used for the decryptionin
- The encrypted valueformat
- The credit card number, where the # characters get decrypted, the ? characters are passed as plain text, and other characters are passed as-is to the output. For example, for "????-####-####-####", the first 4 numbers are plain and the rest of the credit card number is decrypted.- Returns:
- Original plain credit card
- Throws:
java.lang.SecurityException
- In case of decryption error
-
encryptUSPhone
public java.lang.String encryptUSPhone(java.lang.String tweak, java.lang.String in, java.lang.String format) throws java.lang.SecurityExceptionEncrypt a US phone in format preserving form, where the encrypted value is also a legitimate US phone number.
The number is 10 digits. Any non-digits, such as hyphens, are passed as-is. It is validated by checking the format aaa-bcc-dddd, where aaa > 200, b >= 2, and cc is not 11.- Parameters:
tweak
- The tweak used for the encryptionin
- Phone number to encryptformat
- The output format, where the # characters get encrypted and other characters are passed as-is to the output. For example, the format could be "###-###-####".- Returns:
- The encrypted value
- Throws:
java.lang.SecurityException
- In case of encryption error
-
decryptUSPhone
public java.lang.String decryptUSPhone(java.lang.String tweak, java.lang.String in, java.lang.String format) throws java.lang.SecurityExceptionDecrypt an encrypted US phone number, where the encrypted value is also a US phone number- Parameters:
tweak
- The tweak used for the decryptionin
- The encrypted valueformat
- The output format, where the # characters get decrypted and other characters are passed as-is to the output. For example, the format could be "###-###-####".- Returns:
- Original plain US phone number
- Throws:
java.lang.SecurityException
- In case of decryption error
-
encryptSSN
public java.lang.String encryptSSN(java.lang.String tweak, java.lang.String in, java.lang.String format) throws java.lang.SecurityExceptionEncrypt an SSN in format preserving form, where the encrypted value is also a legitimate SSN.
The SSN can be all numbers except:
- Numbers with all zeros in any digit group (000-##-####, ###-00-####, ###-##-0000).
- Numbers with 666 or 900-999 (Individual Taxpayer Identification Number) in the first digit group.- Parameters:
tweak
- The tweak used for the encryptionin
- SSN to encryptformat
- The output format, where the # characters get encrypted, the ? characters are passed as plain text, and other characters are passed as-is to the output. Note that only the last 4 numbers can be plain text, so only "###-##-####" and "###-##-????" are acceptable formats (with or without the hyphen delimiters).- Returns:
- The encrypted value
- Throws:
java.lang.SecurityException
- In case of encryption error
-
decryptSSN
public java.lang.String decryptSSN(java.lang.String tweak, java.lang.String in, java.lang.String format) throws java.lang.SecurityExceptionDecrypt an encrypted SSN, where the encrypted value is also SSN- Parameters:
tweak
- The tweak used for the decryptionin
- The encrypted valueformat
- The output format, where the # characters get decrypted, the ? characters are passed as plain text, and other characters are passed as-is to the output. Note that only the last 4 numbers can be plain text, so only "###-##-####" and "###-##-????" are acceptable formats (with or without the hyphen delimiters).- Returns:
- Original plain SSN
- Throws:
java.lang.SecurityException
- In case of decryption error
-