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
3 answers

Inter-convertability of asymmetric key containers (eg: X.509, PGP, OpenSSH)

Are asymmetrical cryptographic keys fundamentally inter-convertible between the major key container formats? For example, can I convert an X.509 key file into a PGP or OpenGPG key file? And--assuming the answer is yes--is it "security neutral" to…
Chris Wenham
  • 23,679
  • 13
  • 59
  • 69
5
votes
1 answer

Fernet class encryption in python and decryption in java not working

I am trying to write a code for encryption in Python and decryption in Java but I am getting an error. I am using cryptography.fernet in python to encrypt a file and when I use Fernet Java for decryption it shows an error. Here is my python…
Vai
  • 343
  • 3
  • 17
5
votes
3 answers

Is it possible to recover secret data with allocating memory (like RSA private key in free'd memory used for decryption)?

For example, lets take the pseudo code which tries to obtain RSA private key once stored in allocated (then free'd) memory with this method: int main(){ bigNum priKey; while(true) { void *mem = malloc(2024); //allocate a good…
5
votes
2 answers

Consensus-based information disclosure

Problem description I am interested in a solution to the following problem: There is some secret information that a group of n people would like to lock away until some minimum number 1<=m<=n of them agrees to release it. For example, say,…
Cam
  • 14,930
  • 16
  • 77
  • 128
5
votes
1 answer

Digital Signature vs. HMAC with key via DH

I am writing an application that heavily uses cryptology. Like most networked applications, mine breaks up data into different types of messages (instant message, file chunk, video frame, etc.) -- and each one must be checked for authenticity both…
Hut8
  • 6,080
  • 4
  • 42
  • 59
5
votes
1 answer

How to verify gnupg signature with Python gnupg module?

I have problem with verification signature with Python gnupg module. With this module I can encrypt and sign file: gpg.encrypt_file(stream, encrypt_for, sign=sign_by, passphrase=key_passwd, output=file_out) Such encrypted file can be decrypted by…
Michał Niklas
  • 53,067
  • 18
  • 70
  • 114
5
votes
4 answers

Cryptanalysis of ciphertext using Java

I'm looking for some ideas on an assignment. I have 7 ciphertext files, all of which are encrypted using the same symmetric key, which is 3 characters long and is alphabetic. No encryption algorithm is provided but the specs state that it is a…
Dhruv Gairola
  • 9,102
  • 5
  • 39
  • 43
5
votes
3 answers

How Is My Password Transferred from My Browser to the Web Server Securely?

How is the password I enter in, say a Gmail login form, transferred to the web server securely? What does the browser or any client application do? What does the web server do?
Srikanth
  • 11,780
  • 23
  • 72
  • 92
5
votes
1 answer

C# How to send OCSP Request correctly using bouncy castle library?

OCSP request does not fall into the Audit log table when I send it using Bouncy Castle library. I don't understand why? What is wrong with my code and how to solve it? I have a client certificate and issuer certificate. I create two…
Freeedy
  • 101
  • 3
  • 9
5
votes
2 answers

pip._vendor.pep517.wrappers.BackendUnavailable error while installing cryptography

I'm trying to install cryptography to my system, but I get this error: WARNING: Missing build requirements in pyproject.toml for cryptography from…
Razero
  • 321
  • 1
  • 4
  • 16
5
votes
1 answer

Convert an element in tuple to a bytes-like object

I'm trying to base64 encode some RSA encrypted data, but the RSA encryption returns a tuple and the base64 encoding requires a bytes-like object. File "C:\PATH\AppData\Local\Continuum\anaconda3\lib\base64.py", line 58, in b64encode encoded =…
Noob14
  • 165
  • 3
  • 12
5
votes
1 answer

PHP Sodium not installed?

I'm trying to use Libsodium for the first time to for encryption, but I've encountered an error. I'm running everything on XAMPP; sodium is in the /ext/ folder and I've added extension=sodium to the php.ini file. This is my code. // This refers to…
zugo123456789
  • 97
  • 1
  • 1
  • 7
5
votes
1 answer

Converting EC private key from PEM to DER in python

I am trying to write a Python script to convert an EC private key from PKCS8 PEM to DER using cryptography in Python. I was able to do this previously using openssl like so: openssl pkcs8 -nocrypt -in pem_key.p8 -out der_key.der -outform der I…
Alfonso Embid-Desmet
  • 3,561
  • 3
  • 32
  • 45
5
votes
1 answer

Is there a benefit to performing JWT operations as async?

I'm using the highly popular jsonwebtoken package for node. Signing and verifying are typically performed synchronously, but async options are also provided. I thought that the operations involved are neither data-bound nor computationally…
lonix
  • 14,255
  • 23
  • 85
  • 176
5
votes
1 answer

Python Cryptography export key to DER

In the past when using PyCrypto I was able to do the following to generate a fingerprint of a RSA public key: rsa_cipher = PKCS1_v1_5.new(RSA.importKey(pub_rsa_key)) hashlib.sha1(rsa_cipher._key.exportKey("DER")).hexdigest() How can I achieve the…
McAbra
  • 2,382
  • 2
  • 21
  • 29