class RsaSecurityKey
cangjie
public class RsaSecurityKey <: AsymmetricSecurityKey功能:表示 RSA 安全密钥。
父类型:
成员概览
| 成员 | 功能 |
|---|---|
| init(?RSAPublicKey, ?RSAPrivateKey) | 使用公钥和私钥创建 RSA 安全密钥。 |
| init(JsonWebKey) | 从 JWK 创建 RSA 安全密钥。 |
| init(RsaParameters) | 从 RSA 参数创建安全密钥。 |
| prop keyId | 获取密钥标识。 |
| prop publicKey | 获取 RSA 公钥。 |
| prop privateKey | 获取 RSA 私钥。 |
| prop keySize | 获取 RSA 密钥位长度。 |
| func exportParameters(Bool) | 导出 RSA 密钥参数。 |
| func fromPublicKeyPem(String) | 从 PEM 文本加载 RSA 公钥。 |
| func fromPrivateKeyPem(String) | 从 PEM 文本加载 RSA 私钥。 |
| func fromPublicKeyPemFile(String) | 从 PEM 文件加载 RSA 公钥。 |
| func fromPrivateKeyPemFile(String) | 从 PEM 文件加载 RSA 私钥。 |
| func fromPemFiles(String, String) | 同时从 PEM 文件加载 RSA 公钥和私钥。 |
init(?RSAPublicKey, ?RSAPrivateKey)
cangjie
public init(publicKey!: ?RSAPublicKey = None, privateKey!: ?RSAPrivateKey = None)功能:使用公钥和私钥创建 RSA 安全密钥。
参数:
- publicKey:
?RSAPublicKey- 可选的 RSA 公钥。 - privateKey:
?RSAPrivateKey- 可选的 RSA 私钥。
init(JsonWebKey)
cangjie
public init(jsonWebKey: JsonWebKey)功能:从 JWK 创建 RSA 安全密钥。
参数:
- jsonWebKey: JsonWebKey - 包含 RSA 密钥材料的 JWK。
异常:
IllegalArgumentException- 当必填字段缺失或编码无效时抛出。
init(RsaParameters)
cangjie
public init(params: RsaParameters)功能:从 RSA 参数创建安全密钥。
参数:
- params: RsaParameters - RSA 密钥参数。
prop keyId
cangjie
public prop keyId: ?String功能:获取密钥标识。
类型:?String
prop publicKey
cangjie
public prop publicKey: ?RSAPublicKey功能:获取 RSA 公钥。
类型:?RSAPublicKey
prop privateKey
cangjie
public prop privateKey: ?RSAPrivateKey功能:获取 RSA 私钥。
类型:?RSAPrivateKey
prop keySize
cangjie
public prop keySize: Int64功能:获取 RSA 密钥位长度。
类型:Int64
func exportParameters(Bool)
cangjie
public func exportParameters(includePrivateParameters: Bool): RsaParameters功能:导出 RSA 密钥参数。
参数:
- includePrivateParameters:
Bool- 是否同时导出私钥参数。
返回值:
- RsaParameters - 导出的 RSA 密钥参数。
异常:
IllegalArgumentException- 当既没有公钥也没有私钥时抛出。
func fromPublicKeyPem(String)
cangjie
public static func fromPublicKeyPem(pem: String): RsaSecurityKey功能:从 PEM 文本加载 RSA 公钥。
参数:
- pem:
String- PEM 格式的公钥文本。
返回值:
- RsaSecurityKey - 创建出的 RSA 安全密钥。
func fromPrivateKeyPem(String)
cangjie
public static func fromPrivateKeyPem(pem: String): RsaSecurityKey功能:从 PEM 文本加载 RSA 私钥。
参数:
- pem:
String- PEM 格式的私钥文本。
返回值:
- RsaSecurityKey - 创建出的 RSA 安全密钥。
func fromPublicKeyPemFile(String)
cangjie
public static func fromPublicKeyPemFile(path: String): RsaSecurityKey功能:从 PEM 文件加载 RSA 公钥。
参数:
- path:
String- 公钥 PEM 文件路径。
返回值:
- RsaSecurityKey - 创建出的 RSA 安全密钥。
func fromPrivateKeyPemFile(String)
cangjie
public static func fromPrivateKeyPemFile(path: String): RsaSecurityKey功能:从 PEM 文件加载 RSA 私钥。
参数:
- path:
String- 私钥 PEM 文件路径。
返回值:
- RsaSecurityKey - 创建出的 RSA 安全密钥。
func fromPemFiles(String, String)
cangjie
public static func fromPemFiles(publicKeyPath: String, privateKeyPath: String): RsaSecurityKey功能:同时从 PEM 文件加载 RSA 公钥和私钥。
参数:
- publicKeyPath:
String- 公钥 PEM 文件路径。 - privateKeyPath:
String- 私钥 PEM 文件路径。
返回值:
- RsaSecurityKey - 创建出的完整 RSA 密钥对。