monotone

monotone Mtn Source Tree

Root/botan/s2k.cpp

1/*************************************************
2* S2K Source File *
3* (C) 1999-2007 The Botan Project *
4*************************************************/
5
6#include <botan/s2k.h>
7#include <botan/rng.h>
8
9namespace Botan {
10
11/*************************************************
12* Derive a key from a passphrase *
13*************************************************/
14OctetString S2K::derive_key(u32bit key_len,
15 const std::string& passphrase) const
16 {
17 return derive(key_len, passphrase, salt, salt.size(), iterations());
18 }
19
20/*************************************************
21* Set the number of iterations *
22*************************************************/
23void S2K::set_iterations(u32bit i)
24 {
25 iter = i;
26 }
27
28/*************************************************
29* Change the salt *
30*************************************************/
31void S2K::change_salt(const byte new_salt[], u32bit length)
32 {
33 salt.set(new_salt, length);
34 }
35
36/*************************************************
37* Change the salt *
38*************************************************/
39void S2K::change_salt(const MemoryRegion<byte>& new_salt)
40 {
41 change_salt(new_salt.begin(), new_salt.size());
42 }
43
44/*************************************************
45* Create a new random salt *
46*************************************************/
47void S2K::new_random_salt(u32bit length)
48 {
49 salt.create(length);
50 Global_RNG::randomize(salt, length);
51 }
52
53}

Archive Download this file

Branches

Tags

Quick Links:     www.monotone.ca    -     Downloads    -     Documentation    -     Wiki    -     Code Forge    -     Build Status