LinuxQuestions.org
Share your knowledge at the LQ Wiki.
Home Forums Tutorials Articles Register
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - General
User Name
Password
Linux - General This Linux forum is for general Linux questions and discussion.
If it is Linux Related and doesn't seem to fit in any other forum then this is the place.

Notices


Reply
  Search this Thread
Old 12-14-2010, 09:47 AM   #1
executivul
LQ Newbie
 
Registered: Dec 2010
Posts: 7

Rep: Reputation: 0
Advanced bash pipes combine after split


Hello,
I have an encrypted archive, only part of the archive (first 10MB of the tar.gz) is actually encrypted, since the archive is quite large and asymmetric decription is slow.
On the receiving side I want the download and decryption + inflating to be as quick as possible. That's why I'm using pipes, not download locally and then decrypt and then inflate.
I intend to use tee:
curl http://server/file | tee >(dd bs=1M count=10 | openssl... | ???) | dd bs=1M skip=10 | ???

-curl downloads the file
-tee splits the stream:
1. first stream acts only on the first 10MB, decrypts using openssl
2. second stream acts only after the first 10MB
??? don't know how to go on from here

Question: how do I join back these pipes in one pipe to input to "tar xzf -"?

Thank you.
 
Old 12-14-2010, 10:54 AM   #2
blittrell
LQ Newbie
 
Registered: Feb 2009
Location: Silicon Valley
Posts: 19

Rep: Reputation: 0
Quote:
Originally Posted by executivul View Post
Hello,
I have an encrypted archive, only part of the archive (first 10MB of the tar.gz) is actually encrypted, since the archive is quite large and asymmetric decription is slow.
On the receiving side I want the download and decryption + inflating to be as quick as possible. That's why I'm using pipes, not download locally and then decrypt and then inflate.
I intend to use tee:
curl http://server/file | tee >(dd bs=1M count=10 | openssl... | ???) | dd bs=1M skip=10 | ???

-curl downloads the file
-tee splits the stream:
1. first stream acts only on the first 10MB, decrypts using openssl
2. second stream acts only after the first 10MB
??? don't know how to go on from here

Question: how do I join back these pipes in one pipe to input to "tar xzf -"?

Thank you.
Don't know the answer to your question but might I suggest that if you want encryption for the file you encrypt it using a symmetric algorithm then us asymmetric algorithm to encrypt the symmetric key? Typically if your looking for security with performance being a priority that is how it is done..
 
Old 12-17-2010, 03:46 PM   #3
executivul
LQ Newbie
 
Registered: Dec 2010
Posts: 7

Original Poster
Rep: Reputation: 0
Even openssl symmetric encryption is slow (3.5MB/sec) compared to LZO (25MB/sec).
I'm looking now at named pipes, maybe that can solve the problem.
 
Old 12-19-2010, 09:24 AM   #4
executivul
LQ Newbie
 
Registered: Dec 2010
Posts: 7

Original Poster
Rep: Reputation: 0
I still haven't figured it out but, I've tried with named pipes:

mkfifo pipe
dd if=pipe | lzop -d | tar xf - & #this should wait for input in the pipe and decompress

now I have the two parts of the archive 1.lzo and 2.lzo, and I do:

dd if=1.lzo of=pipe
dd if=2.lzo of=pipe

This should work but it does not! The pipe is closed after the first dd, and I get an unexpected EOF from lzop.

How can I keep the pipe open? What good is a named pipe which closes after the first write to it?
 
Old 12-20-2010, 03:36 AM   #5
executivul
LQ Newbie
 
Registered: Dec 2010
Posts: 7

Original Poster
Rep: Reputation: 0
It can be done with named pipes

It can be done with named pipes:

mkfifo pipe1
mkfifo pipe2

cat pipe1 pipe2 | lzop -d | tar xf - &

curl part1 |openssl > pipe1
curl part2 > pipe2

Last edited by executivul; 12-20-2010 at 03:38 AM.
 
  


Reply



Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off



Similar Threads
Thread Thread Starter Forum Replies Last Post
[SOLVED] Using a long Bash command including single quotes and pipes in a Bash script antcore Linux - General 9 07-22-2009 11:10 AM
[SOLVED] Scope of unnamed pipes in BASH script propofol Programming 13 06-17-2009 12:54 AM
Bash - named pipes - mathew42 insight please PAix Programming 3 12-11-2007 09:09 AM
split utility in pipes: backup to FAT32 (4GB limit) Samsara Linux - Software 3 01-26-2007 11:25 PM
pipes and bash scripts twistedpair Linux - General 0 06-03-2004 09:59 PM

LinuxQuestions.org > Forums > Linux Forums > Linux - General

All times are GMT -5. The time now is 06:33 PM.

Main Menu
Advertisement
My LQ
Write for LQ
LinuxQuestions.org is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
Syndicate
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
Open Source Consulting | Domain Registration