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
6
votes
1 answer

Why are prime numbers used in Diffie-Hellman key exchange?

Diffie-Hellman key exchange algorithm uses operations like 2^8 mod n where n is a prime number. What is the reason for using prime numbers instead of other numbers?
Shourob Datta
  • 1,886
  • 22
  • 30
6
votes
2 answers

How to encrypt large file with RSA?

Code https://play.golang.org/p/CUEqjsJq5c Error: panic: crypto/rsa: message too long for RSA public key size goroutine 1 [running]: panic(0x4a6d80, 0xc420010420) /usr/local/go/src/runtime/panic.go:500 +0x1a1 main.main() /tmp/sample.go:28…
6
votes
1 answer

RSA in javascript no longer supports ASCII/byte arrays

I am using rsa.js v1.0 from http://www-cs-students.stanford.edu/~tjw/jsbn/ to encrypt an ASCII string in a browser. The string is actually a 16 byte array that contains a double-length TripleDes key. With rsa v1.0 this works. The byte array is…
6
votes
2 answers

How to gpg encrypt with ssh public key?

I have a public key in a file called key.pub, and the contents look like: ssh-rsa AAAAB......t+f klahnakoski I would like to to use it to encrypt a file with gpg. What is the sequence of shell commands required? I imagine the sequence looks…
ekyle
  • 61
  • 2
  • 5
6
votes
2 answers

Public Key Encryption in Microsoft Edge

I have the following JavaScript code to implement public key encryption using the Web Cryptography API. It works for Firefox and Chrome but fails for Microsoft Edge. The error I am getting from Edge is "Could not complete the operation due to error…
6
votes
2 answers

How to generate PublicKey object from a file in Java

I have a file containing a public RSA key (generated with ssh-keygen). I'd like to read the file and generate a PublicKey object. Prior to that I converted the file, since reading the original files seems to be impossible: #…
Edward
  • 4,453
  • 8
  • 44
  • 82
6
votes
1 answer

How to give highest trust level to an OpenPGP certificate in Kleopatra?

I'd like to give the highest trust level to a certificate. I need to do so, as this certificate is mine but I don't have exported it before formatting my PC. I have downloaded it from a public key server and I have my private key saved in KeePass,…
fede.97
  • 73
  • 1
  • 3
6
votes
2 answers

Use ecc for encryption in ios

I am trying to implement ecc technique for encryption. I went through the following posts: Shared Secret based on Elliptic curve Diffie–Hellman with CommonCrypto Elliptic Curve Crypto in iOS which doesn't have any satisfactory solutions. Now, I…
6
votes
1 answer

How to share a public key for OAuth2 JWT validation?

I am implementing an app that connects to an OAuth2 server and it gets back a Json Web Token (JWT). I am passing the token along and I want to independently validate that the token came from the issuing source. I can do this, no problem, with the…
Brian Genisio
  • 47,787
  • 16
  • 124
  • 167
6
votes
2 answers

How to authenticate a public key with certificate authority using Python?

import OpenSSL key = ... signature = ... data = ... x509 = OpenSSL.crypto.load_certificate(OpenSSL.crypto.FILETYPE_ASN1, key) OpenSSL.crypto.verify(x509, signature, data, 'sha1') So far, I am able to do all of this without any problems. However,…
badideas
  • 3,189
  • 3
  • 25
  • 26
6
votes
1 answer

OpenSSL: print X and Y of EC_POINT

This is my code: EC_KEY *eckey = EC_KEY_new(); EC_KEY_generate_key(eckey); const EC_POINT *pub = EC_KEY_get0_public_key(eckey); printf("%s", pub->X); I'm getting an error that says "Incomplete definition of type 'struct ec_point_st'". I also…
Tech163
  • 4,176
  • 8
  • 33
  • 36
6
votes
2 answers

Small portable digital signing and verification library

I'm looking for a library that allows me to authenticate data sent to embedded modules. Due to the hardware constraints, it needs to be of small footprint (both code and memory wise) and yet have security comparable to RSA-1024. The requirements are…
Rys
  • 63
  • 1
  • 4
6
votes
1 answer

Why would SecKeyEncrypt return paramErr (-50) for input strings longer than 246 bytes?

I am using SecKeyEncrypt with a JSON formatted string as input. If pass SecKeyEncrypt a plainTextLength of less than 246, it works. If I pass it a length of 246 or more, it fails with return value: paramErr (-50). It could be a matter of the string…
Mathew
  • 1,788
  • 15
  • 27
6
votes
1 answer

Generate Chrome .crx from PHP

I want to generate a Chrome extension (Chrome theme) from PHP. My PHP script generates a zip file (download.zip). To convert it to a .crx package, it needs to add headers, including a public key and a signature. I saw this answer, but you need a…
6
votes
2 answers

How do I obtain the public key from an ECDSA private key in OpenSSL?

I am providing this sample application to show my problem #include #include #include #include int main() { EC_KEY *pkey = NULL; EC_POINT *pub_key = NULL; const EC_GROUP *group =…
farmdve
  • 786
  • 3
  • 13
  • 26