I have a follow up question to Given a private key, is it possible to derive it’s public key?
Are the public and the private keys the 'same' (in the sense that you just choose to make one public) or can you do more with the private key than with the public key?
EDIT - to better state my question:
When the two keys are generated, could I just randomly choose one of them to be the public key?
Some paper descriptions present roles of public and private keys as quite symmetrical but you definitely can't swap roles of private and public key in real world.
Common usage:
the public key must be used for encryption and verifying signature
the private key must be used for decryption and signing
There is several reasons for that:
you don't want to leave a choice to the user as to which key should be published and which not. The public key is published worldwide and you can consider it as your public identity. The private part is needed when you have to prove to someone else that you have more insight than others about this identity: you can read messages sent to it, you are able to sign messages that can be verifyed by anyone who knows your public id. If what part of public/private key to publish were left to the user you'll end end with users publishing both. But that's not the main reason.
when you have private keys, you really have both keys every common implementation I know offer tools to extract public keys from private files. That's true for pgp, gpg, openssl. It means so called private key files store both private and public keys as described in algorithms. That's by design.
For exemple with openssl the sequence of commands to generate a RSA key pair can be:
openssl genrsa -out private.key 2048
openssl rsa -in private.key -pubout -out public.key
It should be clear enough that the first command generate both keys in the private key file and that the public key is merely extracted from it.
The consequence is that if your private key is ever compromized, both your keys would be compromized. The other way around is secure, you can't deduce the private key if you know the public key neither from the file nor from a mathematical attack.
encryption with private key is mathematically weak: well, the previous point is already enough, but some devious users could be considering using asymmetric cryptography
keeping both keys hidden for exchanging data. Don't, use symmetric ciphering if you want to do that kind of exchanges. Yes it is possible to crypt a message using private key and decrypt it using public one (that's basically what is used for signing, but the use case is different as you also have initial message). Internal parameters of the two keys are not the sames and all the strongness of cryptography has been prooved only for the usual direction and common usage.
It really depends on what you call "private key." In almost every practical sitation, the sender knowing the private key also knows the public key. It provides others with its public key so it needs to know it. So in essence, that "private key" will contain "public key" information or at least it can be derived from it.
Generally, you cannot swap private and public keys. In fact, they are not always of the same type (depending on the cryptosystem used). For instance, in ECDSA, your public key is a two-dimensional "point" on an elliptic curve, whereas your private key is a number.
From http://www.webopedia.com/TERM/P/public_key_cryptography.html:
A cryptographic system that uses two
keys -- a public key known to everyone
and a private or secret key known only
to the recipient of the message. When
John wants to send a secure message to
Jane, he uses Jane's public key to
encrypt the message. Jane then uses
her private key to decrypt it.
An important element to the public key
system is that the public and private
keys are related in such a way that
only the public key can be used to
encrypt messages and only the
corresponding private key can be used
to decrypt them. Moreover, it is
virtually impossible to deduce the
private key if you know the public
key.
No. That is the idea of generating a pair of keys in PPK world. You typically encrypt with the public key and decrypt with the private key. So you'd share the public key with your friends and ask them to use it when they send you their bank account number.
Related
I am working on a method for licencing a software for distribution.
All the .exe distributed will have a public key.
Public key will be same for all distributions, which will be used to encrypt licencing information and generate a licence file.
The distribution will be supplied with a private key(serial key) which will be used to run the software.
Private key will be different for all distributions.
can anyone suggest any algorithm to which can encrypt with a single public key
and decrypt with different private key.
Here is the link which i found similar to this topic but cant figure out how to implement.
as stated in your link by Artjom;
Let's say multiple recipients have (a different) private key and all
of them can decrypt data encrypted with the same public key. You
should ask yourself, how can the different private keys be generated
to arrive at the same public key, but where all the recipients
wouldn't know the private key of each other.
Actually, he tries to say, this construction would be impossible.
And again in your link Panco noted; the questions;
I suspect you need to think more about the security goals (and
nongoals) of the system. The cluster head sends a message; who must be
able to read the message (e.g. the intended recipient)? Who must not
be able to read the message (e.g. random third parties)? Who don't you
care whether they can or cannot (e.g. the cluster head itself)? Also,
this is an ad hoc network; how do nodes join the cluster? Is there
some sort of introduction protocol (where keys can be exchanged)?
This is your solution;
Depending on the answers, a purely symmetric system may be the Right
Thing.
In asymmetric encryption it is quite common to publish your public key to others. With the public key everyone can verify signatures created with the according private key.
So why do crypto-currencies like bitcoin not simply use the public key as the output of a transaction directly?
Bitcoin is instead using a so called address. What is the reason instead of just using the curve25519 public key?
There are basically two advantages to publishing an address, i.e., a RIPEMD-160 hash of the public key, instead of the public key directly:
The hash is only 160 bits compared to 256 bits of public key, so we safe about 1/3 of the space that we'd use when directly using public keys. This is both data transferred and stored at the endpoints. While the transferred size is pretty clear, storage comes in two forms as well: UTXO set size and on disk size.
Some limited protection against ECDSA being broken: should it become computationally feasible to create a signature given a public key, because of a weakness being discovered, we can avoid all funds being stolen by having this level of indirection. Assuming that it takes a while to generate a valid signature we can switch the signature algorithm, and the owners in possession of the private key still have a timing advantage w.r.t. an attacker, which would have to grab the public key from the wire, turn around and quickly compute a signature to a competing transaction.
I thought this would be a simple matter but it looks like webcrypto api doesn't provide a way to take a private key and generate its public key counterpart.
Is this true? Or am I missing something?
The reason I'm trying to do this is because I want to transfer the keypair and trying to reduce the total size. It would be great if I can just export the private key and later retrieve both of the pairs.
WebCrypto does not provide a mechanism to derive the public key from a private key.
It is technically possible with the RSA cryptosystem but not necessarily others (see Given a private key, is it possible to derive its public key?) you are only missing e which is generally could be brute forced/guessed (it is usually 65537).
Migrating private keys is something you do not want to do often if at all, every place a software key exists it may leave a remnant (page file, etc) that could be used to discover key later.
If you make the private key exportable (you do not want to do this for security reasons -- see above why) then you could write javascript to do this.
In short, the space savings is probably not worth the complexity and security consequences.
I have recently been working with some p12 files storing both private and public keys. Being far from a cryptography expert, I started pondering whether storing a public and private key being stored together in the same archive (and then transferred over wire) defeats the whole purpose of the keys.
There's nothing wrong storing a public key along with the private key in a file. It all depends on the intent of this.
If you only wanted to send the public key to a third party, then by sending your private key you give them a way to break the public key mechanism. This is insecure, and you should throw away your keys as have they don't have any values now.
If the transfer is part of your infrastructure, and the transfer happens securely, and you fully expect this file to be private on the destination, then there's nothing wrong storing them as one file.
Most frameworks will know how to use a single private/public file properly, and would only disclose the public part to a third party and keep the private part internal.
Whether to distribute private keys or not depends on your particular needs. Normally they are kept secret and not distributed more than needed (almost never).
Technically it's possible to add a certificate without a private key into PKCS#12 container, but this doesn't make much sense because other formats are more practical for distributing just certificates. And if you are adding a private key just because some software works only with PKCS#12 format and you don't know how to avoid putting the private key there, this is a mistake - you should not do this.
Now, safety of data in PKCS#12 file depends on what encryption algorithm is used. Previously (in older versions of Windows) 40-bit encryption was used by default. 40-bit is not secure, that's for sure. Newer versions support 3DES encryption - it's much stronger.
I'm trying to implement licensing system for a software to prevent piracy.
For this I need to read a license file within the application, and I need to make sure this file is written by the owner company.
Asymmetric cryptography has good potential for this aim, but in other way around!
Asymmetric cryptography algorithms, like RSA, give you a Public key and a Private key which are used as follow:
Private keys are used to decrypt.
Public keys are used to encrypt.
But I need them like this:
Private keys to be used to encrypt.
Public keys to be used to decrypt.
A simplistic idea would be to switch the role of public and private keys, but there are posts saying that in RSA public keys can be generated from private ones which make this idea impractical.
So here's my question: Is there any asymmetric cryptography with reversed key roles?
If speaking about RSA public/private key pair can be used in both cases you described. When you use private key to encrypt then public key decrypts and vice-versa.
As you said public key can be derived from private key but not the other way.
If you want to prove the origin of licensing file, use RSA in signature mode. In signature mode a hash is computed from the data you want to protect and then encrypted using private key. The result -the digital signature - is appended to the protected data.
Verification process starts by decrypting the signature which gives you the hash. Then compute hash value from the data. Computed and decrypted value shall be the same.
There are a lot of libraries providing comfortable way of signature creation and verification. You can choose depending on the platform you use for your application development.
http://en.wikipedia.org/wiki/Digital_signature