Skip to content

Commit

Permalink
Improve API docs
Browse files Browse the repository at this point in the history
  • Loading branch information
ldclakmal committed May 21, 2021
1 parent bc269d5 commit e0d3950
Show file tree
Hide file tree
Showing 3 changed files with 16 additions and 16 deletions.
4 changes: 2 additions & 2 deletions crypto-ballerina/encrypt_decrypt.bal
Original file line number Diff line number Diff line change
Expand Up @@ -16,10 +16,10 @@

import ballerina/jballerina.java;

# Padding algorithms supported by AES encryption and decryption.
# Represents the padding algorithms supported by AES encryption and decryption.
public type AesPadding NONE|PKCS5;

# Padding algorithms supported with RSA encryption and decryption.
# Represents the padding algorithms supported with RSA encryption and decryption.
public type RsaPadding PKCS1|OAEPwithMD5andMGF1|OAEPWithSHA1AndMGF1|OAEPWithSHA256AndMGF1|OAEPwithSHA384andMGF1|
OAEPwithSHA512andMGF1;

Expand Down
2 changes: 1 addition & 1 deletion crypto-ballerina/hash.bal
Original file line number Diff line number Diff line change
Expand Up @@ -86,7 +86,7 @@ public isolated function hashSha512(byte[] input) returns byte[] = @java:Method
'class: "org.ballerinalang.stdlib.crypto.nativeimpl.Hash"
} external;

# Returns the Hex-encoded CRC32B value for the provided element.
# Returns the Hex-encoded CRC32B value for the given data.
# ```ballerina
# string stringData = "Hello Ballerina";
# byte[] data = stringData.toBytes();
Expand Down
26 changes: 13 additions & 13 deletions crypto-ballerina/private_public_key.bal
Original file line number Diff line number Diff line change
Expand Up @@ -17,13 +17,13 @@
import ballerina/jballerina.java;
import ballerina/time;

# The key algorithms supported by the Crypto module.
# Represents the key algorithms supported.
public type KeyAlgorithm RSA;

# The `RSA` algorithm.
public const RSA = "RSA";

# KeyStore related configurations.
# Represents the keystore related configurations.
#
# + path - Path to the KeyStore file
# + password - KeyStore password
Expand All @@ -32,7 +32,7 @@ public type KeyStore record {|
string password;
|};

# TrustStore related configurations.
# Represents the truststore related configurations.
#
# + path - Path to the TrustStore file
# + password - TrustStore password
Expand All @@ -41,14 +41,14 @@ public type TrustStore record {|
string password;
|};

# Private key used in cryptographic operations.
# Represents the private key used in cryptographic operations.
#
# + algorithm - Key algorithm
public type PrivateKey record {|
KeyAlgorithm algorithm;
|};

# Public key used in cryptographic operations.
# Represents the public key used in cryptographic operations.
#
# + algorithm - Key algorithm
# + certificate - Public key certificate
Expand All @@ -57,7 +57,7 @@ public type PublicKey record {|
Certificate certificate?;
|};

# X509 public key certificate information.
# Represents the X509 public key certificate information.
#
# + version0 - Version number
# + serial - Serial number
Expand All @@ -78,7 +78,7 @@ public type Certificate record {|
string signingAlgorithm;
|};

# Reads a private key from the provided PKCS#12 archive file.
# Decodes the RSA private key from the given PKCS#12 archive file.
# ```ballerina
# crypto:KeyStore keyStore = {
# path: "/path/to/keystore.p12",
Expand All @@ -96,7 +96,7 @@ public isolated function decodeRsaPrivateKeyFromKeyStore(KeyStore keyStore, stri
'class: "org.ballerinalang.stdlib.crypto.nativeimpl.Decode"
} external;

# Reads a private key from the provided private key and private key password.
# Decodes the RSA private key from the given private key and private key password.
# ```ballerina
# string keyFile = "/path/to/private.key";
# crypto:PrivateKey privateKey = check crypto:decodeRsaPrivateKeyFromKeyFile(keyFile, "keyPassword");
Expand All @@ -110,7 +110,7 @@ public isolated function decodeRsaPrivateKeyFromKeyFile(string keyFile, string?
'class: "org.ballerinalang.stdlib.crypto.nativeimpl.Decode"
} external;

# Reads a public key from the provided PKCS#12 archive file.
# Decodes the RSA public key from the given PKCS#12 archive file.
# ```ballerina
# crypto:TrustStore trustStore = {
# path: "/path/tp/truststore.p12",
Expand All @@ -127,7 +127,7 @@ public isolated function decodeRsaPublicKeyFromTrustStore(TrustStore trustStore,
'class: "org.ballerinalang.stdlib.crypto.nativeimpl.Decode"
} external;

# Reads a public key from the provided public certificate file.
# Decodes the RSA public key from the given public certificate file.
# ```ballerina
# string certFile = "/path/to/public.cert";
# crypto:PublicKey publicKey = check crypto:decodeRsaPublicKeyFromCertFile(certFile);
Expand All @@ -139,15 +139,15 @@ public isolated function decodeRsaPublicKeyFromCertFile(string certFile) returns
'class: "org.ballerinalang.stdlib.crypto.nativeimpl.Decode"
} external;

# Returns the `crypto:PublicKey` created with the modulus and exponent retrieved from the JWKs endpoint.
# Build the RSA public key from the given modulus and exponent parameters.
# ```ballerina
# string modulus = "luZFdW1ynitztkWLC6xKegbRWxky...";
# string exponent = "AQAB";
# crypto:PublicKey publicKey = check crypto:buildRsaPublicKey(modulus, exponent);
# ```
#
# + modulus - JWK modulus value ('n' parameter) for the RSA public key
# + exponent - JWK exponent value ('e' paramenter) for the RSA public key
# + modulus - Modulus value ('n' parameter) for the RSA public key
# + exponent - Exponent value ('e' paramenter) for the RSA public key
# + return - Reference to the public key or else a `crypto:Error` if the modulus or exponent is invalid
public isolated function buildRsaPublicKey(string modulus, string exponent) returns PublicKey|Error = @java:Method {
name: "buildRsaPublicKey",
Expand Down

0 comments on commit e0d3950

Please sign in to comment.