mirror of
https://github.com/guanzhi/GmSSL.git
synced 2026-06-24 14:13:45 +08:00
update speck module
This commit is contained in:
@@ -313,7 +313,7 @@ $config{sdirs} = [
|
|||||||
"cms", "ts", "srp", "cmac", "ct", "async", "kdf",
|
"cms", "ts", "srp", "cmac", "ct", "async", "kdf",
|
||||||
"sm3", "sms4", "kdf2", "ecies", "ffx", "sm2", "paillier", "cpk", "otp", "gmapi", "ec2",
|
"sm3", "sms4", "kdf2", "ecies", "ffx", "sm2", "paillier", "cpk", "otp", "gmapi", "ec2",
|
||||||
"bfibe", "bb1ibe", "sm9", "saf", "sdf", "skf", "sof", "zuc",
|
"bfibe", "bb1ibe", "sm9", "saf", "sdf", "skf", "sof", "zuc",
|
||||||
"serpent"
|
"serpent", "speck"
|
||||||
];
|
];
|
||||||
|
|
||||||
# Known TLS and DTLS protocols
|
# Known TLS and DTLS protocols
|
||||||
@@ -434,6 +434,7 @@ my @disablables = (
|
|||||||
"pkcs7",
|
"pkcs7",
|
||||||
"pkcs12",
|
"pkcs12",
|
||||||
"serpent",
|
"serpent",
|
||||||
|
"speck",
|
||||||
);
|
);
|
||||||
foreach my $proto ((@tls, @dtls))
|
foreach my $proto ((@tls, @dtls))
|
||||||
{
|
{
|
||||||
@@ -477,6 +478,7 @@ our %disabled = ( # "what" => "comment"
|
|||||||
"saf" => "default",
|
"saf" => "default",
|
||||||
"sof" => "default",
|
"sof" => "default",
|
||||||
"serpent" => "default",
|
"serpent" => "default",
|
||||||
|
# "speck" => "default",
|
||||||
);
|
);
|
||||||
|
|
||||||
# Note: => pair form used for aesthetics, not to truly make a hash table
|
# Note: => pair form used for aesthetics, not to truly make a hash table
|
||||||
|
|||||||
2
crypto/speck/build.info
Normal file
2
crypto/speck/build.info
Normal file
@@ -0,0 +1,2 @@
|
|||||||
|
LIBS=../../libcrypto
|
||||||
|
SOURCE[../../libcrypto]=speck.c
|
||||||
@@ -1,4 +1,4 @@
|
|||||||
#include "speck.h"
|
#include <openssl/speck.h>
|
||||||
|
|
||||||
#define ROR(x, r) ((x >> r) | (x << ((sizeof(SPECK_TYPE) * 8) - r)))//循环右移
|
#define ROR(x, r) ((x >> r) | (x << ((sizeof(SPECK_TYPE) * 8) - r)))//循环右移
|
||||||
#define ROL(x, r) ((x << r) | (x >> ((sizeof(SPECK_TYPE) * 8) - r)))//循环左移
|
#define ROL(x, r) ((x << r) | (x >> ((sizeof(SPECK_TYPE) * 8) - r)))//循环左移
|
||||||
@@ -11,7 +11,7 @@
|
|||||||
#define RR(x, y, k) (y ^= x, y = ROR(y, 3), x ^= k, x -= y, x = ROL(x, 8))
|
#define RR(x, y, k) (y ^= x, y = ROR(y, 3), x ^= k, x -= y, x = ROL(x, 8))
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
void mycipher_set_encrypt_key(mycipher_key_t *key, const unsigned char *user_key)
|
void speck_set_encrypt_key(speck_key_t *key, const unsigned char *user_key)
|
||||||
{
|
{
|
||||||
int i;
|
int i;
|
||||||
for (i = 0; i < num_word; i++)
|
for (i = 0; i < num_word; i++)
|
||||||
@@ -35,9 +35,9 @@ extern "C" {
|
|||||||
|
|
||||||
typedef struct {
|
typedef struct {
|
||||||
unsigned char rk[num_word];
|
unsigned char rk[num_word];
|
||||||
} mycipher_key_t;
|
} speck_key_t;
|
||||||
|
|
||||||
void mycipher_set_encrypt_key(mycipher_key_t *key, const unsigned char *user_key);
|
void speck_set_encrypt_key(speck_key_t *key, const unsigned char *user_key);
|
||||||
void speck_expand(SPECK_TYPE const K[SPECK_KEY_LEN], SPECK_TYPE S[SPECK_ROUNDS]);
|
void speck_expand(SPECK_TYPE const K[SPECK_KEY_LEN], SPECK_TYPE S[SPECK_ROUNDS]);
|
||||||
void speck_encrypt(SPECK_TYPE const pt[2], SPECK_TYPE ct[2], SPECK_TYPE const K[SPECK_ROUNDS]);
|
void speck_encrypt(SPECK_TYPE const pt[2], SPECK_TYPE ct[2], SPECK_TYPE const K[SPECK_ROUNDS]);
|
||||||
void speck_decrypt(SPECK_TYPE const ct[2], SPECK_TYPE pt[2], SPECK_TYPE const K[SPECK_ROUNDS]);
|
void speck_decrypt(SPECK_TYPE const ct[2], SPECK_TYPE pt[2], SPECK_TYPE const K[SPECK_ROUNDS]);
|
||||||
@@ -21,7 +21,7 @@ IF[{- !$disabled{tests} -}]
|
|||||||
pailliertest cpktest otptest gmapitest ec2test \
|
pailliertest cpktest otptest gmapitest ec2test \
|
||||||
bfibetest bb1ibetest sm9test \
|
bfibetest bb1ibetest sm9test \
|
||||||
saftest sdftest skftest softest zuctest \
|
saftest sdftest skftest softest zuctest \
|
||||||
serpenttest
|
serpenttest specktest
|
||||||
|
|
||||||
SOURCE[aborttest]=aborttest.c
|
SOURCE[aborttest]=aborttest.c
|
||||||
INCLUDE[aborttest]=../include
|
INCLUDE[aborttest]=../include
|
||||||
@@ -368,6 +368,10 @@ IF[{- !$disabled{tests} -}]
|
|||||||
INCLUDE[serpenttest]=../include
|
INCLUDE[serpenttest]=../include
|
||||||
DEPEND[serpenttest]=../libcrypto
|
DEPEND[serpenttest]=../libcrypto
|
||||||
|
|
||||||
|
SOURCE[specktest]=specktest.c
|
||||||
|
INCLUDE[specktest]=../include
|
||||||
|
DEPEND[specktest]=../libcrypto
|
||||||
|
|
||||||
IF[{- !$disabled{shared} -}]
|
IF[{- !$disabled{shared} -}]
|
||||||
PROGRAMS_NO_INST=shlibloadtest
|
PROGRAMS_NO_INST=shlibloadtest
|
||||||
SOURCE[shlibloadtest]=shlibloadtest.c
|
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");
|
||||||
@@ -1,7 +1,22 @@
|
|||||||
#include"speck.h"
|
#include <stdio.h>
|
||||||
|
#include <string.h>
|
||||||
|
#include <stdlib.h>
|
||||||
|
|
||||||
|
#include "../e_os.h"
|
||||||
|
|
||||||
|
#ifdef OPENSSL_NO_SPECK
|
||||||
int main(int argc, char **argv)
|
int main(int argc, char **argv)
|
||||||
{
|
{
|
||||||
mycipher_key_t key;
|
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 userkey[2] = { 0x01, 0x02, };
|
||||||
unsigned char msg[2] = { 0xab, 0xcd, };
|
unsigned char msg[2] = { 0xab, 0xcd, };
|
||||||
SPECK_TYPE S[SPECK_ROUNDS];
|
SPECK_TYPE S[SPECK_ROUNDS];
|
||||||
@@ -9,7 +24,7 @@ int main(int argc, char **argv)
|
|||||||
unsigned char cbuf[2];
|
unsigned char cbuf[2];
|
||||||
unsigned char mbuf[2];
|
unsigned char mbuf[2];
|
||||||
|
|
||||||
mycipher_set_encrypt_key(&key, userkey);
|
speck_set_encrypt_key(&key, userkey);
|
||||||
speck_expand(&key, S);
|
speck_expand(&key, S);
|
||||||
speck_encrypt(msg, cbuf, S);
|
speck_encrypt(msg, cbuf, S);
|
||||||
speck_decrypt(cbuf, mbuf, S);
|
speck_decrypt(cbuf, mbuf, S);
|
||||||
@@ -20,3 +35,4 @@ int main(int argc, char **argv)
|
|||||||
|
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
#endif
|
||||||
Reference in New Issue
Block a user