1 |
diff -p -up steghide-0.5.1/src/Arguments.cc.passphrase steghide-0.5.1/src/Arguments.cc |
2 |
--- steghide-0.5.1/src/Arguments.cc.passphrase 2009-06-23 04:19:02.000000000 +0200 |
3 |
+++ steghide-0.5.1/src/Arguments.cc 2009-06-23 04:22:11.000000000 +0200 |
4 |
@@ -20,6 +20,7 @@ |
5 |
|
6 |
#include <cstring> |
7 |
#include <iostream> |
8 |
+#include <fstream> |
9 |
#include <string> |
10 |
|
11 |
#include "MCryptPP.h" |
12 |
@@ -28,6 +29,8 @@ |
13 |
#include "error.h" |
14 |
#include "msg.h" |
15 |
|
16 |
+using namespace std; |
17 |
+ |
18 |
float Arguments::Default_Goal = 100.0 ; |
19 |
|
20 |
// the global Arguments object |
21 |
@@ -322,11 +325,44 @@ bool Arguments::parse_StgFn (ArgIt& cura |
22 |
return found ; |
23 |
} |
24 |
|
25 |
+bool Arguments::parse_PassphraseFile (ArgIt& curarg) |
26 |
+{ |
27 |
+ bool found = false ; |
28 |
+ |
29 |
+ if (*curarg == "-pf" || *curarg == "--passphrase-file") { |
30 |
+ if (Passphrase.is_set()) { |
31 |
+ throw ArgError (_("the passphrase is already set.")) ; |
32 |
+ } |
33 |
+ |
34 |
+ if (++curarg == TheArguments.end()) { |
35 |
+ throw ArgError (_("the \"%s\" argument must be followed by the passphrase filename."), (curarg - 1)->c_str()); |
36 |
+ } |
37 |
+ |
38 |
+ string s; |
39 |
+ if( *curarg == "-" ) { // - means standard input |
40 |
+ cin >> s; |
41 |
+ } else { |
42 |
+ ifstream passphraseFile(curarg->c_str()); |
43 |
+ if( !passphraseFile ) { |
44 |
+ throw ArgError (_("the passphrase could not be read from file \"%s\"."), curarg->c_str()); |
45 |
+ } |
46 |
+ passphraseFile >> s; |
47 |
+ passphraseFile.close(); |
48 |
+ } |
49 |
+ Passphrase.setValue (s); |
50 |
+ found = true ; |
51 |
+ curarg++ ; |
52 |
+ } |
53 |
+ |
54 |
+ return found ; |
55 |
+} |
56 |
+ |
57 |
bool Arguments::parse_Passphrase (ArgIt& curarg) |
58 |
{ |
59 |
bool found = false ; |
60 |
|
61 |
- if (*curarg == "-p" || *curarg == "--passphrase") { |
62 |
+ found = parse_PassphraseFile( curarg ); |
63 |
+ if (!found && (*curarg == "-p" || *curarg == "--passphrase")) { |
64 |
if (Passphrase.is_set()) { |
65 |
throw ArgError (_("the passphrase argument can be used only once.")) ; |
66 |
} |
67 |
diff -p -up steghide-0.5.1/src/Arguments.h.passphrase steghide-0.5.1/src/Arguments.h |
68 |
--- steghide-0.5.1/src/Arguments.h.passphrase 2009-06-23 04:19:02.000000000 +0200 |
69 |
+++ steghide-0.5.1/src/Arguments.h 2009-06-23 04:19:02.000000000 +0200 |
70 |
@@ -124,6 +124,7 @@ class Arguments { |
71 |
bool parse_ExtFn (ArgIt& curarg) ; |
72 |
bool parse_CvrFn (ArgIt& curarg) ; |
73 |
bool parse_StgFn (ArgIt& curarg) ; |
74 |
+ bool parse_PassphraseFile (ArgIt& curarg) ; |
75 |
bool parse_Passphrase (ArgIt& curarg) ; |
76 |
bool parse_Checksum (ArgIt& curarg) ; |
77 |
bool parse_Compression (ArgIt& curarg) ; |
78 |
diff -p -up steghide-0.5.1/src/Session.cc.passphrase steghide-0.5.1/src/Session.cc |
79 |
--- steghide-0.5.1/src/Session.cc.passphrase 2003-09-29 12:07:10.000000000 +0200 |
80 |
+++ steghide-0.5.1/src/Session.cc 2009-06-23 04:19:02.000000000 +0200 |
81 |
@@ -260,6 +260,8 @@ void Session::printHelp () |
82 |
" -cf <filename> embed into the file <filename>\n" |
83 |
" -p, --passphrase specify passphrase\n" |
84 |
" -p <passphrase> use <passphrase> to embed data\n" |
85 |
+ " -pf, --passphrase-file read passphrase from the specified file\n" |
86 |
+ " -pf <filename> \n" |
87 |
" -sf, --stegofile select stego file\n" |
88 |
" -sf <filename> write result to <filename> instead of cover-file\n" |
89 |
" -e, --encryption select encryption parameters\n" |
90 |
@@ -279,6 +281,8 @@ void Session::printHelp () |
91 |
" -sf <filename> extract data from <filename>\n" |
92 |
" -p, --passphrase specify passphrase\n" |
93 |
" -p <passphrase> use <passphrase> to extract data\n" |
94 |
+ " -pf, --passphrase-file read passphrase from the specified file\n" |
95 |
+ " -pf <filename> \n" |
96 |
" -xf, --extractfile select file name for extracted data\n" |
97 |
" -xf <filename> write the extracted data to <filename>\n" |
98 |
" -f, --force overwrite existing files\n" |
99 |
@@ -288,6 +292,8 @@ void Session::printHelp () |
100 |
"\noptions for the info command:\n" |
101 |
" -p, --passphrase specify passphrase\n" |
102 |
" -p <passphrase> use <passphrase> to get info about embedded data\n" |
103 |
+ " -pf, --passphrase-file read passphrase from the specified file\n" |
104 |
+ " -pf <filename> \n" |
105 |
|
106 |
"\nTo embed emb.txt in cvr.jpg: steghide embed -cf cvr.jpg -ef emb.txt\n" |
107 |
"To extract embedded data from stg.jpg: steghide extract -sf stg.jpg\n")) ; |