Skip to content

Commit

Permalink
Bug 1355422 - make enctool windows compatible, r=ttaubert
Browse files Browse the repository at this point in the history
Differential Revision: https://nss-review.dev.mozaws.net/D293

--HG--
extra : rebase_source : b927f4c46e894bb70fcebe5fe13168162fac2604
extra : amend_source : 0ae833acacd8d12b21415b3703c130e85e15a3e8
  • Loading branch information
franziskuskiefer committed Apr 26, 2017
1 parent 8731b18 commit d2634ca
Showing 1 changed file with 6 additions and 6 deletions.
12 changes: 6 additions & 6 deletions nss-tool/enc/enctool.cc
Expand Up @@ -231,7 +231,7 @@ bool EncTool::DoCipher(std::string file_name, std::string out_file,
bool encrypt, key_func_t get_params) {
SECStatus rv;
unsigned int outLen = 0, chunkSize = 1024;
char buffer[chunkSize + 16];
char buffer[1040];
const unsigned char* bufferStart =
reinterpret_cast<const unsigned char*>(buffer);

Expand Down Expand Up @@ -270,21 +270,21 @@ bool EncTool::DoCipher(std::string file_name, std::string out_file,
// Read from stdin.
if (file_name.empty()) {
std::vector<uint8_t> data = ReadInputData("");
uint8_t out[data.size() + 16];
std::vector<uint8_t> out(data.size() + 16);
SECStatus rv;
if (encrypt) {
rv = PK11_Encrypt(symKey.get(), cipher_mech_, params.get(), out, &outLen,
rv = PK11_Encrypt(symKey.get(), cipher_mech_, params.get(), out.data(), &outLen,
data.size() + 16, data.data(), data.size());
} else {
rv = PK11_Decrypt(symKey.get(), cipher_mech_, params.get(), out, &outLen,
rv = PK11_Decrypt(symKey.get(), cipher_mech_, params.get(), out.data(), &outLen,
data.size() + 16, data.data(), data.size());
}
if (rv != SECSuccess) {
PrintError(encrypt ? "Error encrypting" : "Error decrypting",
PR_GetError(), __LINE__);
return false;
};
output.write(reinterpret_cast<char*>(out), outLen);
output.write(reinterpret_cast<char*>(out.data()), outLen);
output.flush();
if (output_file.good()) {
output_file.close();
Expand All @@ -302,7 +302,7 @@ bool EncTool::DoCipher(std::string file_name, std::string out_file,
if (!input.good()) {
return false;
}
uint8_t out[chunkSize + 16];
uint8_t out[1040];
while (input) {
if (encrypt) {
input.read(buffer, chunkSize);
Expand Down

0 comments on commit d2634ca

Please sign in to comment.