cryptography

encrypt- decrypt with SHA256 using java

Hi guys. Please help me the code (Java) to encrypt and decrypt ( will be better if using private key) with SHA256. ^^ Thank you so much! ...

Crypto library suitable for Objective-C

I'm looking for a crypto library to use with Objective-C code. There is a C++ library which is too big for my needs. It's 20 mb when compiled. I think a C library would be perfect to use with Objective-C. Here is my needs for this library: AES (Rijndael) CFB Mode SHA1 SHA256 HMAC-SHA1 HMAC-SHA256 PBKDF2 Your help will be greatly apprec...

Java and C++ Cryptography interoperability

I have a message coming from an external company which has been encrypted with our public key using Java. Specifically the java code performing the encryption is - //get instance of cipher using BouncyCastle cryptography provider Cipher cipher = Cipher.getInstance( "RSA/ECB/PKCS1Padding", "BC"); //initialize the cipher with th...

Reading a ASN.1 DER-encoded RSA Public key

I'm writing an app to get a better understanding of DKIM. The spec says I retrieve a "ASN.1 DER-encoded" public key from the domain TXT record. I can seen the key on "s1024._domainkey.yahoo.com" = "MIGfMA0GCSqGSIb3DQEBAQUAA4GNADCBiQKBgQDrEee0Ri4Juz+QfiWYui/E9UGSXau/2P8LjnTD8V4Unn+2FAZVGE3kL23bzeoULYv4PeleB3gfm". How can I use this key...

Asp.net client side cryptography

Hello! How can I sign data with standard .net crypto providers on client side? ...

Why is MD5'ing a UUID not a good idea?

PHP has a uniqid() function which generates a UUID of sorts. In the usage examples, it shows the following: $token = md5(uniqid()); But in the comments, someone says this: Generating an MD5 from a unique ID is naive and reduces much of the value of unique IDs, as well as providing significant (attackable) stricture on the ...

Cryptography: Decode CRAM-MD5 algorithm

I have an ASP.Net web application where I would like to implement cryptography for password security. I am not using SSL. For that i studied and pick CRAM-MD5 algorithm for password authentication. I have implement javascript cram-md5 algorthim available at http://pajhome.org.uk/crypt/md5/ Here i would like to know that is there anyone...

What are the standard encryption file formats?

I'm a bit confused on encryption file formats. Let's say I want to encrypt a file with AES-256. I run the file through the encryption algorithm and I now have a stream of encrypted bytes. I obviously can write that stream of bytes to a file, but any third-party encryption application is not going to understand it since it's not expect...

C# How to Generate Unique Public and Private Key via RSA

I am building a custom shopping cart where CC numbers and Exp date will be stored in a database until processing (then deleted). I need to encrypt this data (obviously). I want to use the RSACryptoServiceProvider class. Here is my code to create my keys. public static void AssignNewKey(){ const int PROVIDER_RSA_FULL = 1; const...

concrete example breaking xor encryption with five bits

i am new to xor encryption and the task i have uses five bits not ascii. how do i break it?am looking for a concrete example of breaking. ...

replace rand() with openssl_random_pseudo_bytes()

I need a replacement for PHP's rand() function that uses a cryptographically strong random number generator. The openssl_random_pseudo_bytes() function gets you access to the strong random number generator, but it outputs its data as a byte string. Instead, I need an integer between 0 and X. I imagine the key is to get the output of o...

PHP: mcrypt mangles beginning of string to garbage

I need medium to strong encryption on serverside, so I thought I would use mcrypt with PHP. If I use the functions below the beginning of my original string turns into binary garbage after decryption. (This is not the usual problem of getting appended additional garbage, instead my string is altered.) According to the documentation, mcry...

Java ANSI X923 Padding

I have a new application written in java that needs to read encrypted values out of a db. The problem is that all the values in the db were encrypted by .NET code that uses the ANSI x923 padding scheme. I have done some research and it doesn't look like the Java TripleDes libraries have a way to specify this padding scheme. I was wond...

Implementing des-ede2 in vb.net

Can anyone help me getting started with this? We have a current keygen for a set of our apps that's using des-ede2 in C++. I need to make my vb.net app validate keys generated by that keygen. Anyone have any ideas where to start? I'm googling like mad, but hoping someone can point me in the right direction. Thank you! ...

Software security Module/ toolkit replacing HSM for developing crypto functions

Hello I worked and completed a PKI project which used a HSM for generating - storing keys and performing crypto functions. I used PKCS#11 to interface with our application for sigining/verifying and encryption/decryption. Our platform is windows. Now we are looking to offer a low cost alternative solution by replacing the the HSM with ...

Verifying equivalence of a secret

Alice & Bob are both secret quadruple agents who could be working for the US, Russia or China. They want to come up with a scheme that would: a) if they are both working for the same side, prove this to each other so they can talk freely. b) if they are working for different sides, not expose any additional information about which side...

java to python conversion: x509 / dsa / sha1withdsa crypto howto?

I've got the following Java code that I'm trying to convert to python, and I'm not really sure how to do this: import java.security.spec.X509EncodedKeySpec; import java.security.KeyFactory; import java.security.PublicKey; import java.security.Signature; byte[] key = KeyReader.read(filestream) //KeyReader.read(inputstream) just reads...

CSP Out of memory with CryptVerifySignature

I have an issue with CryptVerifySignature returning NTE_NO_MEMORY (The CSP ran out of memory during the operation.) I'm trying to verify an signature generated with OpenSSL, I've already decoded a PEM public key, reversed the byte-sequence and imported it. I've tried explicity specifying the MS Enhanced Provider, and my key length is 4...

Choosing a cryptography library

Duplicate of this and this. I'm looking for a free C or C++ cryptography library that can be embedded in a closed-source applicationand supports RSA public-key cyphering. I've found OpenSSL and Crypto++ but neither have a good documentation for a beginner. Anyone knows a good, free, C or C++ cryptography library with a decent docu...

Is it safe to use PBKDF2 with SHA256 to generate 128-bit AES keys?

I want to use PBKDF2 with some cryptographic hash function to generate 128-bit AES keys. SHA1 is also 128-bit, so I thought of using that with PBKDF2, but it was broken, so I have opted to use SHA256 instead. Is this safe, or will the difference between the hash size and resulting key size cause some sort of disastrous silent truncation ...