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

How does the TLS Record Protocol reassemble received data?

I can't find detailed information about how the TLS Record Protocol is able to reassemble received data. In the RFC 5246: Received data is decrypted, verified, decompressed, reassembled, and then delivered to higher-level clients. But HOW? This…
kejsarn
  • 75
  • 4
5
votes
0 answers

Hash large files with crypto.subtle.digest("SHA-256", buffer)

i have developed a web application where a user can select multiple files via a input field. Then the sha-256 checksums are calculated by the following code. The code (taken from developer.mozilla.org) only works for small files. What do I have to…
Jürgen
  • 71
  • 2
5
votes
1 answer

How to generate a shorter private key for ECDSA (secp256k1) in Python Cryptography

I'm trying to learn how to create a bitcoin address by following this guide. If you scroll down, the first step, step 0, is to have a 256 bit (64 hex) long ECDSA key. I looked into Python Cryptography and am using the code below to test generating…
mucle6
  • 645
  • 1
  • 10
  • 24
5
votes
5 answers

NodeJS implementation for Python's pbkdf2_sha256.verify

I have to translate this Python code to NodeJS: from passlib.hash import pbkdf2_sha256 pbkdf2_sha256.verify('12345678', '$pbkdf2-sha256$2000$8R7jHOOcs7YWImRM6V1LqQ$CIdNv8YlLlCZfeFJihZs7eQxBsauvVfV05v07Ca2Yzg') >> True The code above is the entire…
Alexander
  • 7,484
  • 4
  • 51
  • 65
5
votes
1 answer

How to break repeating-key XOR Challenge using Single-byte XOR cipher

This Question is about challenge number 6 in set number 1 in the challenges of "the cryptopals crypto challenges". The challenge is: There's a file here. It's been base64'd after being encrypted with repeating-key XOR. Decrypt it. After that…
Yonlif
  • 1,770
  • 1
  • 13
  • 31
5
votes
3 answers

Is there an implementation of ID-based encryption?

I've been reading up about ID-based encryption, but can't find any implementations (the maths in the paper is a bit much for me). Does anyone know where I might go looking to find an implementation? I don't really mind what language it's in.
fredley
  • 32,953
  • 42
  • 145
  • 236
5
votes
1 answer

pycryptodome : MAC Check Failed (using decrypt_and_verify)

I am working on an encryption program with Pycryptodome in Python 3.6 I am trying to encrypt a file and then decrypt it and verify the MAC tag. When I get to verify it, an error is thrown import os from Crypto.Cipher import AES bib Cryptodome…
jeff tran
  • 51
  • 1
  • 3
5
votes
1 answer

Why doesn't SSH use the interlock protocol?

It seems that the SSH designers cared a great deal about man in the middle attack. Their approach was, to save server's public key finger print at the first time you're connected to the server (and hope that the user doesn't connect from a poisoned…
Elazar Leibovich
  • 32,750
  • 33
  • 122
  • 169
5
votes
1 answer

BIP44 with ed25519 curve signature

I want to use BIP44 HD wallet with Ed25519 curve. Does BIP 44 support the Ed25519 curve, Because I have read that BIP32 does not compatible with Ed25519 based cryptography.
5
votes
1 answer

android.security.KeyStoreException: Unknown error On a rare number of devices

I'm getting android.security.KeyStoreException: Unknown error On a rare number of devices with different Android Versions (6 - 8) This is my key generation code: final KeyPairGenerator keyGenerator = KeyPairGenerator …
AndyB
  • 556
  • 1
  • 9
  • 25
5
votes
2 answers

How read a PKCS8 encrypted Private key which is also encoded in DER with bouncycastle?

I have tried answers of these questions: Bouncy Castle : PEMReader => PEMParser Read an encrypted private key with bouncycastle/spongycastle However as my encrypted key is encoded in DER when I call Object object = pemParser.readObject(); object…
Aloxi
  • 85
  • 2
  • 8
5
votes
4 answers

Decrypting the Same Cipher Text With Different Keys (AES)

Lets say I have a key - k, and plain text P. I then encrypt P with AES using key k: C = AES_k(P) Now lets say I have another plain text that I chose - P*.This plain text has nothing to do with P, I choose it to be whatever I want it to be. Is it…
qowpr
  • 51
  • 1
  • 2
5
votes
0 answers

difference between donna and supercop implementations for ed25519 signature scheme

While looking up the existing implementations of the ed25519 signature scheme I found out that the donna implementation (found here) produces signatures that are not verifiable by supercop implementation (found here), but supercop signatures are…
5
votes
1 answer

Export SecKey to pkcs8 format

Currently I am generating a RSAKeyPair with the iOS security framework statusCode = SecKeyGeneratePair(keyPairAttributes as CFDictionary, &newPublicKey, &newPrivateKey) I then want to export these keys to a PEM format with PKCS8. The standard…
5
votes
6 answers

128 bit data encryption using Java

I need to store some sensitive data by encrypting it with atleast 128 bit key. I investigated into javax.crypto package and found that there are certain Cipher names, like PBEWithMD5AndDES or PBEWithSHA1AndDESede which provides encryption upto 56…
jatanp
  • 3,982
  • 4
  • 40
  • 46