Questions tagged [public-key-encryption]

An cryptographic scheme which uses two mathematically related keys; a public and a private key where a message encrypted with public key can only be decrypted with the private key and vice-versa.

The most important element of public key encryption is that the public and private keys are related in such a way that only the public key can be used to encrypt a message and only the matching private key can be used to decrypt it. In addition, it is practically impossible to derive the private key with only the knowledge of the public key. Public-key systems such as PGP, SSL and many others benefit from this mathematically well-defined behavior of public key encryption. It is important to note that public key encryption is mostly called asymmetric encryption because it uses two keys instead of one key as opposed to symmetric encryption.

1918 questions
47
votes
1 answer

How is SSH_AUTH_SOCK setup and used by ssh-agent?

I have been able to setup the sharing of ssh-agent for public-key authentication after reading https://superuser.com/a/230872/301446 The environment file thus generated has the following contents: SSH_AUTH_SOCK=/tmp/ssh-OwqeSuxmEsQN/agent.4744;…
user3104542
45
votes
3 answers

How to use public and private key encryption technique in C#

I want to encrypt data using public/private key technique. I mean, encrypt with the public key of receiver and the receiver can decrypt with their own private key. How can I do that? Do you have any suggestion or sample code ?
cagin
  • 5,772
  • 14
  • 74
  • 130
44
votes
9 answers

How to do PGP in Python (generate keys, encrypt/decrypt)

I'm making a program in Python to be distributed to windows users via an installer. The program needs to be able to download a file every day encrypted with the user's public key and then decrypt it. So I need to find a Python library that will let…
Greg
  • 45,306
  • 89
  • 231
  • 297
43
votes
4 answers

Command to send public key to remote host

I remember there is a command to send public key to the remote host that I want. I want to use that feature to send one of my public keys to the other host. How can I do that?
user482594
  • 16,878
  • 21
  • 72
  • 108
42
votes
1 answer

DH vs. DHE and ECDHE and perfect forward secrecy

Does Diffie-Hellman (DH) provide perfect forward secrecy? or is it a feature for Ephemeral Diffie-Hellman (DHE) only ? Is Elliptic Curve Ephemeral diffie-Hellman (ECDHE) is better than DHE ?
user1810868
  • 1,565
  • 8
  • 23
  • 30
41
votes
4 answers

gpg: Sorry, no terminal at all requested - can't get input

When decrypting I get following error: $ eyaml decrypt -s 'ENC and the key goes on here' .gnupg --quiet --no-secmem-warning --no-permission-warning --no-tty --yes --decrypt) failed with: gpg: Sorry, no terminal at all requested - can't get input I…
39
votes
2 answers

How does the man in the middle attack work in Diffie–Hellman?

I'm having doubts about the mechanics of a man in the middle attack during a Diffie–Hellman key exchange. I have heard that it can happen during the key agreement communication. But in the presence of CA (Certificate Authority) the receiver can…
Chanikag
  • 1,419
  • 2
  • 18
  • 31
38
votes
3 answers

Rainbow tables as a solution to large prime factoring

In explanations I've read about public key cryptography, it is said that some large number is come up with by multiplying together 2 extremely large primes. Since factoring the product of large primes is almost impossibly time-consuming, you have…
Dinah
  • 52,922
  • 30
  • 133
  • 149
31
votes
5 answers

C# How to simply encrypt a text file with a PGP Public Key?

I've researched a bit about how to achieve what I said in the question and found several APIs but most of them look very complicated and since I'm just a noobie in this area I just want a simple method like: public String Encrypt(String message,…
Leo
  • 2,173
  • 6
  • 28
  • 37
29
votes
3 answers

RSA encryption output size

What is RSA encryption output size when using 2048 bit key and pkcs1padding. Is it always 256 bytes independent of input size? How can i calculate it for other key sizes?
hyda
  • 550
  • 1
  • 6
  • 15
28
votes
3 answers

GPG encryption and decryption of a folder using command line

man page of gpg command line (Gnupg) has commands to encrypt and decrypt files. Here is a standard command to encrypt/decrypt files with gpg. gpg --encrypt --recipient xxx@mail.com ~/xxx/xxx.txt - to encrypt gpg --output ~/xxx/xxx.txt --decrypt…
0928e8f6
  • 383
  • 1
  • 3
  • 4
27
votes
3 answers

RSA Encryption: Difference between Java and Android

I am using RSA to encrypt username and password on Android and decrypt them on server (tomcat 6, java 1.6). Android Encryption: PublicKey pubKey = readPublicKeyFromFile(mod, ex); Cipher cipher = Cipher.getInstance("RSA"); …
bsobat
  • 650
  • 1
  • 6
  • 12
27
votes
9 answers

Can I get the modulus or exponent from a SecKeyRef object in Swift?

In Swift, I created a SecKeyRef object by calling SecTrustCopyPublicKey on some raw X509 certificate data. This is what this SecKeyRef object looks like. Optional(
Josh Beam
  • 19,292
  • 3
  • 45
  • 68
25
votes
4 answers

Ruby: file encryption/decryption with private/public keys

I am searching for an algorithm for file encryption/decryption which satisfies the following requirements: Algorithm must be reliable Algorithm should be fast for rather big files Private key can be generated by some parameter (for example,…
25
votes
5 answers

Are there any asymmetric encryption options for JavaScript?

I have to transfer some sensitive information over a JavaScript AJAX Call, over an unencrypted channel (HTTP, not HTTPS). I'd like to encrypt the data, but encryption on the JavaScript side means I expose the key, which makes symmetric encryption…