mirror of
https://github.com/guanzhi/GmSSL.git
synced 2026-05-07 08:56:17 +08:00
update speck module
This commit is contained in:
@@ -21,7 +21,7 @@ IF[{- !$disabled{tests} -}]
|
||||
pailliertest cpktest otptest gmapitest ec2test \
|
||||
bfibetest bb1ibetest sm9test \
|
||||
saftest sdftest skftest softest zuctest \
|
||||
serpenttest
|
||||
serpenttest specktest
|
||||
|
||||
SOURCE[aborttest]=aborttest.c
|
||||
INCLUDE[aborttest]=../include
|
||||
@@ -368,6 +368,10 @@ IF[{- !$disabled{tests} -}]
|
||||
INCLUDE[serpenttest]=../include
|
||||
DEPEND[serpenttest]=../libcrypto
|
||||
|
||||
SOURCE[specktest]=specktest.c
|
||||
INCLUDE[specktest]=../include
|
||||
DEPEND[specktest]=../libcrypto
|
||||
|
||||
IF[{- !$disabled{shared} -}]
|
||||
PROGRAMS_NO_INST=shlibloadtest
|
||||
SOURCE[shlibloadtest]=shlibloadtest.c
|
||||
|
||||
12
test/recipes/05-test_speck.t
Normal file
12
test/recipes/05-test_speck.t
Normal file
@@ -0,0 +1,12 @@
|
||||
#! /usr/bin/env perl
|
||||
# Copyright 2015-2016 The OpenSSL Project Authors. All Rights Reserved.
|
||||
#
|
||||
# Licensed under the OpenSSL license (the "License"). You may not use
|
||||
# this file except in compliance with the License. You can obtain a copy
|
||||
# in the file LICENSE in the source distribution or at
|
||||
# https://www.openssl.org/source/license.html
|
||||
|
||||
|
||||
use OpenSSL::Test::Simple;
|
||||
|
||||
simple_test("test_speck", "specktest", "speck");
|
||||
38
test/specktest.c
Normal file
38
test/specktest.c
Normal file
@@ -0,0 +1,38 @@
|
||||
#include <stdio.h>
|
||||
#include <string.h>
|
||||
#include <stdlib.h>
|
||||
|
||||
#include "../e_os.h"
|
||||
|
||||
#ifdef OPENSSL_NO_SPECK
|
||||
int main(int argc, char **argv)
|
||||
{
|
||||
printf("No Speck support\n");
|
||||
return 0;
|
||||
}
|
||||
#else
|
||||
|
||||
#include <openssl/speck.h>
|
||||
|
||||
int main(int argc, char **argv)
|
||||
{
|
||||
speck_key_t key;
|
||||
unsigned char userkey[2] = { 0x01, 0x02, };
|
||||
unsigned char msg[2] = { 0xab, 0xcd, };
|
||||
SPECK_TYPE S[SPECK_ROUNDS];
|
||||
|
||||
unsigned char cbuf[2];
|
||||
unsigned char mbuf[2];
|
||||
|
||||
speck_set_encrypt_key(&key, userkey);
|
||||
speck_expand(&key, S);
|
||||
speck_encrypt(msg, cbuf, S);
|
||||
speck_decrypt(cbuf, mbuf, S);
|
||||
|
||||
if (memcmp(msg, mbuf, 2)) {
|
||||
return -1;
|
||||
}
|
||||
|
||||
return 0;
|
||||
}
|
||||
#endif
|
||||
Reference in New Issue
Block a user