Questions tagged [cryptography]

CRYPTOGRAPHY MUST BE PROGRAMMING RELATED. Cryptography covers, among other things, encryption, hashing and digital signatures. Cryptography questions not directly related to software development are better asked at crypto.stackexchange.com.

CRYPTOGRAPHY MUST BE PROGRAMMING RELATED.

Cryptography (from the Greek for "secret/hidden writing") is the practice and study of techniques for secure communication and processing in the presence of third parties. There are general three properties that we associate with secure communication:

  • confidentiality: some information must be stored or transfered without permitting unauthorized entities to read it;
  • integrity: some information must be stored or transfered without allowing any alteration by an unauthorized entity to go unnoticed;
  • authenticity: some information must be stored or transfered in such a way that the originator of the information can be verified, in a way which unauthorized entities cannot falsify.

"Entities" are persons, roles or systems which are supposed to be distinct from each other according to some definition. Cryptography operates in the logical world of computers, from which the physical world is out of reach; anybody can buy a PC, so what distinguishes one user on a network from another (as seen through a network or any other communication protocol) is what that user knows. Cryptography calls such knowledge as a secret or key: this is a piece of secret data, which is used as parameter to a cryptographic algorithm that implements a cryptographic property with regards to the key.

For instance, symmetric encryption is about transforming some data (possibly a huge file), using a (normally short) key, into an encrypted form which shows no readable structure anymore, but such that the transformation can be reversed (recovering the original data from the encrypted form) if the encryption key is known. In a way, symmetric encryption concentrates confidentiality into the key, which can be short enough to be manageable (e.g. the key might be memorized by a human being, in which case it is called a password).

The cryptographic algorithms themselves are public, if only because nobody can really tell "how much" a given algorithm is secret, since algorithms are often implemented as software or hardware systems which are duplicated into many instances, and the cost of reverse engineering is hard to estimate. A cryptosystem (combination of an algorithm and its key) is then split into the algorithm, which is embodied as an implementation, and a key, for which security can be quantified (e.g. by counting the number of possible keys of a given length).

Cryptography covers the science of designing cryptographic algorithms (cryptology) and of trying to break them (cryptanalysis); it also encompasses the techniques used to apply the algorithms in various situations, in particular implementation as software, and the related subjects (such as performance issues). Some algorithms consist in the assembly of several sub-algorithms in order to obtain higher level properties (e.g. "a bidirectional tunnel for confidential data with verified integrity and mutual authentication"); they are then called protocols.

Commonly used cryptographic algorithms and protocols include, among others:

  • Symmetric encryption: 3DES, AES, RC4, Blowfish
  • Hash functions: MD5, SHA-1, SHA-2 (includes SHA-256 and SHA-512)
  • Asymmetric encryption: RSA
  • Digital signatures: RSA (similar, but not identical to, the RSA for encryption), DSA (as part of the "DSS" standard), ECDSA
  • Data tunneling: TLS (formerly known as "SSL"; when used to convey HTTP requests, the result is known as "HTTPS"), SSH, IPsec
  • Encrypted and/or signed emails: OpenPGP (standard protocol derived from the original PGP software), S/MIME
  • Certificates: X.509, OpenPGP (certificates are about binding identities to public keys, which are themselves used in asymmetric encryption and digital signatures)
  • Key sharing (or Key exchanging): diffie-hellman, PKI (Protocols and infrastructures to establish cryptographic keys between parties for confidential communication.)

On-topic themes also include password management (storage, verification, entropy, breaking techniques such as rainbow tables...), advanced multi-party protocols (electronic voting schemes, digital cash, anonymous browsing...), usage of existing implementations (libraries, hardware accelerators, smartcards...), and so on.

Questions not directly related to software development (e.g. the more theoretic ones) are better asked in the Cryptography Stack Exchange site (still in beta).

See also: , , ,

13045 questions
5
votes
1 answer

PKCS#7 data payload unpacking with NodeJS?

I'm working on an MDM NodeJS server for iOS. On the Apple docs, the following ruby code is given : p7sign = OpenSSL::PKCS7::PKCS7.new(req.body) store = OpenSSL::X509::Store.new p7sign.verify(nil, store, nil, OpenSSL::PKCS7::NOVERIFY) signers…
Olivier
  • 3,243
  • 5
  • 32
  • 52
5
votes
1 answer

iOS SecItemCopyMatching RSA public key format?

