2019-12-04 06:17:31 +08:00
|
|
|
/****************************************************************************
|
|
|
|
* tools/cxd56/clefia.h
|
|
|
|
*
|
2021-08-26 18:47:21 +08:00
|
|
|
* Licensed to the Apache Software Foundation (ASF) under one or more
|
|
|
|
* contributor license agreements. See the NOTICE file distributed with
|
|
|
|
* this work for additional information regarding copyright ownership. The
|
|
|
|
* ASF licenses this file to you under the Apache License, Version 2.0 (the
|
|
|
|
* "License"); you may not use this file except in compliance with the
|
|
|
|
* License. You may obtain a copy of the License at
|
2019-12-04 06:17:31 +08:00
|
|
|
*
|
2021-08-26 18:47:21 +08:00
|
|
|
* http://www.apache.org/licenses/LICENSE-2.0
|
2019-12-04 06:17:31 +08:00
|
|
|
*
|
2021-08-26 18:47:21 +08:00
|
|
|
* Unless required by applicable law or agreed to in writing, software
|
|
|
|
* distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
|
|
|
|
* WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
|
|
|
|
* License for the specific language governing permissions and limitations
|
|
|
|
* under the License.
|
2019-12-04 06:17:31 +08:00
|
|
|
*
|
2020-06-29 15:17:23 +08:00
|
|
|
****************************************************************************/
|
2019-12-04 06:17:31 +08:00
|
|
|
|
2019-12-04 06:46:12 +08:00
|
|
|
#ifndef _TOOLS_CXD56_CLEFIA_H_
|
|
|
|
#define _TOOLS_CXD56_CLEFIA_H_
|
|
|
|
|
|
|
|
/****************************************************************************
|
|
|
|
* Public Types
|
|
|
|
****************************************************************************/
|
2019-12-04 06:17:31 +08:00
|
|
|
|
|
|
|
struct cipher
|
|
|
|
{
|
|
|
|
int mode;
|
|
|
|
int dir;
|
|
|
|
uint8_t rk[8 * 26 + 16];
|
|
|
|
uint8_t vector[16];
|
|
|
|
int round;
|
2019-12-04 06:46:12 +08:00
|
|
|
uint8_t k1[16];
|
|
|
|
uint8_t k2[16];
|
2019-12-04 06:17:31 +08:00
|
|
|
};
|
|
|
|
|
2019-12-04 06:46:12 +08:00
|
|
|
/****************************************************************************
|
|
|
|
* Public Function Prototypes
|
|
|
|
****************************************************************************/
|
|
|
|
|
2019-12-04 06:17:31 +08:00
|
|
|
struct cipher *cipher_init(uint8_t * key, uint8_t * iv);
|
|
|
|
void cipher_deinit(struct cipher *c);
|
|
|
|
int cipher_calc_cmac(struct cipher *c, void *data, int size, void *cmac);
|
|
|
|
void bytexor(unsigned char *dst, const unsigned char *a,
|
|
|
|
const unsigned char *b, int bytelen);
|
|
|
|
int clefiakeyset(unsigned char *rk, const unsigned char *skey);
|
|
|
|
void clefiaencrypt(unsigned char *ct, const unsigned char *pt,
|
|
|
|
const unsigned char *rk, const int r);
|
|
|
|
|
|
|
|
#endif
|