N
N
Nikita Gusakov2013-11-06 13:16:06
Password storage
Nikita Gusakov, 2013-11-06 13:16:06

Cryptographic encryption algorithm based on master password

At the institute, instead of a dozen unnecessary, the lab agreed to make a program for storing passwords. Passwords and their purpose must be encrypted with a master password. I don’t know anything at all in cryptography, but it’s interesting, I understood RSA, but as I understand it, it doesn’t suit me - this is for message passing.
XOR is too simple, I would like an interesting, but not very complex algorithm. Tell me this one?

Answer the question

In order to leave comments, you need to log in

8 answer(s)
P
Peter, 2013-11-06
@hell0w0rd

What is good about RSA, for example, is that you can use any “master key” with it, since there the public and private keys are interdependent, and not like, for example, in the ElGamal protocol.
But there will be a problem. For a program that itself stores passwords, storing more information about the key encryption key (master key) is somehow unsafe.
It's better to use a different approach. Namely, a strong (!) cryptographic hash function (it’s easier and there will be almost no information about the master key in the program) and a symmetric encryption algorithm (3DES, AES, any other that will be understandable for implementation. Even GOST28147-89 is suitable. For all of them in the network there are many maximally chewed algorithms).
Now the actual protocol of the program.
Encryption:
There is a message M, containing the user's password, which must be stored in the program.
It is encrypted with a randomly generated encryption key K .
K , in turn, is encrypted with a key encryption key (master key).
Key encryption key - let be the result of the impact of a strong cryptographic hash function H () on the passphrase P .
Decryption:
I take the passphrase P .
I take the hash H(P) from it .
I decrypt the one-time data encryption key K using H(P) as the key.
Decrypt with Kstored message M containing the password.
Possible problems:
strength of the hash function
uniform distribution of PRNG
Otherwise, it will be a very exciting activity. For me, it would definitely be like this =)
And if you use lists and trees to store data, then the teachers will be happy)))

@
@ntkt, 2013-11-06
_

1. Start with theory at the “for dummies” level.
You need to understand what is "symmetric" and "asymmetric" encryption, what is hashing with the so-called. cryptography, when they are used, what data can be encrypted and what cannot (yes, yes!), basic things about the modes of operation of ciphers and the use-reuse of keys.
2. Further - the choice of algorithms is not fundamental at all.
The implementation of RSA is exactly one lab in terms of volume.
The implementation of a simple symmetric cipher like the one mentioned by XXTEA is even smaller.
Implementing a decent hash function is trickier here (but here's a hint: you can make a pretty decent hash function out of a decent symmetric encryption algorithm).
3. Fundamentally - understanding what's what (see paragraph 1).
You can not implement anything at all, but first assemble it from ready-made pieces and play around.

I
ivan_kolmycheck, 2013-11-06
@ivan_kolmycheck

To summarize all the answers briefly, then: you need symmetric algorithms (AES, Twofish, Blowfish). RSA is asymmetric.
In a nutshell and from an applied point of view, then in a symmetric algorithm for encryption, a not very long key is used, which is the same for both encryption and decryption.
In asymmetric algorithms, two keys are used - public and private. For example, I take your public key, which everyone knows, and encrypt some message with it - that's it, now only someone who knows your private key can decrypt it. Basically, even I can't decrypt if I suddenly forget, because I don't have your private key.
Due to the peculiarities of asymmetric algorithms, the safe length of the keys is larger there than in the symmetric one, and the operations are more resource-intensive. Therefore, hybrid encryption is often used, where the message is encrypted symmetrically with a randomly generated key, the key is encrypted asymmetrically and glued to the encrypted message. The recipient "bites off" the key from the message, decrypts it asymmetrically and receives the key with which he decrypts the message.

S
Singerofthefall, 2013-11-06
@Singerofthefall

At the institute, instead of a dozen unnecessary labs <...> I don’t know anything about cryptography at all
I hope these are not cryptography labs;)
Any symmetric algorithm will do for you ( here is a short list) . Check out something like XXTEA (block) or RC4 (threaded) (although the latter is sort of licensed if that bothers you) - both were conceived as algorithms that are easy to implement.

K
KEKSOV, 2013-11-06
@KEKSOV

Excuse me, what's wrong with public Blowfish comrades? Implementations in all languages ​​are like dirt.

R
Roman Sopov, 2013-11-06
@sopov

Take the AES algorithm is quite suitable for your tasks.

U
Uncle Seryozha, 2013-11-06
@Protos

Fine! the key is 2kbit and asymmetric, it is slow for streaming encrypted, but for storing small amounts of information the norm! I did it myself on PC, though it depends how you do it: all by hand or using third-party ready-made libraries

I
ivan_kolmycheck, 2013-11-06
@ivan_kolmycheck

You can also peep something here: www.keepassx.org/downloads/ (free software, respectively, source codes are available)

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question