source: camellia/trunk/t_camellia.py @ 14

Revision 14, 761 bytes checked in by sgk, 13 years ago (diff)

実行フラグ。

  • Property svn:executable set to *
Line 
1#!/usr/bin/python
2
3# Copyright (c) 2006 by Accense Technology, Inc.
4
5import binascii
6import camellia
7
8# Test vector
9# 'http://info.isl.ntt.co.jp/crypt/camellia/dl/cryptrec/t_camellia.txt'
10testFile = './t_camellia.txt'
11
12
13for line in file(testFile).xreadlines():
14  if line[1:5] != ' No.':
15    continue
16  op = line[0]
17  id = line[5:8]
18  line = binascii.a2b_hex(''.join(line[11:].rstrip().split(' ')))
19
20  if op == 'K':
21    keyid = id
22    keytable = camellia.Ekeygen(line)
23
24  elif op == 'P':
25    testid = id
26    plain = line
27
28  elif op == 'C':
29    assert id == testid
30    assert camellia.EncryptBlock(plain, keytable) == line, 'Encrypt %s.%s' % (keyid, testid)
31    assert camellia.DecryptBlock(line, keytable) == plain, 'Encrypt %s.%s' % (keyid, testid)
32
33print 'ok'
Note: See TracBrowser for help on using the repository browser.