91av视频/亚洲h视频/操亚洲美女/外国一级黄色毛片 - 国产三级三级三级三级

  • 大小: 23KB
    文件類型: .gz
    金幣: 1
    下載: 1 次
    發布日期: 2021-06-17
  • 語言: C/C++
  • 標簽: C語??AE??linu??

資源簡介

AES 算法C語言實現(linux), 可直接編譯運行. 可自由移植到其他平臺

資源截圖

代碼片段和文件信息

/*
?*??FIPS-197?compliant?AES?implementation
?*
?*??Copyright?(C)?2006-2015?ARM?Limited?All?Rights?Reserved
?*??SPDX-License-Identifier:?Apache-2.0
?*
?*??Licensed?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
?*
?*??http://www.apache.org/licenses/LICENSE-2.0
?*
?*??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.
?*
?*??This?file?is?part?of?mbed?TLS?(https://tls.mbed.org)
?*/
/*
?*??The?AES?block?cipher?was?designed?by?Vincent?Rijmen?and?Joan?Daemen.
?*
?*??http://csrc.nist.gov/encryption/aes/rijndael/Rijndael.pdf
?*??http://csrc.nist.gov/publications/fips/fips197/fips-197.pdf
?*/

#if?!defined(MBEDTLS_CONFIG_FILE)
//#include?“config.h“
#else
#include?MBEDTLS_CONFIG_FILE
#endif

#include?
#include?
#include?

#include?“aes.h“

#if?!defined(MBEDTLS_AES_ALT)

/*?Implementation?that?should?never?be?optimized?out?by?the?compiler?*/
static?void?mbedtls_zeroize(?void?*v?size_t?n?)?{
????volatile?unsigned?char?*p?=?(unsigned?char*)v;?while(?n--?)?*p++?=?0;
}

/*?Add?base64?and?padding?By?zhanggf?start?1?*/
#ifndef?base64
static?const?char?*ALPHA_base?=?“ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/“;

unsigned?char*?str2hex(char?*str)?{
????unsigned?char?*ret?=?NULL;
????int?str_len?=?strlen(str);
????int?i?=?0;

????ret?=?(char?*)malloc(str_len/2);
memset(ret?0?str_len/2);
????for?(i?=0;i?????????sscanf(str+i“%2hhx“&ret[i/2]);
????}
????return?ret;
}

int?AES_padding7_buf(char?*pszBufint?iSize?char?*pszOutbuf?int?iOutbufLen)?{
int??iFinalSize?=?-1;
????int?pidding_size?=?AES_BLOCK_SIZE?-?(iSize?%?AES_BLOCK_SIZE);
????int?i;
?
if?(iOutbufLen?==?0)?{
return?iFinalSize;
}

????iFinalSize?=?iSize?+?pidding_size;
memset(pszOutbuf?0?iOutbufLen);
????memcpy(pszOutbuf?pszBuf?iSize);
????if?(pidding_size!=0)?{
????????for?(i?=?iSize;i?????????????pszOutbuf[i]?=?pidding_size;
????????}
????}

????return?iFinalSize;
}

int?AES_padding0_buf(char?*pszBufint?iSize?char?*pszOutbuf?int?iOutbufLen)?{
int??iFinalSize?=?-1;
????int?pidding_size?=?AES_BLOCK_SIZE?-?(iSize?%?AES_BLOCK_SIZE);
????int?i;
?
if?(iOutbufLen?==?0)?{
return?iFinalSize;
}

????iFinalSize?=?iSize?+?pidding_size;
memset(pszOutbuf?0?iOutbufLen);
????memcpy(pszOutbuf?pszBuf?iSize);
????if?(pidding_size!=0)?{
????????for?(i?=?iSize;i?????????????pszOutbuf[i]?=?0;
????????}
????}

????return?iFinalSize;
}
?
void?AES_printf_hex(char?*pszBuf?int?iBufLen)
{
int?iLoop?=?0;

for?(;?iLoop? printf(“%02x“?(unsigned?char)ps

評論

共有 條評論