Questions tagged [cryptography]

CRYPTOGRAPHY MUST BE PROGRAMMING RELATED. Cryptography covers, among other things, symmetric and asymmetric 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 transferred 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 transferred 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: , , ,

14876 questions
5
votes
2 answers

Is still valid password hashing using md5 or sha1?

Just now I'm working in a financial project. Here, the team is thinking to use MD5 for password hashing. But, today is easy copy a SHA1 or MD5 password to decrypt, inclusive if they are complex password like: My$uper$ecur3PAS$word+448, you might use…
Benjamin RD
  • 11,516
  • 14
  • 87
  • 157
5
votes
1 answer

python - cryptography - generate new RSA private key

I need a function that generates me a new RSA private key that can then be stored as a string in a Django model field. I'm using cryptography==2.1.4. I though I had accomplished that through: from cryptography.hazmat.primitives import…
Luke
  • 1,794
  • 10
  • 43
  • 70
5
votes
4 answers

How to benchmark a crypto library?

What are good tests to benchmark a crypto library? Which unit (time,CPU cycles...) should we use to compare the differents crypto libraries? Are there any tools, procedures....? Any Idea, comment is welcome! Thank you for your inputs!
Daniel Gartmann
  • 11,678
  • 12
  • 45
  • 60
5
votes
1 answer

javax.crypto.BadPaddingException: Decryption error when using Java RSA encryption

I'm trying to set up RSA encryption so I can make a simple library for myself to use in the future and I can't get this simple code to work. Here is the source code: package rsa.testing; import java.security.KeyPair; import…
liaquore
  • 403
  • 8
  • 22
5
votes
1 answer

How does libgcrypt increment the counter for CTR mode?

I have a file encrypted with AES-256 using libgcrypt's CTR mode implementation. I want to be able to decrypt the file in parts (e.g. decrypting blocks 5-10 out of 20 blocks without decrypting the whole file). I know that by using CTR mode, I should…
E1adi
  • 77
  • 4
5
votes
2 answers

Key Strengthening. Am I Doing It Right?

I am writing a class to hash passwords which implements Key Stretching by using the System.Security.Cryptography.Rfc2898DeriveBytes class to generate the keys used to compute the hash value. The code essentially does this: // Higher iterations value…
Rudy
  • 75
  • 6
5
votes
1 answer

How to construct private key from generated previously ECDSA both encoded key pair?

Having generated the private key like this: fun getKeyPair(): Pair { Security.addProvider(provider) val generator = KeyPairGenerator.getInstance("ECDSA") val ecSpec =…
K.Os
  • 5,123
  • 8
  • 40
  • 95
5
votes
3 answers

Html.AntiForgeryToken() causeing errors after upgrading to .NET 3.5 SP1

I've just updated to .NET 3.5 SP1 and my once working ASP.NET MVC page has now stopped working. When trying to load a page I get the following YSOD [CryptographicException: Padding is invalid and cannot be removed.] …
Remmus
  • 505
  • 3
  • 9
5
votes
1 answer

Steam OpenID Signature Validation

I've been having this issue for a while now. I'm trying to add a Sign in through Steam button, which upon login, not only retrieves the user's ID, but also validates the signature. Steam uses OpenID 2.0. I have followed the documentation here. I…
troffaholic
  • 185
  • 1
  • 10
5
votes
3 answers

Using WebCrypto to generate ECDH key from PBKDF2

WARNING The following is not intended as an endorsement of converting passwords to ECDH keys. Create ECDH keys from high-entropy, crypto-safe PRNGs. I want to take a secret and generate a ECDH public/private key from it. In the browser, a usual…
Brian M. Hunt
  • 81,008
  • 74
  • 230
  • 343
5
votes
2 answers

Reverse Jenkins' one-at-a-time hash

How would I go about obtaining any possible string value that matches a returned hash? I don't want to obtain the exact key that was used, just any key that when passed into the function, will return the same hash of the unknown key. uint32_t…
Joseph Jones
  • 187
  • 3
  • 10
5
votes
1 answer

convert crypto.subtle.deriveKey result to hex string

according to bip39 standard, I want to get seed from mnemonic words in javascript. I use this code: function mnemonicToSeed(mnemonic,passphrase){ if (typeof passphrase != 'string') passphrase=''; window.crypto.subtle.importKey( …
saeid ezzati
  • 855
  • 11
  • 29
5
votes
1 answer

Extracting the public key from the private key

I trying to accomplish step (2) in the following way programmatically: 1. openssl genrsa -out signing.pem 2048 2. openssl rsa -in signing.pem -outform PEM -pubout -out signing.pub.pem Following is a simple function which reads the private key and…
Invictus
  • 2,653
  • 8
  • 31
  • 50
5
votes
2 answers

Asymmetric digital signature Node.JS

I need to find some criptographic solution, which allows me to sign some data using private key, and check signature using public key. Would be great if there is some nodejs package. Thanks!
Anatoliy
  • 29,485
  • 5
  • 46
  • 45
5
votes
6 answers

Time complexity of a brute-force embedded MD5sum

A question I've been meaning to have answered for a long time - What would be the time complexity of finding an MD5sum of a compiled binary that contains that same MD5 statically embedded in it, say, as a string? Edit: If this wasn't already clear.…
atx
  • 4,831
  • 3
  • 26
  • 40