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
Discover YubiKeys | Strong Two-Factor Authentication for Secure Login
How to Use Excel for Trading Research
Television Archive News Search Service
13 Easy Ways to Get Level 99 in Every Skill on RuneScape (F2P)
Encore Atlanta Cheer Competition
سریال رویای شیرین جوانی قسمت 338
The Best English Movie Theaters In Germany [Ultimate Guide]
Weapons Storehouse Nyt Crossword
Snarky Tea Net Worth 2022
123 Movies Black Adam
Accuradio Unblocked
Craigslist Pets Athens Ohio
5 high school volleyball stars of the week: Sept. 17 edition
Lake Nockamixon Fishing Report
Commodore Beach Club Live Cam
Booknet.com Contract Marriage 2
Nine Perfect Strangers (Miniserie, 2021)
Caledonia - a simple love song to Scotland
Healthier Homes | Coronavirus Protocol | Stanley Steemer - Stanley Steemer | The Steem Team
Accident On The 210 Freeway Today
Mega Personal St Louis
The Listings Project New York
Cain Toyota Vehicles
Apartments / Housing For Rent near Lake Placid, FL - craigslist
Albert Einstein Sdn 2023
Local Collector Buying Old Motorcycles Z1 KZ900 KZ 900 KZ1000 Kawasaki - wanted - by dealer - sale - craigslist
JVID Rina sauce set1
'Insidious: The Red Door': Release Date, Cast, Trailer, and What to Expect
Evil Dead Rise - Everything You Need To Know
Napa Autocare Locator
Frommer's Belgium, Holland and Luxembourg (Frommer's Complete Guides) - PDF Free Download
Bernie Platt, former Cherry Hill mayor and funeral home magnate, has died at 90
Tra.mypatients Folio
Everything You Need to Know About NLE Choppa
Rise Meadville Reviews
Rocketpult Infinite Fuel
Agematch Com Member Login
Pinellas Fire Active Calls
Red Dead Redemption 2 Legendary Fish Locations Guide (“A Fisher of Fish”)
Www Craigslist Com Brooklyn
Electronic Music Duo Daft Punk Announces Split After Nearly 3 Decades
This 85-year-old mom co-signed her daughter's student loan years ago. Now she fears the lender may take her house
The Conners Season 5 Wiki
Gregory (Five Nights at Freddy's)
Levi Ackerman Tattoo Ideas
Candise Yang Acupuncture
Craigslist Houses For Rent Little River Sc
Craigslist St Helens
Ark Silica Pearls Gfi
Marion City Wide Garage Sale 2023
Texas 4A Baseball
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.