~ubuntu-branches/debian/sid/botan/sid

« back to all changes in this revision

Viewing changes to modules/alg_ia32/serpent.cpp

  • Committer: Package Import Robot
  • Author(s): Laszlo Boszormenyi (GCS)
  • Date: 2018-03-01 22:23:25 UTC
  • mfrom: (1.2.2)
  • Revision ID: package-import@ubuntu.com-20180301222325-7p7vc45gu3hta34d
Tags: 2.4.0-2
* Don't remove .doctrees from the manual if it doesn't exist.
* Don't specify parallel to debhelper.

Show diffs side-by-side

added added

removed removed

Lines of Context:
1
 
/*************************************************
2
 
* Serpent Source File                            *
3
 
* (C) 1999-2007 The Botan Project                *
4
 
*************************************************/
5
 
 
6
 
#include <botan/serpent.h>
7
 
#include <botan/bit_ops.h>
8
 
 
9
 
namespace Botan {
10
 
 
11
 
extern "C" {
12
 
 
13
 
void serpent_encrypt(const byte[16], byte[16], const u32bit[132]);
14
 
void serpent_decrypt(const byte[16], byte[16], const u32bit[132]);
15
 
void serpent_key_schedule(u32bit[140]);
16
 
 
17
 
}
18
 
 
19
 
/*************************************************
20
 
* Serpent Encryption                             *
21
 
*************************************************/
22
 
void Serpent::enc(const byte in[], byte out[]) const
23
 
   {
24
 
   serpent_encrypt(in, out, round_key);
25
 
   }
26
 
 
27
 
/*************************************************
28
 
* Serpent Decryption                             *
29
 
*************************************************/
30
 
void Serpent::dec(const byte in[], byte out[]) const
31
 
   {
32
 
   serpent_decrypt(in, out, round_key);
33
 
   }
34
 
 
35
 
/*************************************************
36
 
* Serpent Key Schedule                           *
37
 
*************************************************/
38
 
void Serpent::key(const byte key[], u32bit length)
39
 
   {
40
 
   SecureBuffer<u32bit, 140> W;
41
 
   for(u32bit j = 0; j != length / 4; ++j)
42
 
      W[j] = make_u32bit(key[4*j+3], key[4*j+2], key[4*j+1], key[4*j]);
43
 
   W[length / 4] |= u32bit(1) << ((length%4)*8);
44
 
 
45
 
   serpent_key_schedule(W);
46
 
   round_key.copy(W + 8, 132);
47
 
   }
48
 
 
49
 
}