bouncycastle

Signing a string with RSA private key on .NET?

僤鯓⒐⒋嵵緔 提交于 2019-12-17 17:14:34
问题 byte[] plaintext = System.Text.Encoding.UTF8.GetBytes("AAAAAAAAAAAAA"); TextReader trCer = new StreamReader(@"AA.key"); //key in PEM format PemReader rdCer = new PemReader(trCer); AsymmetricCipherKeyPair o = rdCer.ReadObject() as AsymmetricCipherKeyPair; ISigner sig = SignerUtilities.GetSigner("MD5WithRSAEncryption"); sig.Init(true, o.Private); sig.BlockUpdate(plaintext,0,plaintext.Length); Byte[] signature = sig.GenerateSignature(); string signatureHeader = Convert.ToBase64String(signature);

PBKDF2 in Bouncy Castle C#

穿精又带淫゛_ 提交于 2019-12-17 16:08:40
问题 I've being messing around the C# Bouncy Castle API to find how to do a PBKDF2 key derivation. I am really clueless right now. I tried reading through the Pkcs5S2ParametersGenerator.cs and PBKDF2Params.cs files but i really cant figure out how to do it. According to the research I have done so far, PBKDF2 requires a string (or char[]) which is the password, a salt and an iteration count. So far the most promising and most obvious i've come so far is the PBKDF2Params and

Bouncy Castle : PEMReader => PEMParser

不问归期 提交于 2019-12-17 06:46:16
问题 With a PEM certificate like -----BEGIN RSA PRIVATE KEY----- Proc-Type: 4,ENCRYPTED DEK-Info: AES-256-CBC,B9846B5D1803E..... using BC 1.46, I extract the keypair with the following code : int myFunc(String pemString, char [] password) { ByteArrayInputStream tube = new ByteArrayInputStream(pemString.getBytes()); Reader fRd = new BufferedReader(new InputStreamReader(tube)); PEMReader pr = new PEMReader(fRd, new Password (password), "BC"); try { Object o = pr.readObject(); if (o instanceof

Hash String via SHA-256 in Java

丶灬走出姿态 提交于 2019-12-17 03:24:08
问题 By looking around here as well as the internet in general, I have found Bouncy Castle. I want to use Bouncy Castle (or some other freely available utility) to generate a SHA-256 Hash of a String in Java. Looking at their documentation I can't seem to find any good examples of what I want to do. Can anybody here help me out? 回答1: To hash a string, use the built-in MessageDigest class: import java.security.MessageDigest; import java.security.NoSuchAlgorithmException; import java.nio.charset

Encrypt and Decrypt data using Blowfish/CBC/PKCS5Padding

三世轮回 提交于 2019-12-14 03:48:52
问题 A legacy application (ColdFusion) is using Blowfish/CBC/PKCS5Padding encryption. How can we encrypt and decrypt this data using the BouncyCastle lib? For other fields, encrypted in ColdFusion using this: encrypt( data, key, 'BLOWFISH', 'HEX') We use this code BlowfishEngine engine = new BlowfishEngine(); PaddedBufferedBlockCipher cipher = new PaddedBufferedBlockCipher(engine); cipher.Init(false, new KeyParameter(Convert.FromBase64String(keyString))); byte[] out1 = Hex.Decode(name); byte[]

“Not trusted Server Certificate” in Android 2.2 but not 3.0

六眼飞鱼酱① 提交于 2019-12-14 00:48:51
问题 I'm using the BouncyCastle provider and Apache HttpClient to trust an SSL certificate, as described by Antoine Hauck here. The app I've made targets Android 1.5, and works fine on the emulator and a device running 3.0. However, when I try to test it on 2.2 (Galaxy S), an SSLException, "Not trusted Server Certificate", occurs. Since there's no errors complaining about BouncyCastle itself, I'm assuming the device is not reading the certificates properly from the .bks file. Is what I'm

writing php MCrypt twofish for c# bouncycastle

给你一囗甜甜゛ 提交于 2019-12-13 22:05:07
问题 I'm learning how to use the BouncyCastle c# cipher library for doing encryption. I'm not looking to send messages so I'm not thinking about security etc. I have written my c# code in Visual Studio. Here is the problem. I have encrypted the text " Hello World! ", using Twofish in CFB mode. The key is 1234567812345678. I've used phpfiddle http://phpfiddle.org/ online tool. $algo = 'twofish'; $mode = 'cfb'; $cipher = mcrypt_module_open($algo,'',$mode,''); $key = hex2bin(

How to decrypt a private key in Java (without BC openssl)

我的未来我决定 提交于 2019-12-13 17:11:31
问题 Is it possible decrypt an encrypted RSA (or others, shouldn't matter) private keys using JCE and/or BouncyCastle provider (not using openssl bundle)? I can read unencrypted keys just fine using PrivateKeyFactory. Googling this gets me through examples of using PEMReader (from BC openssl bundle) that has a password applied to it, but - don't want to use openssl bundle, don't necessarily want to use PEM format, and I can decode PEM using PemReader (from provider bundle). It's what can I do with

Generating digital certificates using Bouncycastle

╄→尐↘猪︶ㄣ 提交于 2019-12-13 12:44:24
问题 I have determined, after some research, that in order to generate and sign certificates programmatically in java I need the bouncycastle library. Unfortunately it appears that the library has gone through a major overhaul sometime fairly recently. A great deal of their classes are now deprecated and all of the tutorials and code samples I can find that are simple enough to understand are deprecated along with them. I am reasonably new to cryptography. Armed with only basic knowledge and fuzzy

BouncyCastle J2ME RSA using custom keys

梦想的初衷 提交于 2019-12-13 12:42:34
问题 I would like to use BouncyCastle J2ME/RIM Crypto in my Blackberry Application. The issue i'm having is that I would like to generate the public key for encryption from a C#.NET program that sends the key to the BlackBerry. Is it possible to encrypt a message using a raw string? Also, do I need to know other common variable such as modulo etc? Apologies but i'm completely new to cryptography algorithms. Do I need BouncyCastle for this or can the above be done with RIM Crypto? Thanks, Conor 回答1