From 98a49c6e1530af3292c43c86c769a11fdf9eb39b Mon Sep 17 00:00:00 2001 From: Udara Pathum <46132469+hwupathum@users.noreply.github.com> Date: Tue, 14 May 2024 12:16:30 +0530 Subject: [PATCH] Fix doc issues --- ballerina/hpke.bal | 14 +++++++------- ballerina/kem.bal | 4 ++-- ballerina/private_public_key.bal | 4 ++-- docs/spec/spec.md | 18 +++++++++--------- 4 files changed, 20 insertions(+), 20 deletions(-) diff --git a/ballerina/hpke.bal b/ballerina/hpke.bal index 4874f4d8..53eaf938 100644 --- a/ballerina/hpke.bal +++ b/ballerina/hpke.bal @@ -35,7 +35,7 @@ public type HybridEncryptionResult record {| # password: "keyStorePassword" # }; # crypto:PublicKey publicKey = check crypto:decodeMlKem768PublicKeyFromTrustStore(keyStore, "keyAlias"); -# crypto:HybridEncryptionResult encryptionResult = crypto:encryptMlKem768Hpke(data, publicKey); +# crypto:HybridEncryptionResult encryptionResult = check crypto:encryptMlKem768Hpke(data, publicKey); # ``` # + input - The content to be encrypted # + publicKey - Public key used for encryption @@ -61,10 +61,10 @@ public isolated function encryptMlKem768Hpke(byte[] input, PublicKey publicKey, # password: "keyStorePassword" # }; # crypto:PublicKey publicKey = check crypto:decodeMlKem768PublicKeyFromTrustStore(keyStore, "keyAlias"); -# crypto:HybridEncryptionResult encryptionResult = crypto:encryptMlKem768Hpke(data, publicKey); +# crypto:HybridEncryptionResult encryptionResult = check crypto:encryptMlKem768Hpke(data, publicKey); # byte[] cipherText = encryptionResult.cipherText; # byte[] encapsulatedKey = encryptionResult.encapsulatedSecret; -# crypto:PrivateKey privateKey = check crypto:decodeMlKem768PrivateKeyFromKeyStore(keyStore, "keyAlias"); +# crypto:PrivateKey privateKey = check crypto:decodeMlKem768PrivateKeyFromKeyStore(keyStore, "keyAlias", "keyStorePassword"); # byte[] decryptedData = check crypto:decryptMlKem768Hpke(cipherText, encapsulatedKey, privateKey); # ``` # + input - The content to be decrypted @@ -92,7 +92,7 @@ public isolated function decryptMlKem768Hpke(byte[] input, byte[] encapsulatedKe # }; # crypto:PublicKey mlkemPublicKey = check crypto:decodeMlKem768PublicKeyFromTrustStore(mlkemKeyStore, "keyAlias"); # crypto:PublicKey rsaPublicKey = check crypto:decodeRsaPublicKeyFromTrustStore(rsaKeyStore, "keyAlias"); -# crypto:HybridEncryptionResult encryptionResult = crypto:encryptRsaKemMlKem768Hpke(data, rsaPublicKey, mlkemPublicKey); +# crypto:HybridEncryptionResult encryptionResult = check crypto:encryptRsaKemMlKem768Hpke(data, rsaPublicKey, mlkemPublicKey); # ``` # + input - The content to be encrypted # + rsaPublicKey - The RSA public key used for encryption @@ -123,11 +123,11 @@ public isolated function encryptRsaKemMlKem768Hpke(byte[] input, PublicKey rsaPu # }; # crypto:PublicKey mlkemPublicKey = check crypto:decodeMlKem768PublicKeyFromTrustStore(mlkemKeyStore, "keyAlias"); # crypto:PublicKey rsaPublicKey = check crypto:decodeRsaPublicKeyFromTrustStore(rsaKeyStore, "keyAlias"); -# crypto:HybridEncryptionResult encryptionResult = crypto:encryptRsaKemMlKem768Hpke(data, rsaPublicKey, mlkemPublicKey); +# crypto:HybridEncryptionResult encryptionResult = check crypto:encryptRsaKemMlKem768Hpke(data, rsaPublicKey, mlkemPublicKey); # byte[] cipherText = encryptionResult.cipherText; # byte[] encapsulatedKey = encryptionResult.encapsulatedSecret; -# crypto:PrivateKey mlkemPrivateKey = check crypto:decodeMlKem768PrivateKeyFromKeyStore(mlkemKeyStore, "keyAlias"); -# crypto:PrivateKey rsaPrivateKey = check crypto:decodeRsaPrivateKeyFromKeyStore(rsaKeyStore, "keyAlias"); +# crypto:PrivateKey mlkemPrivateKey = check crypto:decodeMlKem768PrivateKeyFromKeyStore(mlkemKeyStore, "keyAlias", "keyStorePassword"); +# crypto:PrivateKey rsaPrivateKey = check crypto:decodeRsaPrivateKeyFromKeyStore(rsaKeyStore, "keyAlias", "keyStorePassword"); # byte[] decryptedData = check crypto:decryptRsaKemMlKem768Hpke(cipherText, encapsulatedKey, rsaPrivateKey, mlkemPrivateKey); # ``` # + input - The content to be decrypted diff --git a/ballerina/kem.bal b/ballerina/kem.bal index e62ba18b..b203b220 100644 --- a/ballerina/kem.bal +++ b/ballerina/kem.bal @@ -51,7 +51,7 @@ public isolated function encapsulateMlKem768(PublicKey publicKey) # crypto:PublicKey publicKey = check crypto:decodeMlKem768PublicKeyFromTrustStore(keyStore, "keyAlias"); # crypto:EncapsulationResult encapsulationResult = check crypto:encapsulateMlKem768(publicKey); # byte[] encapsulatedSecret = encapsulationResult.encapsulatedSecret; -# crypto:PrivateKey privateKey = check crypto:decodeMlKem768PrivateKeyFromKeyStore(keyStore, "keyAlias"); +# crypto:PrivateKey privateKey = check crypto:decodeMlKem768PrivateKeyFromKeyStore(keyStore, "keyAlias", "keyStorePassword"); # byte[] sharedSecret = check crypto:decapsulateMlKem768(encapsulatedSecret, privateKey); # ``` # + encapsulatedSecret - Encapsulated secret @@ -148,7 +148,7 @@ public isolated function encapsulateRsaKem(PublicKey publicKey) # crypto:PublicKey publicKey = check crypto:decodeRsaPublicKeyFromTrustStore(keyStore, "keyAlias"); # crypto:EncapsulationResult encapsulationResult = check crypto:encapsulateRsaKem(publicKey); # byte[] encapsulatedSecret = encapsulationResult.encapsulatedSecret; -# crypto:PrivateKey privateKey = check crypto:decodeRsaPrivateKeyFromKeyStore(keyStore, "keyAlias"); +# crypto:PrivateKey privateKey = check crypto:decodeRsaPrivateKeyFromKeyStore(keyStore, "keyAlias", "keyStorePassword"); # byte[] sharedSecret = check crypto:decapsulateRsaKem(encapsulatedSecret, privateKey); # ``` # + encapsulatedSecret - Encapsulated secret diff --git a/ballerina/private_public_key.bal b/ballerina/private_public_key.bal index d054ca9f..9869412e 100644 --- a/ballerina/private_public_key.bal +++ b/ballerina/private_public_key.bal @@ -124,7 +124,7 @@ public isolated function decodeEcPrivateKeyFromKeyStore(KeyStore keyStore, strin # ```ballerina # crypto:KeyStore keyStore = { # path: "/path/to/keyStore.p12", -# password +# password: "keyStorePassword" # }; # crypto:PrivateKey privateKey = check crypto:decodeMlDsa65PrivateKeyFromKeyStore(keyStore, "keyAlias", "keyPassword"); # ``` @@ -142,7 +142,7 @@ public isolated function decodeMlDsa65PrivateKeyFromKeyStore(KeyStore keyStore, # ```ballerina # crypto:KeyStore keyStore = { # path: "/path/to/keyStore.p12", -# password +# password: "keyStorePassword" # }; # crypto:PrivateKey privateKey = check crypto:decodeMlKem768PrivateKeyFromKeyStore(keyStore, "keyAlias", "keyPassword"); # ``` diff --git a/docs/spec/spec.md b/docs/spec/spec.md index 03b30afa..ccd4445c 100644 --- a/docs/spec/spec.md +++ b/docs/spec/spec.md @@ -901,7 +901,7 @@ crypto:KeyStore keyStore = { crypto:PublicKey publicKey = check crypto:decodeRsaPublicKeyFromTrustStore(keyStore, "keyAlias"); crypto:EncapsulationResult encapsulationResult = check crypto:encapsulateRsaKem(publicKey); byte[] encapsulatedSecret = encapsulationResult.encapsulatedSecret; -crypto:PrivateKey privateKey = check crypto:decodeRsaPrivateKeyFromKeyStore(keyStore, "keyAlias"); +crypto:PrivateKey privateKey = check crypto:decodeRsaPrivateKeyFromKeyStore(keyStore, "keyAlias", "keyStorePassword"); byte[] sharedSecret = check crypto:decapsulateRsaKem(encapsulatedSecret, privateKey); ``` @@ -917,7 +917,7 @@ crypto:KeyStore keyStore = { crypto:PublicKey publicKey = check crypto:decodeMlKem768PublicKeyFromTrustStore(keyStore, "keyAlias"); crypto:EncapsulationResult encapsulationResult = check crypto:encapsulateMlKem768(publicKey); byte[] encapsulatedSecret = encapsulationResult.encapsulatedSecret; -crypto:PrivateKey privateKey = check crypto:decodeMlKem768PrivateKeyFromKeyStore(keyStore, "keyAlias"); +crypto:PrivateKey privateKey = check crypto:decodeMlKem768PrivateKeyFromKeyStore(keyStore, "keyAlias", "keyStorePassword"); byte[] sharedSecret = check crypto:decapsulateMlKem768(encapsulatedSecret, privateKey); ``` @@ -961,7 +961,7 @@ crypto:KeyStore keyStore = { password: "keyStorePassword" }; crypto:PublicKey publicKey = check crypto:decodeMlKem768PublicKeyFromTrustStore(keyStore, "keyAlias"); -crypto:HybridEncryptionResult encryptionResult = crypto:encryptMlKem768Hpke(data, publicKey); +crypto:HybridEncryptionResult encryptionResult = check crypto:encryptMlKem768Hpke(data, publicKey); ``` #### 9.1.2. [RSA-KEM-ML-KEM-768-HPKE](#912-rsa-kem-ml-kem-768-hpke) @@ -981,7 +981,7 @@ crypto:KeyStore rsaKeyStore = { }; crypto:PublicKey mlkemPublicKey = check crypto:decodeMlKem768PublicKeyFromTrustStore(mlkemKeyStore, "keyAlias"); crypto:PublicKey rsaPublicKey = check crypto:decodeRsaPublicKeyFromTrustStore(rsaKeyStore, "keyAlias"); -crypto:HybridEncryptionResult encryptionResult = crypto:encryptRsaKemMlKem768Hpke(data, rsaPublicKey, mlkemPublicKey); +crypto:HybridEncryptionResult encryptionResult = check crypto:encryptRsaKemMlKem768Hpke(data, rsaPublicKey, mlkemPublicKey); ``` ### 9.2. [Decrypt](#92-decrypt) @@ -998,10 +998,10 @@ crypto:KeyStore keyStore = { password: "keyStorePassword" }; crypto:PublicKey publicKey = check crypto:decodeMlKem768PublicKeyFromTrustStore(keyStore, "keyAlias"); -crypto:HybridEncryptionResult encryptionResult = crypto:encryptMlKem768Hpke(data, publicKey); +crypto:HybridEncryptionResult encryptionResult = check crypto:encryptMlKem768Hpke(data, publicKey); byte[] cipherText = encryptionResult.cipherText; byte[] encapsulatedKey = encryptionResult.encapsulatedSecret; -crypto:PrivateKey privateKey = check crypto:decodeMlKem768PrivateKeyFromKeyStore(keyStore, "keyAlias"); +crypto:PrivateKey privateKey = check crypto:decodeMlKem768PrivateKeyFromKeyStore(keyStore, "keyAlias", "keyStorePassword"); byte[] decryptedData = check crypto:decryptMlKem768Hpke(cipherText, encapsulatedKey, privateKey); ``` @@ -1022,10 +1022,10 @@ crypto:KeyStore rsaKeyStore = { }; crypto:PublicKey mlkemPublicKey = check crypto:decodeMlKem768PublicKeyFromTrustStore(mlkemKeyStore, "keyAlias"); crypto:PublicKey rsaPublicKey = check crypto:decodeRsaPublicKeyFromTrustStore(rsaKeyStore, "keyAlias"); -crypto:HybridEncryptionResult encryptionResult = crypto:encryptRsaKemMlKem768Hpke(data, rsaPublicKey, mlkemPublicKey); +crypto:HybridEncryptionResult encryptionResult = check crypto:encryptRsaKemMlKem768Hpke(data, rsaPublicKey, mlkemPublicKey); byte[] cipherText = encryptionResult.cipherText; byte[] encapsulatedKey = encryptionResult.encapsulatedSecret; -crypto:PrivateKey mlkemPrivateKey = check crypto:decodeMlKem768PrivateKeyFromKeyStore(mlkemKeyStore, "keyAlias"); -crypto:PrivateKey rsaPrivateKey = check crypto:decodeRsaPrivateKeyFromKeyStore(rsaKeyStore, "keyAlias"); +crypto:PrivateKey mlkemPrivateKey = check crypto:decodeMlKem768PrivateKeyFromKeyStore(mlkemKeyStore, "keyAlias", "keyStorePassword"); +crypto:PrivateKey rsaPrivateKey = check crypto:decodeRsaPrivateKeyFromKeyStore(rsaKeyStore, "keyAlias", "keyStorePassword"); byte[] decryptedData = check crypto:decryptRsaKemMlKem768Hpke(cipherText, encapsulatedKey, rsaPrivateKey, mlkemPrivateKey); ```