aboutsummaryrefslogtreecommitdiffstats
path: root/misc/cms/cms_algo.cpp
diff options
context:
space:
mode:
authorlloyd <[email protected]>2006-06-03 06:59:11 +0000
committerlloyd <[email protected]>2006-06-03 06:59:11 +0000
commit720ef4cd84b5ac9ca127c44d891de11e61e4a584 (patch)
treef5b89afb6626d001345975d8e786904b4cee3e0c /misc/cms/cms_algo.cpp
parent4b2d4d38ce6e9b96e75b68026eece044d77edc7f (diff)
Various hacks that get the old CMS code close to compiling under
mainline. Not completely done, getting some of it to work may require changes to the ASN.1 code.
Diffstat (limited to 'misc/cms/cms_algo.cpp')
-rw-r--r--misc/cms/cms_algo.cpp26
1 files changed, 13 insertions, 13 deletions
diff --git a/misc/cms/cms_algo.cpp b/misc/cms/cms_algo.cpp
index daed4af87..ec4d1e5ae 100644
--- a/misc/cms/cms_algo.cpp
+++ b/misc/cms/cms_algo.cpp
@@ -49,7 +49,7 @@ SecureVector<byte> do_rfc3217_wrap(const std::string& cipher,
InitializationVector fixed("4ADDA22C79E82105");
Pipe pipe(get_cipher(cipher + "/CBC/NoPadding", kek, iv, ENCRYPTION),
- new Flip_Bytes(iv.copy()),
+ new Flip_Bytes(iv.bits_of()),
get_cipher(cipher + "/CBC/NoPadding", kek, fixed, ENCRYPTION));
pipe.start_msg();
pipe.write(input);
@@ -71,7 +71,7 @@ SecureVector<byte> CMS_Encoder::wrap_key(const std::string& cipher,
{
SymmetricKey cek_parity = cek;
cek_parity.set_odd_parity();
- return do_rfc3217_wrap(cipher, kek, cek_parity.copy());
+ return do_rfc3217_wrap(cipher, kek, cek_parity.bits_of());
}
else if(cipher == "RC2" || cipher == "CAST-128")
{
@@ -80,9 +80,9 @@ SecureVector<byte> CMS_Encoder::wrap_key(const std::string& cipher,
SecureVector<byte> lcekpad;
lcekpad.append((byte)cek.length());
- lcekpad.append(cek.copy());
+ lcekpad.append(cek.bits_of());
while(lcekpad.size() % 8)
- lcekpad.append(Global_RNG::random(Nonce));
+ lcekpad.append(Global_RNG::random());
return do_rfc3217_wrap(cipher, kek, lcekpad);
}
else
@@ -100,20 +100,20 @@ SecureVector<byte> CMS_Encoder::encode_params(const std::string& cipher,
if(cipher == "RC2")
{
- encoder.start_sequence();
- DER::encode(encoder, RC2::EKB_code(8*key.length()));
- DER::encode(encoder, iv.copy(), OCTET_STRING);
- encoder.end_sequence();
+ encoder.start_cons(SEQUENCE).
+ encode((u32bit)RC2::EKB_code(8*key.length())).
+ encode(iv.bits_of(), OCTET_STRING).
+ end_cons();
}
else if(cipher == "CAST-128")
{
- encoder.start_sequence();
- DER::encode(encoder, iv.copy(), OCTET_STRING);
- DER::encode(encoder, 8*key.length());
- encoder.end_sequence();
+ encoder.start_cons(SEQUENCE).
+ encode(iv.bits_of(), OCTET_STRING).
+ encode(8*key.length()).
+ end_cons();
}
else
- DER::encode(encoder, iv.copy(), OCTET_STRING);
+ encoder.encode(iv.bits_of(), OCTET_STRING);
return encoder.get_contents();
}