- 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 aPrivateKeyprovided for decryption purposes and aPublicKeyfor encryption purposes.
-
-
Nested Class Summary
Nested Classes Modifier and Type Class Description static classAsymmetricCipher.BuilderBuilder of theAsymmetricCipher.
-
Field Summary
Fields Modifier and Type Field Description static StringALGORITHM_RSA_ECB_OAEP_MD5Deprecated.It is strongly recommended not to use this algorithm as stated here RFC6151 - 2.static StringALGORITHM_RSA_ECB_OAEP_SHA1RSA cipher with ECB method using optimal asymmetric encryption padding with SHA1 and MGF1.static StringALGORITHM_RSA_ECB_OAEP256RSA cipher with ECB method using optimal asymmetric encryption padding with SHA-256 and MGF1.static StringALGORITHM_RSA_ECB_OAEP384RSA cipher with ECB method using optimal asymmetric encryption padding with SHA-384 and MGF1.static StringALGORITHM_RSA_ECB_OAEP512_224RSA cipher with ECB method using optimal asymmetric encryption padding with SHA-512/224 and MGF1.static StringALGORITHM_RSA_ECB_OAEP512_256RSA cipher with ECB method using optimal asymmetric encryption padding with SHA-512/256 and MGF1.static StringALGORITHM_RSA_ECB_PKCS1RSA cipher with ECB method using PKCS1 padding.
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description static AsymmetricCipher.Builderbuilder()Create a new builder.Base64Valuedecrypt(Base64Value encrypted)Decrypt encrypted message.static Base64Valuedecrypt(String algorithm, String provider, PrivateKey privateKey, Base64Value message)Decrypt the message with the provided private key and selected algorithm.Base64Valueencrypt(Base64Value message)Encrypt message.static Base64Valueencrypt(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:CommonCipherEncrypt message.- Specified by:
encryptin interfaceCommonCipher- Parameters:
message- message- Returns:
- encrypted message
-
decrypt
public Base64Value decrypt(Base64Value encrypted)
Description copied from interface:CommonCipherDecrypt encrypted message.- Specified by:
decryptin interfaceCommonCipher- Parameters:
encrypted- encrypted message- Returns:
- decrypted message
-
-