How to encrypt a big file using OpenSSL and someone's public key (2024)

Alexei Czeskis

How to encrypt a big file using OpenSSL and someone's public key

The situation

You have a public key for someone, you have a file you want to send them, you want to send it securely.


Can you call them, securely chat with them, or send them an encrypted e-mail?

If you are set up to chat over OTR with them or to send them an encrypted e-mail, just use that to send your file. It'll be faster. If you can call them, then call them and agree on a symmetric key. Then just use that key to encrypt the file like this. If you can't (or don't want to) do either of those, then you can follow this how-to.


Step 0) Get their public key

The other person needs to send you their public key in .pem format. If they only have it in rsa format (e.g., they use it for ssh), then have them do:

openssl rsa -in id_rsa -outform pem > id_rsa.pem

openssl rsa -in id_rsa -pubout -outform pem &gt id_rsa.pub.pem

Have them send you id_rsa.pub.pem


Step 1) Generate a 256 bit (32 byte) random key

openssl rand -base64 32 > key.bin


Step 2) Encrypt the key

openssl rsautl -encrypt -inkey id_rsa.pub.pem -pubin -in key.bin -out key.bin.enc


Step 3) Actually Encrypt our large file

openssl enc -aes-256-cbc -salt -in SECRET_FILE -out SECRET_FILE.enc -pass file:./key.bin


Step 4) Send/Decrypt the files

Send the .enc files to the other person and have them do:

openssl rsautl -decrypt -inkey id_rsa.pem -in key.bin.enc -out key.bin

openssl enc -d -aes-256-cbc -in SECRET_FILE.enc -out SECRET_FILE -pass file:./key.bin


Notes

You should always verify the hash of the file with the recipient or sign it with your private key, so the other person knows it actually came from you.

If there is a man-in-the-middle, then he/she could substitute the other person's public key for his/her own and then you're screwed. Always verify the other person's public key (take a hash and read it to each other over the phone).

How to encrypt a big file using OpenSSL and someone's public key (2024)
Top Articles
Comment devenir un trader rentable en 12 Règles d’Or – Objectif renta
Best Way To Make Money With Affiliate Marketing - morewages
Navicent Human Resources Phone Number
Bank Of America Financial Center Irvington Photos
Lowe's Garden Fence Roll
Lamb Funeral Home Obituaries Columbus Ga
His Lost Lycan Luna Chapter 5
Napa Autocare Locator
Jeremy Corbell Twitter
Noaa Swell Forecast
Flights To Frankfort Kentucky
Radio Aleluya Dialogo Pastoral
Shreveport Active 911
Craigslist Farm And Garden Cincinnati Ohio
Bad Moms 123Movies
Houses and Apartments For Rent in Maastricht
Epro Warrant Search
How Much You Should Be Tipping For Beauty Services - American Beauty Institute
Hollywood Bowl Section H
The Blind Showtimes Near Amc Merchants Crossing 16
Wbiw Weather Watchers
Dcf Training Number
Buying Cars from Craigslist: Tips for a Safe and Smart Purchase
Knock At The Cabin Showtimes Near Alamo Drafthouse Raleigh
Piedmont Healthstream Sign In
Tokyo Spa Memphis Reviews
Kitchen Exhaust Cleaning Companies Clearwater
Account Now Login In
Tactical Masters Price Guide
Maisons près d'une ville - Štanga - Location de vacances à proximité d'une ville - Štanga | Résultats 201
Kqelwaob
Hannah Jewell
Alima Becker
What does wym mean?
Craigslist Gigs Norfolk
Blackstone Launchpad Ucf
1400 Kg To Lb
Atlantic Broadband Email Login Pronto
The Boogeyman Showtimes Near Surf Cinemas
Case Funeral Home Obituaries
Planet Fitness Lebanon Nh
Bismarck Mandan Mugshots
How Big Is 776 000 Acres On A Map
Brown launches digital hub to expand community, career exploration for students, alumni
Scythe Banned Combos
Child care centers take steps to avoid COVID-19 shutdowns; some require masks for kids
Kate Spade Outlet Altoona
Das schönste Comeback des Jahres: Warum die Vengaboys nie wieder gehen dürfen
Automatic Vehicle Accident Detection and Messageing System – IJERT
Craigslist Psl
March 2023 Wincalendar
Latest Posts
Article information

Author: Allyn Kozey

Last Updated:

Views: 6456

Rating: 4.2 / 5 (63 voted)

Reviews: 94% of readers found this page helpful

Author information

Name: Allyn Kozey

Birthday: 1993-12-21

Address: Suite 454 40343 Larson Union, Port Melia, TX 16164

Phone: +2456904400762

Job: Investor Administrator

Hobby: Sketching, Puzzles, Pet, Mountaineering, Skydiving, Dowsing, Sports

Introduction: My name is Allyn Kozey, I am a outstanding, colorful, adventurous, encouraging, zealous, tender, helpful person who loves writing and wants to share my knowledge and understanding with you.