Find private Key from a set of public keys - private-key

my old laptop suddenly died and I need to recover my private/pub keys.
I manage to recover the files from the HD but I have around 400 private keys.
I know tho, my public key.
Is it possible to figured out which one is the right private key associated to that specific public key, looking among a set of 400 keys?
Any tips is very welcome!

Related

Firebase, filter results at database level

We are running a project which contains some maps.
We have this under the node:
root.maps //object
It is a list of maps, in case some are private and some are public. Which is under the node:
root.maps.$mapId.config.isPrivate //boolean
root.maps.$mapId.config.uid //string
Now we have a problem. We listen on the maps node for changes, but we want only to return the public nodes, and the private nodes of the user.
So we added rules but it does not seem to work. The maps are either all displayed or none. When we try to set a restriction on a map itself it does not work.
Now after some searching on the internet we read that in order to manage the security rules well the private and public maps should be moved to private or public nodes.
So like this
root.maps.private.$mapId.uid
root.maps.public.$mapId.uid
Which I can't believe is true. In order to change this boolean value, we have to move the complete node from the public to the private node.
Is this really how this database should work? It does not sound logical at all to me.
Is there any other way on how to filter this data based on rules (maps should not be known to the client, client side filtering is not an option)
And if the really strange case of moving complete nodes based on changing boolean values is really true.
What is the idea behind it? This can't be true right?

Azure Mobile Services and Universal Apps SQLite Synchronization

I have a normal Universal App, nothing fancy, really simple.
There is a SQLite database that weights more than 200KB (could be even 20MB, keep that in mind) and I want to share this database between Windows 8.1 and Windows Phone 8.1 devices.
I guess that roaming data isn't enough, am I right?
So, I googled and find Azure Mobile Services and it's really sweet but the examples that are provided are too simply and I don't know how to extend it.
My database has 7 tables and some of them are connected by foreign key. Here is example one of my class (database is based on it).
public class Meeting : INotifyPropertyChanged
{
public Meeting() { }
private int _id;
[PrimaryKey, AutoIncrement]
public int Id { get; set; }
private int _adressId;
public int AdressId { get; set; }
private Adress _adress;
[Ignore]
public Adress Adress { get; set; }
}
Then it is method
private async Task InitLocalStoreAsync()
{
if (!App.MobileService.SyncContext.IsInitialized)
{
var store = new MobileServiceSQLiteStore("MyDatabase.db");
store.DefineTable<Adress>();
store.DefineTable<Contractor>();
store.DefineTable<Item>();
store.DefineTable<ItemGroup>();
store.DefineTable<Meeting>();
store.DefineTable<Note>();
store.DefineTable<Order>();
await App.MobileService.SyncContext.InitializeAsync(store);
}
}
and I get exception "Error getting value from 'Adress' on 'Projekt.DataModel.Meeting'."
The thing is: It is really hard to work with this. Isn't there a simplier solution? I don't need at this moment nothing but synchronization of my database. Please remember that I have a tables that are connected by foreign key. Maybe I skip some worthy example or tutorial?
Thanks for all your help.
You're right that this database would be too big for roaming settings. You should be able to get Azure Mobile Services working for your scenario.
One way to manage the relationships, especially if they are 1-to-many and not many-to-many, is to create database views in the backend that join the tables. Then you just sync against them. See my messages on this forum thread that describes how this would work: https://social.msdn.microsoft.com/Forums/azure/en-US/4c056373-d5cf-4ca6-9f00-f152d2b01372/best-practice-for-syncing-related-tables-in-offline-mode?forum=azuremobile
You might also be interested in a solution accelerator we have built, that shows how you would connect everything in a real app: https://code.msdn.microsoft.com/windowsapps/Field-Engineer-501df99d
If you have more questions, feel free to post in our forums that the product team monitors regularly: https://social.msdn.microsoft.com/Forums/azure/en-US/home?forum=azuremobile

Decrypting using same private key that is used to encrypt

