1
/*************************************************
2
* Boost.Python module definition *
3
* (C) 1999-2007 The Botan Project *
4
*************************************************/
6
#include <botan/botan.h>
9
#include <boost/python.hpp>
10
namespace python = boost::python;
15
u32bit output_length() const { return mac->OUTPUT_LENGTH; }
16
u32bit keylength_min() const { return mac->MINIMUM_KEYLENGTH; }
17
u32bit keylength_max() const { return mac->MAXIMUM_KEYLENGTH; }
18
u32bit keylength_mod() const { return mac->KEYLENGTH_MULTIPLE; }
19
std::string name() const { return mac->name(); }
20
void clear() throw() { mac->clear(); }
22
void set_key(const OctetString& key) { mac->set_key(key); }
24
bool valid_keylength(u32bit kl) const
26
return mac->valid_keylength(kl);
29
void update(const std::string& in) { mac->update(in); }
33
SecureVector<byte> result = mac->final();
34
return std::string((const char*)result.begin(), result.size());
37
Py_MAC(const std::string& name)
41
~Py_MAC() { delete mac; }
43
MessageAuthenticationCode* mac;
48
python::class_<Py_MAC>("MAC", python::init<std::string>())
49
.add_property("output_length", &Py_MAC::output_length)
50
.add_property("keylength_min", &Py_MAC::keylength_min)
51
.add_property("keylength_max", &Py_MAC::keylength_max)
52
.add_property("keylength_mod", &Py_MAC::keylength_mod)
53
.add_property("name", &Py_MAC::name)
54
.def("valid_keylength", &Py_MAC::valid_keylength)
55
.def("set_key", &Py_MAC::set_key)
56
.def("clear", &Py_MAC::clear)
57
.def("update", &Py_MAC::update)
58
.def("final", &Py_MAC::final);