Skip to content

Commit

Permalink
Add pgp encryption and decryption
Browse files Browse the repository at this point in the history
  • Loading branch information
dinukaamarasinghe817 committed May 9, 2024
1 parent fd56930 commit 9110389
Show file tree
Hide file tree
Showing 16 changed files with 641 additions and 0 deletions.
3 changes: 3 additions & 0 deletions ballerina/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -76,6 +76,9 @@ dependencies {
externalJars(group: 'org.bouncycastle', name: 'bcutil-jdk18on', version: "${bouncycastleVersion}") {
transitive = false
}
externalJars(group: 'org.bouncycastle', name: 'bcpg-jdk18on', version: "${bouncycastleVersion}") {
transitive = false
}
}

task updateTomlFiles {
Expand Down
38 changes: 38 additions & 0 deletions ballerina/encrypt_decrypt.bal
Original file line number Diff line number Diff line change
Expand Up @@ -243,3 +243,41 @@ public isolated function decryptAesGcm(byte[] input, byte[] key, byte[] iv, AesP
name: "decryptAesGcm",
'class: "io.ballerina.stdlib.crypto.nativeimpl.Decrypt"
} external;

# Returns the PGP-encrypted value for the given data.
# ```ballerina
# byte[] message = "Hello Ballerina!".toBytes();
# byte[] publicKey = check io:fileReadBytes("public_key.asc"); // provide the path to the public key
# byte[] cipherText = check crypto:encryptPgp(message, publicKey);
# ```
#
# + input - The content to be encrypted
# + key - Public key
# + options - PGP encryption options
# + return - Encrypted data or else a `crypto:Error` if the key is invalid
public isolated function encryptPgp(byte[] input, byte[] key, *PgpEncryptionOptions options)
returns byte[]|Error = @java:Method {
name: "encryptPgp",
'class: "io.ballerina.stdlib.crypto.nativeimpl.Encrypt"
} external;

# Returns the PGP-decrypted value for the given PGP-encrypted data.
# ```ballerina
# byte[] message = "Hello Ballerina!".toBytes();
# byte[] publicKey = check io:fileReadBytes("public_key.asc"); // provide the path to the public key
# byte[] cipherText = check crypto:encryptPgp(message, publicKey);
#
# byte[] privateKey = check io:fileReadBytes("private_key.asc"); // provide the path to the private key
# byte[] passphrase = check io:fileReadBytes("pass_phrase.txt"); // provide the path to the passphrase
# byte[] decryptedMessage = check crypto:decryptPgp(cipherText, privateKey, passphrase);
# ```
#
# + input - The encrypted content to be decrypted
# + key - Private key
# + passphrase - passphrase of the private key
# + return - Decrypted data or else a `crypto:Error` if the key or passphrase is invalid
public isolated function decryptPgp(byte[] input, byte[] key, byte[] passphrase)
returns byte[]|Error = @java:Method {
name: "decryptPgp",
'class: "io.ballerina.stdlib.crypto.nativeimpl.Decrypt"
} external;
46 changes: 46 additions & 0 deletions ballerina/pgp_utils.bal
Original file line number Diff line number Diff line change
@@ -0,0 +1,46 @@
// Copyright (c) 2024 WSO2 LLC. (https://www.wso2.com).
//
// WSO2 LLC. licenses this file to you under the Apache License,
// Version 2.0 (the "License"); you may not use this file except
// in compliance with the License.
// You may obtain a copy of the License at
//
// http://www.apache.org/licenses/LICENSE-2.0
//
// Unless required by applicable law or agreed to in writing,
// software distributed under the License is distributed on an
// "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
// KIND, either express or implied. See the License for the
// specific language governing permissions and limitations
// under the License.

public type PgpEncryptionOptions record {|
CompressionAlgorithmTags compressionAlgorithm = ZIP;
SymmetricKeyAlgorithmTags symmetricKeyAlgorithm = AES_256;
boolean armor = true;
boolean withIntegrityCheck = true;
|};

public enum CompressionAlgorithmTags {
UNCOMPRESSED = "0",
ZIP = "1",
ZLIB = "2",
BZIP2= "3"
}

public enum SymmetricKeyAlgorithmTags {
NULL = "0",
IDEA = "1",
TRIPLE_DES = "2",
CAST5 = "3",
BLOWFISH = "4",
SAFER = "5",
DES = "6",
AES_128 = "7",
AES_192 = "8",
AES_256 = "9",
TWOFISH = "10",
CAMELLIA_128 = "11",
CAMELLIA_192 = "12",
CAMELLIA_256 = "13"
}
40 changes: 40 additions & 0 deletions ballerina/tests/encrypt_decrypt_pgp_test.bal
Original file line number Diff line number Diff line change
@@ -0,0 +1,40 @@
// Copyright (c) 2020 WSO2 Inc. (http://www.wso2.org) All Rights Reserved.
//
// WSO2 Inc. licenses this file to you under the Apache License,
// Version 2.0 (the "License"); you may not use this file except
// in compliance with the License.
// You may obtain a copy of the License at
//
// http://www.apache.org/licenses/LICENSE-2.0
//
// Unless required by applicable law or agreed to in writing,
// software distributed under the License is distributed on an
// "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
// KIND, either express or implied. See the License for the
// specific language governing permissions and limitations
// under the License.

import ballerina/test;
import ballerina/io;

@test:Config {}
isolated function testEncryptAndDecryptWithPgp() returns error? {
byte[] message = "Ballerina crypto test ".toBytes();
byte[] passphrase = check io:fileReadBytes(PGP_PRIVATE_KEY_PASSPHRASE_PATH);
byte[] publicKey = check io:fileReadBytes(PGP_PUBLIC_KEY_PATH);
byte[] privateKey = check io:fileReadBytes(PGP_PRIVATE_KEY_PATH);
byte[] cipherText = check encryptPgp(message, publicKey);
byte[] plainText = check decryptPgp(cipherText, privateKey, passphrase);
test:assertEquals(plainText.toBase16(), message.toBase16());
}

@test:Config {}
isolated function testEncryptAndDecryptWithPgpWithOptions() returns error? {
byte[] message = "Ballerina crypto test ".toBytes();
byte[] passphrase = check io:fileReadBytes(PGP_PRIVATE_KEY_PASSPHRASE_PATH);
byte[] publicKey = check io:fileReadBytes(PGP_PUBLIC_KEY_PATH);
byte[] privateKey = check io:fileReadBytes(PGP_PRIVATE_KEY_PATH);
byte[] cipherText = check encryptPgp(message, publicKey, symmetricKeyAlgorithm = AES_128, armor = false);
byte[] plainText = check decryptPgp(cipherText, privateKey, passphrase);
test:assertEquals(plainText.toBase16(), message.toBase16());
}
1 change: 1 addition & 0 deletions ballerina/tests/resources/pgp_private_key_passphrase.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
qCr3bv@5mj5n4eY
99 changes: 99 additions & 0 deletions ballerina/tests/resources/private_key.asc
Original file line number Diff line number Diff line change
@@ -0,0 +1,99 @@
-----BEGIN PGP PRIVATE KEY BLOCK-----
Version: Keybase OpenPGP v2.0.76
Comment: https://keybase.io/crypto

xcMFBGY7OqUBCADQO4C2dbXISbB9EZKX8hEysDKk89o+5C2S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Ba0AbXN45xotBrdP2sNC1DKy3NymcKF1HoHZ5PQ9E3Ixp3TnsS
gy3MEb1z2UyAH5fF7AfDRhPDfhJtl5sJ04EnM9yPOruREmTlcxeJvyJ5lnlDRGK8
jN/C3R/zSpAjSpA/vY4EeUOQuMni5PG5SxfFZupQSus3r0qZx5BJdnyY276yDKSi
s/CP5qP5zE8YmJjLMdkwAfJuFi5EkigjOnOgGYymivYiURbpCxmn83rXBjoH/RPw
0Q5Wj0+5+Obc7yw8uUSor1m11kyI8/sv7G8dSDQLMpE5V7VKaj4OQ1fHMzpBPXP4
H8WqQx0XPUEScOJ8zDIS2p1VRMnMr2EerEw/QV/A3B5AwMDZkhd3tK0liP95xZ9v
y+pWPGAFIQrDYcmRMRBL2WB+jxm49VOgcesKl1OP3NO2DpHu/p4RS6N6+2w6H/De
x39rIv+7B6mdK54nHdomM0AdDc8qkks42Qr3kXbpLtnefZirWPs2QcNr9kXPtpfp
IyMpGoeudZWlaBMLcGlkEEO0MJKyTe2iKhIl+UAQwBoJEMbPc8L3m6oNtQotRzJv
4WbzDTObZg6ttIYG6+s=
=4NKk
-----END PGP PRIVATE KEY BLOCK-----
55 changes: 55 additions & 0 deletions ballerina/tests/resources/public_key.asc
Original file line number Diff line number Diff line change
@@ -0,0 +1,55 @@
-----BEGIN PGP PUBLIC KEY BLOCK-----
Version: Keybase OpenPGP v2.0.76
Comment: https://keybase.io/crypto

xsBNBGY7OqUBCADQO4C2dbXISbB9EZKX8hEysDKk89o+5C2SvCUBChBOwV036dDQ
R+4gCf2UE+/uER702r2QzDtpeCr/7uraNFf7x05Teng0ACk5aBTMunYF4KnmuicP
G/qQW0vW04Tv7l/qAGjGAaf8wZkFlQRIb0zMASyxLnxYSuRn09CeNLy+3fNBQxc0
cYUByZKb3IG0tMBUkr63RvCWwRGesQD3aqKrsvmKkTVWnosHt1Il6zFMGrY0M6Pr
S/lps9T677nu3C9ySiviem/sC4UORllfCtBO22eWKlC9KicbhR084vmrtT/s2cPd
v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SYMOXVbQgduOHmWYdzoFlx2VlYH/lppyN/WKvyxp8zUKIGu0hcPPhlno
OkhaxyK1EoWF36DlpS5DmfXslCv/nTpv4ipSKANS1NfgWtAG1zeOcaLQa3T9rDQt
QystzcpnChdR6B2eT0PRNyMad057EoMtzBG9c9lMgB+XxewHw0YTw34SbZebCdOB
JzPcjzq7kRJk5XMXib8ieZZ5Q0RivIzfwt0f80qQI0qQP72OBHlDkLjJ4uTxuUsX
xWbqUErrN69KmceQSXZ8mNu+sgykorPwj+aj+cxPGJiYyzHZMAHybhYuRJIoIzpz
oBmMpor2IlEW6QsZp/N61wY6B/0T8NEOVo9Pufjm3O8sPLlEqK9ZtdZMiPP7L+xv
HUg0CzKROVe1Smo+DkNXxzM6QT1z+B/FqkMdFz1BEnDifMwyEtqdVUTJzK9hHqxM
P0FfwNweQMDA2ZIXd7StJYj/ecWfb8vqVjxgBSEKw2HJkTEQS9lgfo8ZuPVToHHr
CpdTj9zTtg6R7v6eEUujevtsOh/w3sd/ayL/uwepnSueJx3aJjNAHQ3PKpJLONkK
95F26S7Z3n2Yq1j7NkHDa/ZFz7aX6SMjKRqHrnWVpWgTC3BpZBBDtDCSsk3toioS
JflAEMAaCRDGz3PC95uqDbUKLUcyb+Fm8w0zm2YOrbSGBuvr
=DRCu
-----END PGP PUBLIC KEY BLOCK-----
4 changes: 4 additions & 0 deletions ballerina/tests/test_utils.bal
Original file line number Diff line number Diff line change
Expand Up @@ -33,3 +33,7 @@ const string MLKEM_PRIVATE_KEY_PATH = "tests/resources/mlkem-key.pem";
const string INVALID_KEYSTORE_PATH = "tests/resources/cert/keyStore.p12.invalid";
const string INVALID_PRIVATE_KEY_PATH = "tests/resources/cert/private.key.invalid";
const string INVALID_PUBLIC_CERT_PATH = "tests/resources/cert/public.crt.invalid";

const string PGP_PUBLIC_KEY_PATH = "tests/resources/public_key.asc";
const string PGP_PRIVATE_KEY_PATH = "tests/resources/private_key.asc";
const string PGP_PRIVATE_KEY_PASSPHRASE_PATH = "tests/resources/pgp_private_key_passphrase.txt";
6 changes: 6 additions & 0 deletions build-config/resources/Ballerina.toml
Original file line number Diff line number Diff line change
Expand Up @@ -35,3 +35,9 @@ groupId = "org.bouncycastle"
artifactId = "bcutil-jdk18on"
version = "@bouncycastle.version@"
path = "./lib/[email protected]@.jar"

[[platform.java17.dependency]]
groupId = "org.bouncycastle"
artifactId = "bcpg-jdk18on"
version = "@bouncycastle.version@"
path = "./lib/[email protected]@.jar"
1 change: 1 addition & 0 deletions native/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,7 @@ dependencies {
implementation group: 'org.bouncycastle', name: 'bcpkix-jdk18on', version: "${bouncycastleVersion}"
implementation group: 'org.bouncycastle', name: 'bcprov-jdk18on', version: "${bouncycastleVersion}"
implementation group: 'org.bouncycastle', name: 'bcutil-jdk18on', version: "${bouncycastleVersion}"
implementation group: 'org.bouncycastle', name: 'bcpg-jdk18on', version: "${bouncycastleVersion}"
compileOnly group: 'org.graalvm.nativeimage', name: 'svm', version: "${nativeImageVersion}"
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -448,4 +448,5 @@ private static Digest selectHash(String algorithm) {
}
throw CryptoUtils.createError("Unsupported algorithm: " + algorithm);
}

}
Loading

0 comments on commit 9110389

Please sign in to comment.