简体   繁体   English

是否有与 Java 的 BouncyCastleStore 等效的 C#?

[英]Is there a C# equivalent of Java's BouncyCastleStore?

I have a password protected Bouncy Castle key store file created with Bouncy Castle Java API, and I can read key from that store using following Java code:我有一个使用 Bouncy Castle Java API 创建的受密码保护的 Bouncy Castle 密钥存储文件,我可以使用以下 Java 代码从该存储中读取密钥:

BouncyCastleStore uberStore = new BouncyCastleStore();
char[] uberStorePassword = props.getProperty("keystore.pwd").toCharArray();
FileInputStream finUberStore = new FileInputStream(props.getProperty("keystore.path"));
uberStore.engineLoad(finUberStore, uberStorePassword);
KeyStore.PasswordProtection keystorePassProt = new KeyStore.PasswordProtection(uberStorePassword);
SecretKey aesKey = ((KeyStore.SecretKeyEntry) uberStore.engineGetEntry(props.getProperty("keystore.alias"), keystorePassProt)).getSecretKey();

On the other hand, I have an application in C#, where I have to do some AES-EAX encryption using key stored in the Bouncy Castle key store.另一方面,我有一个 C# 应用程序,我必须使用存储在 Bouncy Castle 密钥库中的密钥进行一些 AES-EAX 加密。

While most of the classes in Bouncy Castle Java cryptography API have their equivalent in Bouncy Castle C# API, I couldn't find any class in Bouncy Castle C# API that resembles BouncyCastleStore.虽然 Bouncy Castle Java 加密 API 中的大多数类在 Bouncy Castle C# API 中都有对应的类,但我在 Bouncy Castle C# API 中找不到任何类似于 BouncyCastleStore 的类。 Therefore I was not able to extract key from the Bouncy Castle key store file via C#.因此,我无法通过 C# 从 Bouncy Castle 密钥存储文件中提取密钥。 Is it possible to read this key store using c#?是否可以使用 c# 读取此密钥库?

Edit : I've rephrased my inital question because it was somehow misleading (thanks to @cryptic_star).编辑:我改写了我最初的问题,因为它在某种程度上具有误导性(感谢@cryptic_star)。 My goal is not to make exact translation of sampled Java code, but to find whatever possible way to extract key from Bouncy Castle key store using C#.我的目标不是对示例 Java 代码进行精确翻译,而是找到任何可能的方法来使用 C# 从 Bouncy Castle 密钥库中提取密钥。

BouncyCastle on C# can only read PKCS12 files or PEM (Base64 coded) files. C# 上的 BouncyCastle 只能读取 PKCS12 文件或 PEM(Base64 编码)文件。 Currently I don't see a way to read jks.目前我看不到阅读 jks 的方法。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM