aboutsummaryrefslogtreecommitdiffstats
path: root/src/pbes2.cpp
diff options
context:
space:
mode:
authorlloyd <[email protected]>2006-05-19 00:07:25 +0000
committerlloyd <[email protected]>2006-05-19 00:07:25 +0000
commitf090e030be53e574fecbe7cf50edfb5fdacb53e1 (patch)
tree0bff0c249a9dbcb674fcd2491ab17e3d123ef1f9 /src/pbes2.cpp
parenta0af7b26591f8fb79d1f06fe42548e1eb0c35e90 (diff)
Syntax changes to the BER and DER APIs to improve readability of code
that uses them. These changes are not backwards compatible, this commit updates all uses of the APIs within the library.
Diffstat (limited to 'src/pbes2.cpp')
-rw-r--r--src/pbes2.cpp39
1 files changed, 19 insertions, 20 deletions
diff --git a/src/pbes2.cpp b/src/pbes2.cpp
index 036acb675..0eeb4eee5 100644
--- a/src/pbes2.cpp
+++ b/src/pbes2.cpp
@@ -4,6 +4,8 @@
*************************************************/
#include <botan/pbe_pkcs.h>
+#include <botan/der_enc.h>
+#include <botan/ber_dec.h>
#include <botan/parsing.h>
#include <botan/lookup.h>
#include <botan/rng.h>
@@ -95,15 +97,15 @@ void PBE_PKCS5v20::new_params()
MemoryVector<byte> PBE_PKCS5v20::encode_params() const
{
return DER_Encoder()
- .start_sequence()
+ .start_cons(SEQUENCE)
.encode(
AlgorithmIdentifier("PKCS5.PBKDF2",
DER_Encoder()
- .start_sequence()
+ .start_cons(SEQUENCE)
.encode(salt, OCTET_STRING)
.encode(iterations)
.encode(key_length)
- .end_sequence()
+ .end_cons()
.get_contents()
)
)
@@ -114,7 +116,7 @@ MemoryVector<byte> PBE_PKCS5v20::encode_params() const
.get_contents()
)
)
- .end_sequence()
+ .end_cons()
.get_contents();
}
@@ -125,22 +127,24 @@ void PBE_PKCS5v20::decode_params(DataSource& source)
{
AlgorithmIdentifier kdf_algo, enc_algo;
- BER_Decoder decoder(source);
- BER_Decoder sequence = BER::get_subsequence(decoder);
- BER::decode(sequence, kdf_algo);
- BER::decode(sequence, enc_algo);
- sequence.verify_end();
+ BER_Decoder(source)
+ .start_cons(SEQUENCE)
+ .decode(kdf_algo)
+ .decode(enc_algo)
+ .verify_end()
+ .end_cons();
if(kdf_algo.oid == OIDS::lookup("PKCS5.PBKDF2"))
{
digest = "SHA-160";
- BER_Decoder pbkdf2_params(kdf_algo.parameters);
- BER_Decoder algo_params = BER::get_subsequence(pbkdf2_params);
- algo_params.decode(salt, OCTET_STRING);
- algo_params.decode(iterations);
- BER::decode_optional(algo_params, key_length, INTEGER, UNIVERSAL);
- algo_params.verify_end();
+ BER_Decoder(kdf_algo.parameters)
+ .start_cons(SEQUENCE)
+ .decode(salt, OCTET_STRING)
+ .decode(iterations)
+ .decode_optional(key_length, INTEGER, UNIVERSAL)
+ .verify_end()
+ .end_cons();
}
else
throw Decoding_Error("PBE-PKCS5 v2.0: Unknown KDF algorithm " +
@@ -156,12 +160,7 @@ void PBE_PKCS5v20::decode_params(DataSource& source)
throw Decoding_Error("PBE-PKCS5 v2.0: Don't know param format for " +
cipher);
-#if 0
- BER_Decoder algo_params(enc_algo.parameters);
- algo_params.decode(iv, OCTET_STRING);
-#else
BER_Decoder(enc_algo.parameters).decode(iv, OCTET_STRING).verify_end();
-#endif
if(key_length == 0)
key_length = max_keylength_of(cipher_algo);