Interface
interface DHParamters
public interface DHParamters <: Key {
override func encodeToPem(): PemEntry
static func decodeDer(blob: DerBlob): DHParamters
static func decodeFromPem(text: String): DHParamters
}
Description: Provides the DH parameter interfaces.
Parent Type:
static func decodeDer(DerBlob)
static func decodeDer(blob: DerBlob): DHParamters
Description: Decodes a DH key parameter from the DER format.
Note:
- The Diffie-Hellman (DH) key exchange protocol ensures that a shared key securely traverses insecure networks.
- DER and PEM are two common encoding formats.
Parameters:
- blob: DerBlob: DH key parameter object in DER format
Returns:
- DHParamters: DH key parameter decoded from the DER format
Throws:
- X509Exception: When the DH key parameter in DER format is incorrect and cannot be parsed, this exception is thrown.
static func decodeFromPem(String)
static func decodeFromPem(text: String): DHParamters
Description: Decodes a DH key parameter from the PEM format.
Note:
PEM certificates are encoded using ASCLL (BASE64).
Parameters:
- text: String: DH key parameter character stream in PEM format
Returns:
- DHParamters: DH key parameter decoded from the PEM format
Throws:
- X509Exception: When the character stream does not comply with the PEM format or the file header does not comply with the DH key parameter header standard "-----BEGIN DH PARAMETERS-----", this exception is thrown.
func encodeToPem()
override func encodeToPem(): PemEntry
Description: Encodes a DH key parameter into the PEM format.
Returns:
- PemEntry: DH key parameter object generated in PEM format
interface Key
public interface Key <: ToString {
func encodeToDer(): DerBlob
func encodeToPem(): PemEntry
static func decodeDer(encoded: DerBlob): Key
static func decodeFromPem(text: String): Key
}
Description: Provides the key interfaces. The public key is used for signature verification or encryption, and the private key is used for signature or decryption. The public key and private key must match and be paired. This interface does not have specific implementation, and is provided for PrivateKey, PublicKey, and users to extend interfaces.
Parent Type:
static func decodeDer(DerBlob)
static func decodeDer(encoded: DerBlob): Key
Description: Decodes a key from the DER format.
Parameters:
- encoded: DerBlob: object in DER format
Returns:
- Key: key decoded from the DER format
Throws:
- X509Exception: When the private key content in DER format is incorrect and cannot be parsed, this exception is thrown.
static func decodeFromPem(String)
static func decodeFromPem(text: String): Key
Description: Decodes a key from the PEM format.
Parameters:
- text: String: character stream in PEM format
Returns:
- Key: key decoded from the PEM format
func encodeToDer()
func encodeToDer(): DerBlob
Description: Encodes a key into the DER format.
Returns:
- DerBlob: key data object generated in DER format
func encodeToPem()
func encodeToPem(): PemEntry
Description: Encodes a key into the PEM format.
Returns:
- PemEntry: key data object generated in PEM format
interface PrivateKey
public interface PrivateKey <: Key {
static func decodeDer(blob: DerBlob): PrivateKey
static func decodeFromPem(text: String): PrivateKey
static func decodeDer(blob: DerBlob, password!: ?String): PrivateKey
static func decodeFromPem(text: String, password!: ?String): PrivateKey
func encodeToDer(password!: ?String): DerBlob
override func encodeToPem(): PemEntry
func encodeToPem(password!: ?String): PemEntry
}
Description: Provides the private key interfaces.
Parent Type:
static func decodeDer(DerBlob)
static func decodeDer(blob: DerBlob): PrivateKey
Description: Decodes a private key from the DER format.
Parameters:
- blob: DerBlob: private key object in DER format
Returns:
- PrivateKey: private key decoded from the DER format
Throws:
- X509Exception: When the private key content in DER format is incorrect and cannot be parsed, this exception is thrown.
static func decodeDer(DerBlob, ?String)
static func decodeDer(blob: DerBlob, password!: ?String): PrivateKey
Description: Decrypts and decodes a private key in DER format into a PrivateKey object. If the password is None, decryption is not performed.
Parameters:
Returns:
- PrivateKey: private key object after decryption and decoding
Throws:
- X509Exception: When decryption or decoding fails or the
password
is empty, this exception is thrown.
static func decodeFromPem(String)
static func decodeFromPem(text: String): PrivateKey
Description: Decodes a private key from the PEM format.
Parameters:
- text: String: private key character stream in PEM format
Returns:
- PrivateKey: private key decoded from the PEM format
Throws:
- X509Exception: When the character stream does not comply with the PEM format or the file header does not comply with the public key header standard, this exception is thrown.
static func decodeFromPem(String, ?String)
static func decodeFromPem(text: String, password!: ?String): PrivateKey
Description: Decrypts and decodes a private key in PEM format into a PrivateKey object. If the password is None, decryption is not performed.
Parameters:
Returns:
- PrivateKey: private key object after decryption and decoding
Throws:
- X509Exception: When decryption or decoding fails or the
password
is empty, this exception is thrown.
func encodeToDer(?String)
func encodeToDer(password!: ?String): DerBlob
Description: Encrypts and encodes a private key into the DER format. If the password is None, encryption is not performed.
Parameters:
- password!: ?String: encryption password
Returns:
- DerBlob: encrypted private key in DER format
Throws:
- X509Exception: When encryption fails or the
password
is empty, this exception is thrown.
func encodeToPem()
override func encodeToPem(): PemEntry
Description: Encodes a private key into the PEM format.
Returns:
- PemEntry: encoded private key in PEM format
Throws:
- X509Exception: When encoding fails, this exception is thrown.
func encodeToPem(?String)
func encodeToPem(password!: ?String): PemEntry
Description: Encrypts and encodes a private key into the PEM format. If the password is None, encryption is not performed.
Parameters:
- password!: ?String: encryption password
Returns:
- PemEntry: encrypted private key in PEM format
Throws:
- X509Exception: When encryption fails or the
password
is empty, this exception is thrown.
interface PublicKey
public interface PublicKey <: Key {
override func encodeToPem(): PemEntry
static func decodeDer(blob: DerBlob): PublicKey
static func decodeFromPem(text: String): PublicKey
}
Description: Indicates the public key interface.
Parent Type:
static func decodeDer(DerBlob)
static func decodeDer(blob: DerBlob): PublicKey
Description: Decodes a public key from the DER format.
Parameters:
- blob: DerBlob: public key object in DER format
Returns:
- PublicKey: public key decoded from DER format
Throws:
- X509Exception: When the public key content in DER format is incorrect and cannot be parsed, this exception is thrown.
static func decodeFromPem(String)
static func decodeFromPem(text: String): PublicKey
Description: Decodes a public key from the PEM format.
Parameters:
- text: String: public key character stream in PEM format
Returns:
- PublicKey: public key decoded from the PEM format
Throws:
- X509Exception: When the character stream does not comply with the PEM format or the file header does not comply with the public key header standard, this exception is thrown.
func encodeToPem()
override func encodeToPem(): PemEntry
Description: Encodes a public key into the PEM format.
Returns:
- PemEntry: public key data object generated in PEM format