blowfish.t
1 #! /usr/bin/env perl 2 3 # Licensed under the Apache License, Version 2.0 (the "License"); 4 # you may not use this file except in compliance with the License. 5 # See the NOTICE file distributed with this work for additional 6 # information regarding copyright ownership. 7 # You may obtain a copy of the License at 8 # 9 # http://www.apache.org/licenses/LICENSE-2.0 10 # 11 # Unless required by applicable law or agreed to in writing, software 12 # distributed under the License is distributed on an "AS IS" BASIS, 13 # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 14 # See the License for the specific language governing permissions and 15 # limitations under the License. 16 17 use strict; 18 use warnings; 19 20 use FindBin; 21 use lib "$FindBin::Bin"; 22 use driver; 23 use cmd_helpers; 24 25 runtests( 26 { 27 title => 'Blowfish-ECB withtest vector from libtomcrypt', 28 cases => [ 29 encrypt => { 30 input => 'input', 31 output => 'output', 32 auxilliary => 'key', 33 cmd => mk_cmd('lesec-tool', 'enc', 34 '-plugin ltc', 35 'blowfish-ecb', 36 mk_key_from('key'), 37 mk_opts(-pad => 'STRING')), 38 }, 39 decrypt => { 40 input => 'output', 41 output => 'input', 42 auxilliary => 'key', 43 cmd => mk_cmd('lesec-tool', 'dec', 44 '-plugin ltc', 45 'blowfish-ecb', 46 mk_key_from('key'), 47 mk_opts(-pad => 'STRING')), 48 }, 49 ], 50 algo => "blowfish-ecb", 51 vectors => [ 52 { 53 key => { key => "0000000000000000" }, 54 -pad => 0, 55 tests => [ 56 { 57 input => "0000000000000000", 58 output => "4EF997456198DD78" 59 }, 60 ] 61 }, 62 { 63 key => { key => "FFFFFFFFFFFFFFFF" }, 64 -pad => 0, 65 tests => [ 66 { 67 input => "FFFFFFFFFFFFFFFF", 68 output => "51866FD5B85ECB8A" 69 }, 70 ] 71 }, 72 { 73 key => { key => "3000000000000000" }, 74 -pad => 0, 75 tests => [ 76 { 77 input => "1000000000000001", 78 output => "7D856F9A613063F2" 79 }, 80 ] 81 } 82 ] 83 } 84 );