Botan 1.10.17
serp_x86_32.cpp
Go to the documentation of this file.
1/*
2* Serpent in x86-32
3* (C) 1999-2007 Jack Lloyd
4*
5* Distributed under the terms of the Botan license
6*/
7
8#include <botan/serp_x86_32.h>
9#include <botan/loadstor.h>
10
11namespace Botan {
12
13extern "C" {
14
15/**
16* Entry point for Serpent encryption in x86 asm
17* @param in the input block
18* @param out the output block
19* @param ks the key schedule
20*/
21void botan_serpent_x86_32_encrypt(const byte in[16],
22 byte out[16],
23 const u32bit ks[132]);
24
25/**
26* Entry point for Serpent decryption in x86 asm
27* @param in the input block
28* @param out the output block
29* @param ks the key schedule
30*/
31void botan_serpent_x86_32_decrypt(const byte in[16],
32 byte out[16],
33 const u32bit ks[132]);
34
35/**
36* Entry point for Serpent key schedule in x86 asm
37* @param ks holds the initial working key (padded), and is set to the
38 final key schedule
39*/
41
42}
43
44/*
45* Serpent Encryption
46*/
47void Serpent_X86_32::encrypt_n(const byte in[], byte out[], size_t blocks) const
48 {
49 for(size_t i = 0; i != blocks; ++i)
50 {
52 in += BLOCK_SIZE;
53 out += BLOCK_SIZE;
54 }
55 }
56
57/*
58* Serpent Decryption
59*/
60void Serpent_X86_32::decrypt_n(const byte in[], byte out[], size_t blocks) const
61 {
62 for(size_t i = 0; i != blocks; ++i)
63 {
65 in += BLOCK_SIZE;
66 out += BLOCK_SIZE;
67 }
68 }
69
70/*
71* Serpent Key Schedule
72*/
73void Serpent_X86_32::key_schedule(const byte key[], size_t length)
74 {
76 for(size_t i = 0; i != length / 4; ++i)
77 W[i] = load_le<u32bit>(key, i);
78 W[length / 4] |= u32bit(1) << ((length%4)*8);
79
81 this->set_round_keys(W + 8);
82 }
83
84}
void encrypt_n(const byte in[], byte out[], size_t blocks) const
void decrypt_n(const byte in[], byte out[], size_t blocks) const
const SecureVector< u32bit > & get_round_keys() const
Definition serpent.h:34
void set_round_keys(const u32bit ks[132])
Definition serpent.h:41
void botan_serpent_x86_32_key_schedule(u32bit ks[140])
void botan_serpent_x86_32_decrypt(const byte in[16], byte out[16], const u32bit ks[132])
T load_le(const byte in[], size_t off)
Definition loadstor.h:116
void botan_serpent_x86_32_encrypt(const byte in[16], byte out[16], const u32bit ks[132])
unsigned int u32bit
Definition types.h:32