aboutsummaryrefslogtreecommitdiffstats
path: root/src/s2k/s2k.h
blob: 82f5abeefc6958ef73aeb3f3ac2243ede67e1f78 (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
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
/*
* S2K
* (C) 1999-2007 Jack Lloyd
*
* Distributed under the terms of the Botan license
*/

#ifndef BOTAN_S2K_H__
#define BOTAN_S2K_H__

#include <botan/symkey.h>
#include <botan/rng.h>

namespace Botan {

/*
* S2K Interface
*/
class BOTAN_DLL S2K
   {
   public:
      /**
      * Create a copy of this object.
      * @return an auto_ptr to a copy of this object
      */
      virtual S2K* clone() const = 0;

      /**
      * Get the algorithm name.
      * @return the name of this S2K algorithm
      */
      virtual std::string name() const = 0;

      /**
      * Clear this objects internal values.
      */
      virtual void clear() {}

      /**
      * Derive a key from a passphrase with this S2K object. It will use
      * the salt value and number of iterations configured in this object.
      * @param output_len the desired length of the key to produce
      * @param passphrase the password to derive the key from
      * @param salt the randomly chosen salt
      * @param salt_len length of salt in bytes
      * @param iterations the number of iterations to use (use 10K or more)
      */
      virtual OctetString derive_key(u32bit output_len,
                                     const std::string& passphrase,
                                     const byte salt[], u32bit salt_len,
                                     u32bit iterations) const = 0;

      S2K() {}
      virtual ~S2K() {}
   private:
      S2K(const S2K&) {}
      S2K& operator=(const S2K&) { return (*this); }
   };

}

#endif