aboutsummaryrefslogtreecommitdiffstats
path: root/src/tests/test_transform.cpp
blob: aba0e32c91cf3eece345520a7e333773585f9ea5 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
#include "tests.h"

#include <botan/transform.h>
#include <botan/hex.h>
#include <iostream>
#include <fstream>

using namespace Botan;

namespace {

Transformation* get_transform(const std::string& algo)
   {
   throw std::runtime_error("Unknown transform " + algo);
   }

secure_vector<byte> transform_test(const std::string& algo,
                                   const secure_vector<byte>& nonce,
                                   const secure_vector<byte>& /*key*/,
                                   const secure_vector<byte>& in)
   {
   std::unique_ptr<Transformation> transform(get_transform(algo));

   //transform->set_key(key);
   transform->start(nonce);

   secure_vector<byte> out = in;
   transform->update(out, 0);

   return out;
   }

}

size_t test_transform()
   {
   std::ifstream vec(TEST_DATA_DIR "/transform.vec");

   return run_tests(vec, "Transform", "Output", true,
             [](std::map<std::string, std::string> m)
             {
             return hex_encode(transform_test(m["Transform"],
                                              hex_decode_locked(m["Nonce"]),
                                              hex_decode_locked(m["Key"]),
                                              hex_decode_locked(m["Input"])));
             });
   }