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

How to encrypt long strings in PHP?

I'm using PHP's openssl_public_encrypt() to encrypt data using RSA. But it won't encrypt data larger than a certain size. How can I get it to encrypt data of an arbitrary length?
Paul J
  • 777
  • 2
  • 8
  • 18
12
votes
1 answer

bash/ssh test for public key authentication

Is there a way to programmatically test whether ssh can authenticate using a public key? I would like to do something like this (preferably in bash, but am open to a python solution): ssh-test-thingy user@host || echo "could not authenticate using…
Bacon
  • 2,155
  • 4
  • 23
  • 31
12
votes
1 answer

RSA-OAEP with SHA -256 key size 2048 bits using OpenSSL

I am trying to address a use case exactly same as How to encrypt data using RSA, with SHA-256 as hash function and MGF1 as mask generating function?, but I need a few more clarity on this. The above query was raised in the year 2013. At that time…
Mario Super
  • 309
  • 3
  • 14
12
votes
3 answers

SSH IdentitiesOnly=yes forwarding all my keys

I cannot for the life of me figure out why my SSH config is forwarding the wrong key. I have two keys, we'll call them home_rsa and work_rsa. I have done the following: eval `ssh-agent` ssh-add -K ~/.ssh/home_rsa ssh-add -K ~/.ssh/work_rsa Here is…
Marcus McLean
  • 1,306
  • 2
  • 13
  • 24
12
votes
1 answer

is fingerprint of public cert unique?

I would like to store public cert in a database, but I need an attribute of the public cert to index the public certs in the database. I would like to make this a unique field. Is the finger print of a public cert unique?
user3697919
  • 183
  • 2
  • 6
12
votes
1 answer

OpenPGP encryption with BouncyCastle

I have been trying to put together an in-memory public-key encryption infrastructure using OpenPGP via Bouncy Castle. One of our vendors uses OpenPGP public key encryption to encrypt all their feeds, and requires us to do the same, so I'm stuck…
Jeremy Holovacs
  • 22,480
  • 33
  • 117
  • 254
11
votes
1 answer

InvalidKeyException: Invalid key format java

I am trying to retrieve the public key from Vault. It is stored as secret. I am trying to convert the string retrieved to a PUBLIC KEY to verify the signature. Sample public key string looks like this -----BEGIN PUBLIC KEY-----…
Rohi
  • 385
  • 2
  • 3
  • 15
11
votes
2 answers

Using node.js crypto to verify signatures

I am trying to use AWS lambda to verify signatures created with sec256r1 in swift. Message: "some text to sign" Has been hashed with sha256 too signatures will be in…
WeCanBeFriends
  • 641
  • 1
  • 10
  • 23
11
votes
2 answers

I have a RSA public key exponent and modulus. How can I encrypt a string using Python?

Given a public key exponent and modulus like the following, how can I encrypt a string and send it to a server as text? publicKey: 10001, modulus:…
twoLeftFeet
  • 693
  • 1
  • 5
  • 25
11
votes
5 answers

Encrypting large files using a public key

I need to encrypt a 100KB file using a public key. I've been reading some posts claiming that it is not practical to directly encrypt large files using a public key, and that the preferred method is to encrypt the file using a symmetric key and then…
wanderingbear
  • 1,002
  • 3
  • 11
  • 18
11
votes
4 answers

How would I load a Private / Public Key from a string / byte array or any other container

Is it possible to store a RSA Private/Public Key in the source for example in a byte[] or string or any other container and use this key for encryption / decryption? A decode function from file would look like: void Decode(const string& filename,…
deW1
  • 5,562
  • 10
  • 38
  • 54
11
votes
5 answers

how to encrypt a file using private key in gpg

I'm producing an update for some systems and I want to encrypt the updates for keeping confidentiality, integrity and validity of my signature. I want to encrypt the file with my private key and send them to my client so that they can decrypt it…
11
votes
2 answers

How to find WiX RemotePayload's CertificatePublicKey hash

I'm trying to resolve WiX RemotePayload hashes, but I'm not sure how the CertificatePublicKey attribute is found. Take, for example, the .NET 4.0 Package definition from WiX 3.6 sources:
Joseph Yaduvanshi
  • 20,241
  • 5
  • 61
  • 69
11
votes
4 answers

Is it possible to prevent man-in-the-middle attack when using self-signed certificates?

I'm not sure is similar question has been asked before (I couldn't find any), but is it possible to protect Client/Server from Man-In-The-Middle attack? I'm writing a Client application to communicate with Server. Communication will be SSLv3…
Tushar Sudake
  • 1,148
  • 1
  • 14
  • 25
10
votes
1 answer

GnuPG/PGP and SSL: Sharing the same private key?

I'm trying to sort out my use of digital signatures and encryption. I understand that there are 2 main ways to do this: the PGP way and the SSL way. What I would like to know if it's possible to use the same private key for both SSL certificate and…
Pedro
  • 1,134
  • 11
  • 26