Skip to content

Cryptography

Assignment class 1

In this week we have small assignment to chose one or more of given assignment, do the practical work and answear some question about them.

i have desided to do following assignment 1. Create a public/privat key par 2. encrypt and decrypt a file

Create a public/privat key par

This will not be my first time creating a public/privat key par i had to do it in my fabacademy study. This time i did it in the virtual enviroment that i was given to use in this course

Create a public/private key pair. Fyrst i open terminal on the virtual machine. and write the following code there:

ssh-keygen -t ed25519

its also possible to use -C and set some comment in the end i did not do that.

Then i save the key to location

/home/ubuntu/.ssh/id_ed25519
  • What is the public key?
  • The public key is a key that can be shared with other people. It is used to encrypt data or to check that a digital signature is valid.

For example, when using SSH, the public key is copied to the server so the server knows who is allowed to log in.

  • What is the private key?
  • The private key is a secret key that stays on your own computer. It should never be shared with anyone.

The private key is used to prove your identity and to decrypt data that was encrypted with the public key.

  • What can this key pair be used for?
  • A public and private key pair can be used for:

  • Logging in to servers with SSH without a password.

  • Encrypting files and messages.
  • Creating digital signatures.
  • Securing websites with HTTPS certificates.

The two keys work together. Data encrypted with the public key can only be decrypted with the matching private key.

  • Why must the private key be protected?
  • The private key must be kept safe because anyone who gets it can pretend to be you.

If someone steals your private key, they may be able to:

  • Log in to your servers.
  • Read encrypted information.
  • Sign documents or emails in your name.

For this reason, private keys should be stored securely and never shared with others.

Encrypt and decrypt a file

I decided to encrypt a file on my windows system. I choice a file of no important in case of i will mess it up.

What i did: i started by opening the file system found a file there i could try to en crypt right clik on the file went to propereties then to advance (see pic)

Then click encrypt

Then then click ok and apply

Then click file only and ok to decrypt do the same

  1. Did you use symmetric or public-key encryption? EFS uses both symmetric and public key encription file it self is decryptet with symmetric key then symmetrick key is encrypted with my public key

  2. Where did the key come from? windows automaticly generates the the keypar when EFS is used the first time.

  3. Who can decrypt the file? only the user that own the windows account that encrypted the file can access it any one who have the users privat key.

  4. What happens if the key or password is lost? if key or password get lost i will lose access to that file and it can be permanantly lost