File: stirrer_blowfish.cpp

package info (click to toggle)
entropybroker 2.9-3
  • links: PTS, VCS
  • area: main
  • in suites: buster
  • size: 1,600 kB
  • sloc: cpp: 14,386; sh: 934; makefile: 188; java: 148; perl: 12
file content (45 lines) | stat: -rw-r--r-- 989 bytes parent folder | download | duplicates (3)
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
#include <string.h>
#include <arpa/inet.h>
#include <string>
#include <vector>
#include <arpa/inet.h>

#include "error.h"
#include "utils.h"
#include "encrypt_stream.h"
#include "encrypt_stream_blowfish.h"
#include "stirrer.h"
#include "stirrer_blowfish.h"

stirrer_blowfish::stirrer_blowfish()
{
}

stirrer_blowfish::~stirrer_blowfish()
{
}

int stirrer_blowfish::get_stir_size()
{
	return enc.get_key_size();
}

int stirrer_blowfish::get_ivec_size()
{
	return enc.get_ivec_size();
}

void stirrer_blowfish::do_stir(unsigned char *ivec, unsigned char *target, int target_size, unsigned char *data_in, int data_in_size, unsigned char *temp_buffer, bool direction)
{
	my_assert(target_size > 0);
	my_assert(data_in_size > 0);

	if (data_in_size > get_stir_size())
		error_exit("Invalid stir-size %d (expected: %d)", data_in_size, get_stir_size());

	enc.init(data_in, data_in_size, ivec, true);

	enc.encrypt(target, target_size, temp_buffer);

	memcpy(target, temp_buffer, target_size);
}