aboutsummaryrefslogtreecommitdiffstats
path: root/src/lib/misc/srp6/srp6_files.h
blob: 124bfc86a10aea975831bdee2dd406461f5cd1ce (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
63
64
65
66
67
/*
* SRP-6a File Handling
* (C) 2011 Jack Lloyd
*
* Botan is released under the Simplified BSD License (see license.txt)
*/

#ifndef BOTAN_SRP6A_FILES_H__
#define BOTAN_SRP6A_FILES_H__

#include <botan/bigint.h>
#include <iosfwd>
#include <string>
#include <map>

namespace Botan {

/**
* A GnuTLS compatible SRP6 authenticator file
*/
class BOTAN_DLL SRP6_Authenticator_File
   {
   public:

      /**
      * @param input will be read and processed as SRP authenticator file
      */
      explicit SRP6_Authenticator_File(std::istream& input);

      /**
      * Looks up a user in the authenticator file.
      * @param username user to look up
      * @param v set to the host's password verifier
      * @param salt set to the user's salt value
      * @param group_id set to the user's group value
      * @return whether a user exists in the authenticator file
      */
      bool lookup_user(const std::string& username,
                       BigInt& v,
                       std::vector<uint8_t>& salt,
                       std::string& group_id) const;
   private:
      struct SRP6_Data
         {
         SRP6_Data() {}

         SRP6_Data(const BigInt& v_,
                   const std::vector<uint8_t>& salt_,
                   const std::string& group_id_) :
            v(v_), salt(salt_), group_id(group_id_) {}

         // public member variable:
         BigInt v;

         // public member variable:
         std::vector<uint8_t> salt;

         // public member variable:
         std::string group_id;
         };

      std::map<std::string, SRP6_Data> m_entries;
   };

}

#endif