blob: b52562edbfa8275929cbf41182efa0e5d2888658 [file] [log] [blame]
Alexandre Lisionddd731e2014-01-31 11:50:08 -05001// Copyright (C) 2010 David Sugar, Tycho Softworks.
2//
3// This file is part of GNU uCommon C++.
4//
5// GNU uCommon C++ is free software: you can redistribute it and/or modify
6// it under the terms of the GNU Lesser General Public License as published
7// by the Free Software Foundation, either version 3 of the License, or
8// (at your option) any later version.
9//
10// GNU uCommon C++ is distributed in the hope that it will be useful,
11// but WITHOUT ANY WARRANTY; without even the implied warranty of
12// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13// GNU Lesser General Public License for more details.
14//
15// You should have received a copy of the GNU Lesser General Public License
16// along with GNU uCommon C++. If not, see <http://www.gnu.org/licenses/>.
17
18#include "local.h"
19
20static const unsigned char *_salt = NULL;
21static unsigned _rounds = 1;
22
23void Cipher::Key::assign(const char *text, size_t size, const unsigned char *salt, unsigned rounds)
24{
25 keysize = 0;
26}
27
28void Cipher::Key::set(const char *cipher)
29{
30 clear();
31}
32
33void Cipher::Key::set(const char *cipher, const char *digest)
34{
35 set(cipher);
36}
37
38void Cipher::Key::assign(const char *text, size_t size)
39{
40 assign(text, size, _salt, _rounds);
41}
42
43void Cipher::Key::options(const unsigned char *salt, unsigned rounds)
44{
45 _salt = salt;
46 _rounds = rounds;
47}
48
49bool Cipher::has(const char *id)
50{
51 return false;
52}
53
54void Cipher::push(unsigned char *address, size_t size)
55{
56}
57
58void Cipher::release(void)
59{
60}
61
62void Cipher::set(key_t key, mode_t mode, unsigned char *address, size_t size)
63{
64 release();
65
66 bufsize = size;
67 bufmode = mode;
68 bufaddr = address;
69
70 memcpy(&keys, key, sizeof(keys));
71}
72
73size_t Cipher::put(const unsigned char *data, size_t size)
74{
75 size_t count = 0;
76
77 while(bufsize && size + bufpos > bufsize) {
78 size_t diff = bufsize - bufpos;
79 count += put(data, diff);
80 data += diff;
81 size -= diff;
82 }
83
84 return 0;
85}
86
87size_t Cipher::pad(const unsigned char *data, size_t size)
88{
89 return 0;
90}
91