Questions tagged [public-key]

Public-key (or asymmetric) cryptography is a form of cryptography that does not require common secrets between the communicating partners.

Public-key cryptography or asymmetric cryptography is a form of cryptography that does not require common secrets between the communicating partners. It thus solves the problem of key-exchange. In many modern cryptosystems, public-key cryptography is used to establish a secret key, and the faster symmetric key crypto is used to actually encrypt and decrypt data.

Public-key cryptography is generally based on "one-way" mathematical functions - operations that are easy to perform, but difficult to undo. An example (on which RSA is based) is multiplication vs. factoring. Given two enormous primes p and q, it is simple (for a computer) to multiply them together to get p*q = n, but it turns out it is very difficult (even for a computer) to factor n in a reasonable amount of time.

1163 questions
17
votes
3 answers

Whose key is used to encrypt a HTTPS response?

I have a web server built up relying on HTTPS. So, my server maintains its private key and publish a public key that any clients can use to encrypt their request. Since my server is the only one who has the private key to decrypt any message…
Bruce
  • 1,608
  • 2
  • 17
  • 29
16
votes
2 answers

Any tutorials on public key encryption in java?

I've been able find information on symmetric encryption and hashing but I've been having quite a bit of trouble finding much information on any sort of public key encryption for java. What I'd like to do is make a very simple proof of concept…
Eugene M
  • 47,557
  • 14
  • 38
  • 44
16
votes
5 answers

Loading raw 64-byte long ECDSA public key in Java

I have a raw (r,s) format ECDSA NIST P-256 public key. It seems that there is no simple way to load it into an object that implements java.security.interfaces.ECPublicKey. What is the cleanest way to load a 64 byte public key so that it can be used…
user1094206
  • 920
  • 1
  • 12
  • 24
16
votes
2 answers

RSA Encryption Javascript

I have been instructed to write an application that takes some data then encrypts it with an RSA public key. It needs to be "RSA encryption": Which encryption cipher is RSA meant to use as standard? var key =…
K-G
  • 2,799
  • 4
  • 26
  • 42
15
votes
2 answers

How to decode keys from Keycloak openid-connect cert api

I'm trying to get the key from Keycloak open-id connect certs endpoint that allow me to validate a JWT token. The api to fetch the keys seam to work : GET http://localhost:8080/auth/realms/my-realm/protocol/openid-connect/certs { "keys": [ { …
avianey
  • 5,545
  • 3
  • 37
  • 60
15
votes
1 answer

For RSA, how do i calculate the secret exponent?

For RSA, how do i calculate the secret exponent? Given p and q the two primes, and phi=(p-1)(q-1), and the public exponent (0x10001), how do i get the secret exponent 'd' ? I've read that i have to do: d = e-1 mod phi using modular inversion and the…
Chris
  • 39,719
  • 45
  • 189
  • 235
15
votes
1 answer

Verifying a signature with a public key

I have an external service which call me back after some defined event, and sign his request with its private key. I have stored the public key which look like : -----BEGIN PUBLIC KEY----- ........................................ -----END PUBLIC…
Manuel Leduc
  • 1,849
  • 3
  • 23
  • 39
14
votes
2 answers

SSHJ Example of Public Key Auth from File

Can someone give me an example of using SSHJ for Public Key Authentication? I realise this question is essentially identical to ssh example of private/public key authentication, however the answer by the author…
Obiphil
  • 361
  • 1
  • 6
  • 17
14
votes
3 answers

How can I encrypt with a RSA private key in python?

Is it possible to encrypt a message with a private key in python using pycryptodome or any other library? I know that you are not supposed to encrypt with the private key and decrypt with the public key, but my purpose is to encrypt with the private…
14
votes
3 answers

How to generate RSA public and private keys using Swift 3?

I create the key pairs of public and private using SecKeyGeneratePair. ViewController import UIKit import Security class ViewController: UIViewController { @IBOutlet weak var textFld: UITextField! @IBOutlet weak var encryptedTextFld:…
Alwin
  • 1,476
  • 3
  • 19
  • 35
14
votes
3 answers

How can I know if a .pem file contains public or private key?

I have a .pem file (base64-encoded cryptography information). What OpenSSL command-line should I use to detect whether it contains a public key or a private key? As explained in this StackOverflow question, a .pem can contain both. Since the…
Suzanne Soy
  • 3,027
  • 6
  • 38
  • 56
14
votes
2 answers

What is use of config.put("StrictHostKeyChecking", "no") in JSch

java.util.Properties config = new java.util.Properties(); config.put("StrictHostKeyChecking", "no"); session.setConfig(config); In above code why we need to set StrictHostKeyChecking value as no while connection to SFTP through JSch…
king Ramesh
  • 141
  • 1
  • 1
  • 3
14
votes
1 answer

iPhone: How to create a SecKeyRef from a public key file (PEM)

In order to send and receive encrypted messages from/to the iPhone I need to read a public key (server's public key) PEM file and create a SecKeyRef (later I could even store it on the keychain in order not to create it again). This is my current…
TehJabbit
  • 239
  • 1
  • 2
  • 8
14
votes
2 answers

How can I get the public key of a webpage?

How can I get the public key of a website like VeriSign and all other websites which use https(secure protocol)?
shalki
  • 890
  • 3
  • 14
  • 31
14
votes
1 answer

Verify user's private key for website login

I'm trying to implement a login system to sign into a website using public key authentication. I'm not sure if this is feasible. This is what I plan to do:- While signing up, user's public key is saved in the website. When the user tries to login…
Sparky
  • 4,769
  • 8
  • 37
  • 52