In RSA,
I understand that if a data is encrypted using public key, corresponding private key can be used to decrypt it and vice versa. But :
Data encrypted using public key can be decrypted using same public key?
Data encrypted using private key can be decrypted using same private key?
This property is same for other public key algorithms too?
Data encrypted using public key can be decrypted using same public key?
No. That would defeat the purpose, because everyone knows the public key.
Data encrypted using private key can be decrypted using same private key?
No. That would defeat the purpose, because then you cannot send anyone an encrypted message (without knowing their private key, which by definition you don't).
Symmetric cryptography does work this way, though. There is only a single secret key, that you can use to encrypt your files before you put them on Dropbox, or that you can share with your friend to send messages that only the two of you can read.
Also, in some public key systems, it is possible to derive the public key from the private key (not the other way around, of course). But this does not really change the principle (because the public key is known to the owner of the private key anyway).
This property is same for other public key algorithms too?
The definition of public key cryptography is that there is a key pair, consisting of a private half and a public half, one of them being used to create the message, the other to read them.

RSA - Can you create a public key from a private key?

I am creating an encryption strategy for a lab project and want to know if there exists the capability to create a public key from just the private key?
Otherwise, can the public key only be created at the same time as the private key from some key generator?
P.S. A quick google didnt really help.
Private and public key are created together. Also, the standard storage format for a RSA private key includes all the public key fields, because it is useful for optimized implementations and masking (protection against some side-channel attacks). See the RSA standard itself: PKCS#1.
Edit: question has been edited, it was originally RSA-only. For other asymmetric algorithm, there is no requirement that the public key may be derived from the private key, nor is there any requirement of the contrary. For discrete logarithm-based algorithms (Diffie-Hellman, El-Gamal, DSA, and the elliptic curve variants of all of these), the public key is easily computed from the private key. It is possible to conceive a degenerate RSA in which knowledge of the private key does not allow reconstruction of the public key, but this requires not storing a few key elements which are needed for good performance (in full details, storing the RSA modulus factors allows for a 4x speed enhancement through the Chinese Remainder Theorem, so everybody stores the factors). On a more conceptual basis, the public key is, well, public, so it is assumed that "everybody" knows it; in practical terms, private key storage format almost always include provisions for storing the public key as well, or at least sufficient data to rebuild the public key.
Yes, you can do this (for some, probably not all, pkc schemes). From the ssh-keygen man file:
-y Read private key file and print public key.
Depends on the algorithm. With RSA, you cannot, with EC you can. However, the public key is usually always stored together with the private key (not the other way around, though, of course), so this is not really a problem (if you have the private key, the same file also includes the public key).
Extracting public RSA key from a private key from the command line
Command line comparison to show there is no difference between a public RSA key and an extracted key if you ignore whitespace.
Generate public private key pairing under home directory with no passphrase and no coment.
ssh-keygen -t rsa -f ~/id_rsa -N '' -C ""
Generate public key into file 'extracted_public_key'
ssh-keygen -y -f '/home/vagrant/id_rsa' > extracted_public_key
Diff public key with 'extracted_public_key' file ignoring white space.
diff -b id_rsa.pub extracted_public_key
Ignoring whitespace at the end of id_rsa.pub there is no difference between a public key and an extracted key.
Actually the public key is mostly generated with the private key together.
If you lost your public key but got the private key, you can still recover the public key from the private key.
All you have to do is to extract the public key from the private key like below:
Extracting the public key from the private key:
ssh-keygen -f~/.ssh/test_rsa -y > ~/.ssh/test_rsa.pub
-f option specifies the file of the key to list the fingerprint for
-y option will read a private SSH key file and prints an SSH public key to stdout. The public key part is redirected to the file with the same name as the private key but with the .pub file extension.
NOTE:
If the key has a password set, the password will be required to generate the public key.

Is it possible to generate a public key from private key?

If yes then they are really not a pair.
I was trying to figure out how ssh git#github.com resolves my name using my private key. SSH debug suggests public key is passed to server.
Yes, it is possible.
Sidebar: I'm not sure what you mean by, "they are really not a pair". A pair is when you have two things. A public key and a private key are two things, ergo, you have a pair. The fact that you can derive one from the other is immaterial.
I don't know how github does this, but my guess is simply that they use the public key to identify your account (your public key is unique, pretty much by definition).
I hope this answers your question. I have a feeling I'm not quite getting it.
No, it's not possible.
Neither private key, nor public key cannot be produced form the other one. Remember, private key is the same as public key by design and we call them public or private optionally (keeping one of them private and reveal the other).

Resources