- java.lang.Object
-
- io.helidon.common.crypto.AsymmetricCipher
-
- All Implemented Interfaces:
CommonCipher
public class AsymmetricCipher extends Object implements CommonCipher
This class provides simple and stateless way to encrypt and decrypt messages using selected asymmetric cipher.
It requires to have aPrivateKey
provided for decryption purposes and aPublicKey
for encryption purposes.
-
-
Nested Class Summary
Nested Classes Modifier and Type Class Description static class
AsymmetricCipher.Builder
Builder of theAsymmetricCipher
.
-
Field Summary
Fields Modifier and Type Field Description static String
ALGORITHM_RSA_ECB_OAEP_MD5
Deprecated.It is strongly recommended not to use this algorithm as stated here RFC6151 - 2.static String
ALGORITHM_RSA_ECB_OAEP_SHA1
RSA cipher with ECB method using optimal asymmetric encryption padding with SHA1 and MGF1.static String
ALGORITHM_RSA_ECB_OAEP256
RSA cipher with ECB method using optimal asymmetric encryption padding with SHA-256 and MGF1.static String
ALGORITHM_RSA_ECB_OAEP384
RSA cipher with ECB method using optimal asymmetric encryption padding with SHA-384 and MGF1.static String
ALGORITHM_RSA_ECB_OAEP512_224
RSA cipher with ECB method using optimal asymmetric encryption padding with SHA-512/224 and MGF1.static String
ALGORITHM_RSA_ECB_OAEP512_256
RSA cipher with ECB method using optimal asymmetric encryption padding with SHA-512/256 and MGF1.static String
ALGORITHM_RSA_ECB_PKCS1
RSA cipher with ECB method using PKCS1 padding.
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description static AsymmetricCipher.Builder
builder()
Create a new builder.Base64Value
decrypt(Base64Value encrypted)
Decrypt encrypted message.static Base64Value
decrypt(String algorithm, String provider, PrivateKey privateKey, Base64Value message)
Decrypt the message with the provided private key and selected algorithm.Base64Value
encrypt(Base64Value message)
Encrypt message.static Base64Value
encrypt(String algorithm, String provider, PublicKey publicKey, Base64Value message)
Encrypt the message with the provided public key and selected algorithm.-
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
-
Methods inherited from interface io.helidon.common.crypto.CommonCipher
decryptFromString, encryptToString
-
-
-
-
Field Detail
-
ALGORITHM_RSA_ECB_OAEP_MD5
@Deprecated public static final String ALGORITHM_RSA_ECB_OAEP_MD5
Deprecated.It is strongly recommended not to use this algorithm as stated here RFC6151 - 2.RSA cipher with ECB method using optimal asymmetric encryption padding with MD5 and MGF1.
Value is: "RSA/ECB/OAEPWithMD5AndMGF1Padding".- See Also:
- Constant Field Values
-
ALGORITHM_RSA_ECB_OAEP_SHA1
public static final String ALGORITHM_RSA_ECB_OAEP_SHA1
RSA cipher with ECB method using optimal asymmetric encryption padding with SHA1 and MGF1.
Value is: "RSA/ECB/OAEPWithSHA1AndMGF1Padding".- See Also:
- Constant Field Values
-
ALGORITHM_RSA_ECB_OAEP256
public static final String ALGORITHM_RSA_ECB_OAEP256
RSA cipher with ECB method using optimal asymmetric encryption padding with SHA-256 and MGF1.
Value is: "RSA/ECB/OAEPWithSHA-256AndMGF1Padding".- See Also:
- Constant Field Values
-
ALGORITHM_RSA_ECB_OAEP384
public static final String ALGORITHM_RSA_ECB_OAEP384
RSA cipher with ECB method using optimal asymmetric encryption padding with SHA-384 and MGF1.
Value is: "RSA/ECB/OAEPWithSHA-384AndMGF1Padding".- See Also:
- Constant Field Values
-
ALGORITHM_RSA_ECB_OAEP512_224
public static final String ALGORITHM_RSA_ECB_OAEP512_224
RSA cipher with ECB method using optimal asymmetric encryption padding with SHA-512/224 and MGF1.
Value is: "RSA/ECB/OAEPWithSHA-512/224AndMGF1Padding".- See Also:
- Constant Field Values
-
ALGORITHM_RSA_ECB_OAEP512_256
public static final String ALGORITHM_RSA_ECB_OAEP512_256
RSA cipher with ECB method using optimal asymmetric encryption padding with SHA-512/256 and MGF1.
Value is: "RSA/ECB/OAEPWithSHA-512/256AndMGF1Padding".- See Also:
- Constant Field Values
-
ALGORITHM_RSA_ECB_PKCS1
public static final String ALGORITHM_RSA_ECB_PKCS1
RSA cipher with ECB method using PKCS1 padding.
Value is: "RSA/ECB/PKCS1Padding".- See Also:
- Constant Field Values
-
-
Method Detail
-
builder
public static AsymmetricCipher.Builder builder()
Create a new builder.- Returns:
- new builder
-
encrypt
public static Base64Value encrypt(String algorithm, String provider, PublicKey publicKey, Base64Value message)
Encrypt the message with the provided public key and selected algorithm.- Parameters:
algorithm
- algorithm nameprovider
- algorithm providerpublicKey
- public key used for encryptionmessage
- message to be encrypted- Returns:
- encrypted message
-
decrypt
public static Base64Value decrypt(String algorithm, String provider, PrivateKey privateKey, Base64Value message)
Decrypt the message with the provided private key and selected algorithm.- Parameters:
algorithm
- algorithm nameprovider
- algorithm providerprivateKey
- private key used for decryptionmessage
- message to be decrypted- Returns:
- decrypted message
-
encrypt
public Base64Value encrypt(Base64Value message)
Description copied from interface:CommonCipher
Encrypt message.- Specified by:
encrypt
in interfaceCommonCipher
- Parameters:
message
- message- Returns:
- encrypted message
-
decrypt
public Base64Value decrypt(Base64Value encrypted)
Description copied from interface:CommonCipher
Decrypt encrypted message.- Specified by:
decrypt
in interfaceCommonCipher
- Parameters:
encrypted
- encrypted message- Returns:
- decrypted message
-
-