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
1 answer

Crypto module is not visible to Python after installation on Windows XP

I'm trying to use the Crypto module in Python. I downloaded the Windows installer that was referenced here on StackOverflow (an msi) and the installation went fine. However, when the interpreter hits the 'from Crypto.Cipher import AES' line in my…
CajunTechie
  • 605
  • 1
  • 8
  • 21
5
votes
1 answer

(Crypto++) How to realize media file encryption?

I am new to Crypto++ and want to "convert" the text encryption code I found online to a Crypto++ file encryption. Basically, an image file is just a bunch of text which needs to be read in chunks, am I right? I want to read an image file and encrypt…
Johnny Rebel
  • 51
  • 1
  • 2
5
votes
1 answer

DESFire Key Diversification AV1

I've implemented AES Key Diversification AV2 and now I´m wondering what is SAM AV1 and how does it work? Any one can share a link or give some informatione? Just to share some knowledge an example for AV2: /* * Diversification Example: …
Felix Arnold
  • 839
  • 7
  • 35
5
votes
3 answers

DES encryption in Java vs .NET - why different?

I have a .NET method for doing DES encryption on a string: public static string EncryptTripleDES(string value, byte[] encryptionKey, byte[] initializationVector) { if (!value.IsNullOrEmpty()) { TripleDESCryptoServiceProvider cryptoProvider =…
Shaul Behr
  • 36,951
  • 69
  • 249
  • 387
5
votes
2 answers

El Gamal faster than RSA with the same modulus length?

Why is El Gamal faster than RSA with the same modulus length?
Daniel Gartmann
  • 11,678
  • 12
  • 45
  • 60
5
votes
0 answers

Streaming video encrypted by AES GCM in NodeJs

I have some code that streams unencrypted video from S3, now I want to make it work for encrypted video files, for this purpose I use AES GCM. However, html5 player fails to play it. I tried to decrypt the full file and it worked(without streaming).…
5
votes
1 answer

How can I decrypt a file in C# which has been encrypted by des.exe?

I have a file which has been encrypted by des.exe. A file can be encrypted and decrypted using the following commands: des -E -k "foo" sample.txt sample.txt.enc des -D -k "foo" sample.txt.enc sample.txt.dec I have attempted to decrypt using the…
MaYaN
  • 6,683
  • 12
  • 57
  • 109
5
votes
2 answers

exchange of public key as a serialized object

How to exchange the public key to the client place. i have encrypted a document(text file) using RSA algorithm by using private key and then stored the public key as an java.security.Key object in a file using serialization.I want to know about the…
Lalchand
  • 7,627
  • 26
  • 67
  • 79
5
votes
1 answer

What is the use of the responderID in the OCSP response?

I am not clear on the use of the responder ID in the definition of the OCSP response. I am doing OCSP checks via Java's PKIX APIs. Using a third party library I get (during the OCSP response…
Cratylus
  • 52,998
  • 69
  • 209
  • 339
5
votes
2 answers

Breaking Vigenere only knowing key length

Problem I want to decode a message encrypted with classic Viginere. I know that the key has a length of exactly 6 characters. The message…
Ollie Jones
  • 55
  • 1
  • 5
5
votes
2 answers

how to decrypt with random nonce in AES encryption

I am new in cryptography. I need to encrypt a text using AES with some configuration Encryption mode: GCM Key size: 256 bits Nonce size: 96 bits MAC size: 128 bits As AES is a symmetric algo. so i have a secrete key. I googled and found nonce is…
nitin verma
  • 616
  • 1
  • 6
  • 22
5
votes
1 answer

How can I generate a cryptographically secure pseudo-random number in Javascript?

Is there a Cryptographically Secure Pseudo-Random Number Generator (CSPRNG) in Javascript? I know I can generate a pseudo-random number using Math.random(); function getRandomInt(max) { return Math.floor(Math.random() * Math.floor(max)); } In…
CloudBranch
  • 1,434
  • 3
  • 18
  • 23
5
votes
0 answers

Has Curve25519 been replaced in NaCL library?

I am using NaCL library and I like it but I wonder what is required to replace Curve25519 with different, stronger curve if stronger encryption is needed. I do understand that new library would be incompatible with NaCL.
user3130782
  • 841
  • 1
  • 6
  • 15
5
votes
1 answer

Elliptic Curve Cryptography in React Native

Does anyone know if there is an implementation of Elliptic Curve Diffie Hellman cryptography (ECDH) for React Native? I found some libraries for this. each of them has some issues: react-native-ecc: it only generates key pairs and does not…
Emad Bayat
  • 177
  • 1
  • 2
  • 12
5
votes
2 answers

How to fix ImportError: No module named cryptography?

I want to auto renew certificate via certbot, but not working, got error "ImportError: No module named cryptography" # ./certbot-auto --dry-run Error: couldn't get currently installed version for /opt/eff.org/certbot/venv/bin/letsencrypt: Traceback…
Eric
  • 303
  • 1
  • 8
  • 19