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

How can I generate a RSA key for use with com.auth0 java-jwt?

https://github.com/auth0/java-jwt States that setting up the algorithm for JWT should be as simple as //RSA RSAPublicKey publicKey = //Get the key instance RSAPrivateKey privateKey = //Get the key instance Algorithm algorithmRS =…
Ryan Leach
  • 4,262
  • 5
  • 34
  • 71
5
votes
1 answer

Pycryptodome official example unclear

I have an issue with https://www.pycryptodome.org/en/latest/src/examples.html#encrypt-data-with-rsa from Crypto.PublicKey import RSA from Crypto.Random import get_random_bytes from Crypto.Cipher import AES, PKCS1_OAEP file_out =…
HCLivess
  • 1,015
  • 1
  • 13
  • 21
5
votes
1 answer

Can't authenticate using Socketcluster V2 for Coinigy Exchange websocket ticker api

I'm trying to use the ticker data for the Coinigy websocket api, to get the stream of real time trades and prices of crypto assets. I've tried the following demo with no success, and I get a response of: "Socket is not authenticated" internal class…
Carlo Luther
  • 2,402
  • 7
  • 46
  • 75
5
votes
3 answers

Is it better to salt the string when creating a secure hash?

I'm not really strong at cryptography, so there is my question. Our application — forum — sends our users notifications of new messages, if they opted for it. In the email there should be a link to unsubscribe from this messages. Now, I want that…
Maxim Sloyko
  • 15,176
  • 9
  • 43
  • 49
5
votes
2 answers

Erlang cryptography module - ECDSA, RSA, SHA256 and so on

I need a module that can generate keypairs, compute secure hashes and crypt and sign data. Is there any that module? Or maybe there is interface for OpenSSL crypto functions ?
gordon-quad
  • 734
  • 5
  • 15
5
votes
1 answer

What good source of entropy are available on a smart phone?

I'm thinking of this in the context of how much (kB/s) cryptographically secure entropy can be generated by a smart phone. For an example application: a VoIP app that continually generates new encryption keys. Things I can think of off hand: -…
BCS
  • 75,627
  • 68
  • 187
  • 294
5
votes
3 answers

Understanding Google Developer Console

I am a little confused regarding developer console functioning. I have a project in which I access youtube data apiv3. I have created my project and got 4 keys: Browser Key Server Key Web Client OAuth2.0 Client ID Secret Key Android Key Out of…
Rushi M Thakker
  • 679
  • 2
  • 15
  • 34
5
votes
2 answers

C# Get CngKey object from public key in text file

I have got a file in which there are several public keys for ECDSA SHA256. The file looks like: KEY_ID: 1 STATUS: VALID -----BEGIN PUBLIC…
petriq
  • 969
  • 1
  • 11
  • 24
5
votes
3 answers

C#: Error while decoding OAEP padding weird issue

I'm currently working on a class that encrypts large amounts of text with a randomly generated encryption key encrypted by a X509 certificate from a smart card, using a RSACryptoServiceProvider to perform the master key encryption and decryption…
CitadelCore
  • 53
  • 1
  • 6
5
votes
1 answer

How does AES decrypt with a different IV?

I am trying to learn more about AES encryption. AES encryption uses both the key and initialization vector (IV) for encryption, but since each IV is different, how does AES decrypt the ciphertext and return the plaintext? A Stick Figure Guide to…
ilovetolearn
  • 2,006
  • 5
  • 33
  • 64
5
votes
2 answers

Is it possible to test if two sha2 hashes came from the same plain text?

The following are both SHA256 hashes of an empty string, generated with PHP's crypt function. $5$fooooooooooooooo$Y6IVN.cYkABQ4h8dCR0zL/rJoRx09pwMoGaYST9HqDD $5$baaaaaaaaaaaaaar$C84IKQdPMG8qvnnckGZsyBJWKHuaSD0tqcmyueHI0GA Each was generated with a…
Tim
  • 8,036
  • 2
  • 36
  • 52
5
votes
1 answer

Bouncy Castle, NoSuchMethodError (org.bouncycastle.asn1.ASN1Integer)

I'm totally new to crypto/certs and trying to generate a certificate using the Bouncy Castle libraries. Looking at some of their sample code, this is what I have so far: package crypto; import org.bouncycastle.asn1.x500.X500Name; import…
Crystal
  • 28,460
  • 62
  • 219
  • 393
5
votes
1 answer

Reuse ICryptoTransform objects

I have a class that is used to encrypt textual data. I am trying to reuse the ICryptoTransform objects where possible. However, the second time I am trying to use the same object, I get partially incorrectly decrypted data. I think the first block…
Levente Koncz
  • 103
  • 2
  • 6
5
votes
2 answers

Is it possible to create synchronised random numbers on two different devices?

Is there a secure way to create same random numbers on two different devices on java without can predict next number or whole number series by user/coder? I thought a synchronised initiation like firstly users enter same numbers at run of…
5
votes
1 answer

What is difference between crypto and bcrypt

These modules are required like that const crypto = require('crypto'); const bcrypt = require('bcrypt'); I'm very confused in between them. I want to know what is difference between them and when it should be used.
Rahul Saini
  • 927
  • 1
  • 11
  • 28
1 2 3
99
100