I'm trying to extract a 1024-bit RSA public key from an already generated key pair (two SecKeyRefs), in order to send it over the wire. All I need is a plain (modulus, exponent) pair, which should take up exactly 131 bytes (128 for the modulus and 3…
Vladimir Mitrovic
  • 1,740
  • 16
  • 15
5
votes
1 answer

Verifying Authenticode signed executables and DLLs using OpenSSL API

I have installed openssl and now the rsa_test.c is running fine. What I want to do is: Open any exe or dll digital certificate. Extract the Thumbprint and PublicKey. The public key contains the exponent too (if you are familiar with ASN1…
user1696837
5
votes
2 answers

Use of "SHA1PRNG" in SecureRandom Class

I have a basic question. Why 'SHA1PRNG' is used in SecureRandom Class. It will be helpful if someone explains about it. Thanks in advance. EX: SecureRandom.getInstance("SHA1PRNG");
meghanath ch
  • 63
  • 2
  • 6
5
votes
3 answers

Portable Class Library (PCL) Contrib - Cryptography

I want to use the cryptography in the Portable Class Library Contrib project on codeplex but have not found any documentation on how I can use it. I want to create a wrapper class with Encrypt and Decrypt methods inside it and I want this wrapper…
Muhammad Rehan Saeed
  • 28,236
  • 27
  • 169
  • 261
5
votes
2 answers

How do I obtain the public key from an ECDSA private key in OpenSSL?

I am providing this sample application to show my problem #include #include #include #include int main() { EC_KEY *pkey = NULL; EC_POINT *pub_key = NULL; const EC_GROUP *group =…
farmdve
  • 726
  • 3
  • 12
  • 24
5
votes
4 answers

Is a SecureRandom really needed for generating Initialization vectors or is Random enough?

For a stream cipher to be secure against repeated key attacks the IV's should not repeat themselves. But does SecureRandom have a benefit over a simple non-secure Random in that respect (or is it just for generating an unpredictable…
5
votes
1 answer

Verify detached signature (*.p7s files) and X509Certificate2

I receive an XML document as a string parameter in my method. The XML document is:         Zip_File_In_Base64      Certificate_In_Base64 From this string I…
Mike Gogi
  • 51
  • 1
  • 3
5
votes
2 answers

Is it safe to use a 128 bits key in HMAC-SHA256?

Facebook app secret is a string of 32 characters (0-9, a-f) and thus it represents a 128 bits byte array. Facebook uses this as the key to generate signed request using HMAC-SHA256. Is this a correct usage? I thought HMAC-SHA256 should use 256 bits…
Ethan
  • 17,810
  • 15
  • 46
  • 67
5
votes
3 answers

Is TLS over TLS possible?

Would it be possible to establish a TLS connection over TLS with OpenSSL or some other tool? If possible, would the certificates for each level need to be different?
xor
  • 561
  • 3
  • 13
5
votes
2 answers

Is there a perl implementation of SHA256withRSA

I need to be able to craft JSON Web Token signatures (which only accepts 'RSASSA-PKCS1-V1_5-SIGN with the SHA-256 hash function' signatures), but the obvious CPAN contender for this task (Crypt::RSA) will only generate signatures using MD2, MD5 or…
Cebjyre
  • 6,404
  • 3
  • 28
  • 57
5
votes
5 answers

How do I feed OpenSSL random data for use in ECDSA signing?

I want to feed OpenSSL specific data for use as random seed during the signing of data with an EC key. I'm doing this to compare my application with another reference one (closed source). That utility takes the file with private key, file with data…
Belrog
  • 910
  • 1
  • 11
  • 18
5
votes
4 answers

Cryptography in Java

I'm making an app that encrypts some files. I want to use gnu's cryptix library. It says it is no longer developed since 2005, but I guess it has everything I need... should I use something else? And I have a question about encrypting a single file.…
user568021
  • 1,277
  • 4
  • 22
  • 51
5
votes
3 answers

Bcrypt(4) (=4 iterations) versus SHA512 or something different with unique salt per password?

Background: I want to add a login to my small site, which is an online php application, which I'd like to build to be able to bear much user activity in the future. Before I look further into implementing LightOpenID I want to add a normal login.…
Suzy
  • 75
  • 6
5
votes
1 answer

Node.js: crypto.pbkdf2 password to hex

I currently use following set up to register new users: // creates a new user app.post('/users', function(req, res) { // create new user var user = new User(); // assign post user.username = req.body.username; user.email =…
bodokaiser
  • 13,492
  • 20
  • 90
  • 133
1 2 3
99
100