cryptography

Protecting RSACryptoServiceProvider private key with password or otherwise

I want to encrypt some server data using .NET's RSACryptoServiceProvider and decrypt it when someone enters a key/password via a web page. What are my options for protecting, or ideally not even storing, the private key on the server, whilst avoiding having the user supply it all each time? Encrypt the private key using a symmetric sys...

Reading Private Key in PEM format with LockBox

I have to digitally sign a string using the SHA-1 algorithm with RSA using PKCS#1 padding. I have downloaded Turbo Power Lockbox. The private key I have is in PEM format and was created using openssl: openssl req -x509 -nodes -days 365 -newkey rsa:1024 -sha1 -subj "/C=US/ST=CA/L=Mountain View/CN=www.mycompany.com" -keyout myrsake...

Illegalkeysize exception

I am using the Bouncy Castle Java cryptographic algorithm implementation. I am getting an IllegalKeySizeException. To overcome this I have even changed my java security jars (local_policy.jar and US_Export_policy.jar), but I am still getting the same problem. Can anyone suggest a solution for this (I am using centos operating system)? ...

Digitially Sign Key with Lockbox

I have to digitally sign a string using the SHA-1 algorithm with RSA using PKCS#1 padding. I have downloaded Turbo Power Lockbox to use with the Delphi programming language. In a previous question I have learned how to convert private key from PEM format to DER format (which if I understand correctly is ASN.1 format and is used with Loc...

How should I generate an initialization vector?

I'm sure there's not one answer to this question, but just trying to find out a general approach. Using Java 1.4.2, I need to generate a key and IV for use in a symmetric algorithm. These values will be pre-shared with the recipient through a secure channel. The key I can generate with KeyGenerator.keyGenerate(). But unless I'm missi...

Generate all combinations of a char array inside of a CUDA __device__ kernel

Hi, I need help please. I started to program a common brute forcer / password guesser with CUDA (2.3 / 3.0beta). I tried different ways to generate all possible plain text "candidates" of a defined ASCII char set. In this sample code I want to generate all 74^4 possible combinations (and just output the result back to host/stdout). $...

Is it possible to use AES with an IV in ECB mode?

From http://php.net/manual/en/function.mcrypt-encrypt.php, I saw the following codes using AES with an IV in ECB mode, <?php $iv_size = mcrypt_get_iv_size(MCRYPT_RIJNDAEL_256, MCRYPT_MODE_ECB); $iv = mcrypt_create_iv($iv_size, MCRYPT_RAND); $key = "This is a very secret key"; $text = "Meet me at 11 o'clock behind the mon...

AES 256 in CTR mode

ctr mode makes it possible to use a block cipher as a stream cipher but how strong will be the encryption in this mode ? ...

Registering multiple keystores in JVM

Hello, I have two applications running in the same java virtual machine, and both use different keystores and truststores. A viable option would be use a single keystore and import all the other ones into the shared keystore (e.g. keytool -import), but it would really help my requirements if I could use separate keystores for separate ...

How does this PHP nonce library work?

From http://fullthrottledevelopment.com/php-nonce-library#download, there is a PHP nonce library, but there are a few things that I don't know understand. The first one is that it reminds us to set a value for the FT_NONCE_UNIQUE_KEY but it never uses it in any of its functions. The second thing is, when I call the ft_nonce_create_query...

how to read a RSA public key from a pem file OR xml file

Hello, I have a simple thing to do : I want to encryt data using AES algorythm and a key contained in a pem file, like shown on the page : http://msdn.microsoft.com/en-us/library/sb7w85t6.aspx In this example, a new encryption key is created every time the function is run. But I need to read this key from either a pem file or an xml...

Importing a private-public exchange key pair

Hi I want to export a RSA 1024 private-public exchange key pair from Machine-1 to Machine-2. I am using cryptoAPI in XP. In Machine-1, i generated the key pair. I wrapped a session key which actually encrypts some real data. The key container name is "PAIR1". In Machine-2, i wanted to unwrap the session key with the private key(which ...

Simple caesar cipher in java

Hey I'm making a simple caesar cipher in Java using the formula [x-> (x+shift-1) mod 127 + 1] I want to have my encrypted text to have the ASCII characters except the control characters(i.e from 32-127). How can I avoid the control characters from 0-31 applying in the encrypted text. Thank you. ...

How to sign an XML file with a RSA key in .NET?

I am trying to sign an XML file in C# .NET 3.5 with a private RSA Key generated by OpenSSL. Here is how I proceeded: I converted the RSA key from PEM format to XML format using the chilkat framework (www.example-code.com/csharp/cert_usePrivateKeyFromPEM.asp) With my XML key, I am now able to use native .NET Functions, which I prefer. S...

Storing a SHA512 Password Hash in Database

In my ASP.NET web app I'm hashing my user passwords with SHA512. Despite much SO'ing and Googling I'm unclear how I should be storing them in the database (SQL2005) - the code below shows the basics of how I'm creating the hash as a string and I'm currently inserting it into the database into a Char(88) column as that seems to be the le...

Debugging Signature Verification failure

Using Java 1.4.2 with unlimited jurisdiction policy files installed. I have a class that has been successfully signing and verifying. However, now I've changed the keys and suddenly verification is failing. Keys were generated with: openssl genrsa -aes256 -out production_private.pem 2048 openssl pkcs8 -topk8 -nocrypt -in production_p...

how to "mix" two numbers into one hex-string

How to generate a code from two numbers, that when you know this code and one of the numbers you can descramble the second number? For example you have two numbers: 983 and 2303 and you "mix" it into hex-string like this:4b17a190bce4ea32236b98dd. When you know first number and this hex-string you can descramble second number. But when yo...

ASP.NET Rijndael Encryption Error - Specified key is not a valid size for this algorithm.

I can't seem to get past this problem, I've created what I assume to be a 256-bit key using the random generator at GRC and combined that with my IV. I keep getting the error below: Specified key is not a valid size for this algorithm. Any help is gratefully received, here is the code I am using to Encrypt/Decrypt: Private Function R...

ASP.NET Rijndael Decryption Error: Length of the data to decrypt is invalid.

OK, so having just got the key to be accepted and have an encrypted string out which is 44 char long, I now am unable to decrypt (aarrgghh): Length of the data to decrypt is invalid. Having looked around and read various posts it looks as though the conversion to a Base64String may be the problem but I can't see where it is wrong - man...

crypto++ RSA and "invalid ciphertext"

Hello all Well, I've been going through my personal hell these days I am having some trouble decrypting a message that was encrypted using RSA and I'm always failing with a "RSA/OAEP-MGF1(SHA-1): invalid ciphertext" I have a private key encoded in base64 and I load it: RSA::PrivateKey private_key; StringSource file_pk(PK,tru...