亚洲欧美第一页_禁久久精品乱码_粉嫩av一区二区三区免费野_久草精品视频

? 歡迎來到蟲蟲下載站! | ?? 資源下載 ?? 資源專輯 ?? 關于我們
? 蟲蟲下載站

?? aes_cbc.c

?? 很好用的安全RTP開源庫
?? C
字號:
/* * aes_cbc.c * * AES Cipher Block Chaining Mode * * David A. McGrew * Cisco Systems, Inc. *//* *	 * Copyright (c) 2001-2005, Cisco Systems, Inc. * All rights reserved. *  * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions * are met: *  *   Redistributions of source code must retain the above copyright *   notice, this list of conditions and the following disclaimer. *  *   Redistributions in binary form must reproduce the above *   copyright notice, this list of conditions and the following *   disclaimer in the documentation and/or other materials provided *   with the distribution. *  *   Neither the name of the Cisco Systems, Inc. nor the names of its *   contributors may be used to endorse or promote products derived *   from this software without specific prior written permission. *  * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS * FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE * COPYRIGHT HOLDERS OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, * INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, * STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED * OF THE POSSIBILITY OF SUCH DAMAGE. * */#include "aes_cbc.h"#include "alloc.h"debug_module_t mod_aes_cbc = {  0,                 /* debugging is off by default */  "aes cbc"          /* printable module name       */};err_status_taes_cbc_alloc(cipher_t **c, int key_len) {  extern cipher_type_t aes_cbc;  uint8_t *pointer;  int tmp;  debug_print(mod_aes_cbc, 	      "allocating cipher with key length %d", key_len);  if (key_len != 16)    return err_status_bad_param;    /* allocate memory a cipher of type aes_icm */  tmp = (sizeof(aes_cbc_ctx_t) + sizeof(cipher_t));  pointer = crypto_alloc(tmp);  if (pointer == NULL)     return err_status_alloc_fail;  /* set pointers */  *c = (cipher_t *)pointer;  (*c)->type = &aes_cbc;  (*c)->state = pointer + sizeof(cipher_t);  /* increment ref_count */  aes_cbc.ref_count++;  /* set key size        */  (*c)->key_len = key_len;  return err_status_ok;  }err_status_taes_cbc_dealloc(cipher_t *c) {  extern cipher_type_t aes_cbc;  /* zeroize entire state*/  octet_string_set_to_zero((uint8_t *)c, 			   sizeof(aes_cbc_ctx_t) + sizeof(cipher_t));  /* free memory */  crypto_free(c);  /* decrement ref_count */  aes_cbc.ref_count--;    return err_status_ok;  }err_status_taes_cbc_context_init(aes_cbc_ctx_t *c, const uint8_t *key, 		     cipher_direction_t dir) {  v128_t tmp_key;  /* set tmp_key (for alignment) */  v128_copy_octet_string(&tmp_key, key);  debug_print(mod_aes_cbc, 	      "key:  %s", v128_hex_string(&tmp_key));   /* expand key for the appropriate direction */  switch (dir) {  case (direction_encrypt):    aes_expand_encryption_key(&tmp_key, c->expanded_key);    break;  case (direction_decrypt):    aes_expand_decryption_key(&tmp_key, c->expanded_key);    break;  default:    return err_status_bad_param;  }  return err_status_ok;}err_status_taes_cbc_set_iv(aes_cbc_ctx_t *c, void *iv) {  int i;/*   v128_t *input = iv; */  uint8_t *input = iv;   /* set state and 'previous' block to iv */  for (i=0; i < 16; i++)     c->previous.v8[i] = c->state.v8[i] = input[i];  debug_print(mod_aes_cbc, "setting iv: %s", v128_hex_string(&c->state));   return err_status_ok;}err_status_taes_cbc_encrypt(aes_cbc_ctx_t *c,		unsigned char *data, 		unsigned int *bytes_in_data) {  int i;  unsigned char *input  = data;   /* pointer to data being read    */  unsigned char *output = data;   /* pointer to data being written */  int bytes_to_encr = *bytes_in_data;  /*   * verify that we're 16-octet aligned   */  if (*bytes_in_data & 0xf)     return err_status_bad_param;  /*   * note that we assume that the initialization vector has already   * been set, e.g. by calling aes_cbc_set_iv()   */  debug_print(mod_aes_cbc, "iv: %s", 	      v128_hex_string(&c->state));    /*   * loop over plaintext blocks, exoring state into plaintext then   * encrypting and writing to output   */  while (bytes_to_encr > 0) {        /* exor plaintext into state */    for (i=0; i < 16; i++)      c->state.v8[i] ^= *input++;    debug_print(mod_aes_cbc, "inblock:  %s", 	      v128_hex_string(&c->state));    aes_encrypt(&c->state, c->expanded_key);    debug_print(mod_aes_cbc, "outblock: %s", 	      v128_hex_string(&c->state));    /* copy ciphertext to output */    for (i=0; i < 16; i++)      *output++ = c->state.v8[i];    bytes_to_encr -= 16;  }  return err_status_ok;}err_status_taes_cbc_decrypt(aes_cbc_ctx_t *c,		unsigned char *data, 		unsigned int *bytes_in_data) {  int i;  v128_t state, previous;  unsigned char *input  = data;   /* pointer to data being read    */  unsigned char *output = data;   /* pointer to data being written */  int bytes_to_encr = *bytes_in_data;  uint8_t tmp;  /*   * verify that we're 16-octet aligned   */  if (*bytes_in_data & 0x0f)    return err_status_bad_param;      /* set 'previous' block to iv*/  for (i=0; i < 16; i++) {    previous.v8[i] = c->previous.v8[i];  }  debug_print(mod_aes_cbc, "iv: %s", 	      v128_hex_string(&previous));    /*   * loop over ciphertext blocks, decrypting then exoring with state   * then writing plaintext to output   */  while (bytes_to_encr > 0) {        /* set state to ciphertext input block */    for (i=0; i < 16; i++) {     state.v8[i] = *input++;    }    debug_print(mod_aes_cbc, "inblock:  %s", 	      v128_hex_string(&state));        /* decrypt state */    aes_decrypt(&state, c->expanded_key);    debug_print(mod_aes_cbc, "outblock: %s", 	      v128_hex_string(&state));    /*      * exor previous ciphertext block out of plaintext, and write new     * plaintext block to output, while copying old ciphertext block     * to the 'previous' block     */    for (i=0; i < 16; i++) {      tmp = *output;      *output++ = state.v8[i] ^ previous.v8[i];      previous.v8[i] = tmp;    }    bytes_to_encr -= 16;  }  return err_status_ok;}err_status_taes_cbc_nist_encrypt(aes_cbc_ctx_t *c,		     unsigned char *data, 		     unsigned int *bytes_in_data) {  int i;  unsigned char *pad_start;   int num_pad_bytes;  err_status_t status;  /*    * determine the number of padding bytes that we need to add -    * this value is always between 1 and 16, inclusive.   */  num_pad_bytes = 16 - (*bytes_in_data & 0xf);  pad_start = data;  pad_start += *bytes_in_data;  *pad_start++ = 0xa0;  for (i=0; i < num_pad_bytes; i++)     *pad_start++ = 0x00;     /*    * increment the data size    */  *bytes_in_data += num_pad_bytes;    /*   * now cbc encrypt the padded data    */  status = aes_cbc_encrypt(c, data, bytes_in_data);  if (status)     return status;  return err_status_ok;}err_status_taes_cbc_nist_decrypt(aes_cbc_ctx_t *c,		     unsigned char *data, 		     unsigned int *bytes_in_data) {  unsigned char *pad_end;  int num_pad_bytes;  err_status_t status;  /*   * cbc decrypt the padded data    */  status = aes_cbc_decrypt(c, data, bytes_in_data);  if (status)     return status;  /*   * determine the number of padding bytes in the decrypted plaintext   * - this value is always between 1 and 16, inclusive.   */  num_pad_bytes = 1;  pad_end = data + (*bytes_in_data - 1);  while (*pad_end != 0xa0) {   /* note: should check padding correctness */    pad_end--;    num_pad_bytes++;  }    /* decrement data size */  *bytes_in_data -= num_pad_bytes;    return err_status_ok;}char aes_cbc_description[] = "aes cipher block chaining (cbc) mode";/* * Test case 0 is derived from FIPS 197 Appendix A; it uses an * all-zero IV, so that the first block encryption matches the test * case in that appendix.  This property provides a check of the base * AES encryption and decryption algorithms; if CBC fails on some * particular platform, then you should print out AES intermediate * data and compare with the detailed info provided in that appendix. * */uint8_t aes_cbc_test_case_0_key[16] = {  0x00, 0x01, 0x02, 0x03, 0x04, 0x05, 0x06, 0x07,   0x08, 0x09, 0x0a, 0x0b, 0x0c, 0x0d, 0x0e, 0x0f};uint8_t aes_cbc_test_case_0_plaintext[64] =  {  0x00, 0x11, 0x22, 0x33, 0x44, 0x55, 0x66, 0x77,  0x88, 0x99, 0xaa, 0xbb, 0xcc, 0xdd, 0xee, 0xff };uint8_t aes_cbc_test_case_0_ciphertext[80] = {  0x69, 0xc4, 0xe0, 0xd8, 0x6a, 0x7b, 0x04, 0x30,   0xd8, 0xcd, 0xb7, 0x80, 0x70, 0xb4, 0xc5, 0x5a,  0x03, 0x35, 0xed, 0x27, 0x67, 0xf2, 0x6d, 0xf1,   0x64, 0x83, 0x2e, 0x23, 0x44, 0x38, 0x70, 0x8b};uint8_t aes_cbc_test_case_0_iv[16] = {  0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,   0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00};cipher_test_case_t aes_cbc_test_case_0 = {  16,                                    /* octets in key            */  aes_cbc_test_case_0_key,               /* key                      */  aes_cbc_test_case_0_iv,                /* initialization vector    */  16,                                    /* octets in plaintext      */  aes_cbc_test_case_0_plaintext,         /* plaintext                */  32,                                    /* octets in ciphertext     */  aes_cbc_test_case_0_ciphertext,        /* ciphertext               */  NULL                                   /* pointer to next testcase */};/* * this test case is taken directly from Appendix F.2 of NIST Special * Publication SP 800-38A */uint8_t aes_cbc_test_case_1_key[16] = {  0x2b, 0x7e, 0x15, 0x16, 0x28, 0xae, 0xd2, 0xa6,  0xab, 0xf7, 0x15, 0x88, 0x09, 0xcf, 0x4f, 0x3c,};uint8_t aes_cbc_test_case_1_plaintext[64] =  {  0x6b, 0xc1, 0xbe, 0xe2, 0x2e, 0x40, 0x9f, 0x96,   0xe9, 0x3d, 0x7e, 0x11, 0x73, 0x93, 0x17, 0x2a,  0xae, 0x2d, 0x8a, 0x57, 0x1e, 0x03, 0xac, 0x9c,   0x9e, 0xb7, 0x6f, 0xac, 0x45, 0xaf, 0x8e, 0x51,  0x30, 0xc8, 0x1c, 0x46, 0xa3, 0x5c, 0xe4, 0x11,  0xe5, 0xfb, 0xc1, 0x19, 0x1a, 0x0a, 0x52, 0xef,  0xf6, 0x9f, 0x24, 0x45, 0xdf, 0x4f, 0x9b, 0x17,   0xad, 0x2b, 0x41, 0x7b, 0xe6, 0x6c, 0x37, 0x10};uint8_t aes_cbc_test_case_1_ciphertext[80] = {  0x76, 0x49, 0xab, 0xac, 0x81, 0x19, 0xb2, 0x46,  0xce, 0xe9, 0x8e, 0x9b, 0x12, 0xe9, 0x19, 0x7d,  0x50, 0x86, 0xcb, 0x9b, 0x50, 0x72, 0x19, 0xee,  0x95, 0xdb, 0x11, 0x3a, 0x91, 0x76, 0x78, 0xb2,  0x73, 0xbe, 0xd6, 0xb8, 0xe3, 0xc1, 0x74, 0x3b,  0x71, 0x16, 0xe6, 0x9e, 0x22, 0x22, 0x95, 0x16,   0x3f, 0xf1, 0xca, 0xa1, 0x68, 0x1f, 0xac, 0x09,   0x12, 0x0e, 0xca, 0x30, 0x75, 0x86, 0xe1, 0xa7,  0x39, 0x34, 0x07, 0x03, 0x36, 0xd0, 0x77, 0x99,   0xe0, 0xc4, 0x2f, 0xdd, 0xa8, 0xdf, 0x4c, 0xa3};uint8_t aes_cbc_test_case_1_iv[16] = {  0x00, 0x01, 0x02, 0x03, 0x04, 0x05, 0x06, 0x07,   0x08, 0x09, 0x0a, 0x0b, 0x0c, 0x0d, 0x0e, 0x0f};cipher_test_case_t aes_cbc_test_case_1 = {  16,                                    /* octets in key            */  aes_cbc_test_case_1_key,               /* key                      */  aes_cbc_test_case_1_iv,                /* initialization vector    */  64,                                    /* octets in plaintext      */  aes_cbc_test_case_1_plaintext,         /* plaintext                */  80,                                    /* octets in ciphertext     */  aes_cbc_test_case_1_ciphertext,        /* ciphertext               */  &aes_cbc_test_case_0                    /* pointer to next testcase */};cipher_type_t aes_cbc = {  (cipher_alloc_func_t)          aes_cbc_alloc,  (cipher_dealloc_func_t)        aes_cbc_dealloc,    (cipher_init_func_t)           aes_cbc_context_init,  (cipher_encrypt_func_t)        aes_cbc_nist_encrypt,  (cipher_decrypt_func_t)        aes_cbc_nist_decrypt,  (cipher_set_iv_func_t)         aes_cbc_set_iv,  (char *)                       aes_cbc_description,  (int)                          0,   /* instance count */  (cipher_test_case_t *)        &aes_cbc_test_case_0,  (debug_module_t *)            &mod_aes_cbc};

?? 快捷鍵說明

復制代碼 Ctrl + C
搜索代碼 Ctrl + F
全屏模式 F11
切換主題 Ctrl + Shift + D
顯示快捷鍵 ?
增大字號 Ctrl + =
減小字號 Ctrl + -
亚洲欧美第一页_禁久久精品乱码_粉嫩av一区二区三区免费野_久草精品视频
国产精品欧美一级免费| 婷婷中文字幕综合| 一区二区三区久久| 久久精品99国产国产精| 成人动漫一区二区| 精品播放一区二区| 亚洲一区二区欧美日韩| 成人av在线影院| 精品美女在线观看| 亚洲图片欧美色图| 99riav久久精品riav| 久久亚洲影视婷婷| 免费久久99精品国产| 欧美亚洲禁片免费| 中文字幕中文在线不卡住| 黄页网站大全一区二区| 欧美日本一区二区三区四区| 国产精品久久久久久久久图文区| 韩国成人精品a∨在线观看| 欧美日韩激情在线| 中文字幕在线一区| 丁香激情综合国产| 久久久久国产精品厨房| 久久精品噜噜噜成人88aⅴ| 日本韩国欧美一区二区三区| 国产欧美日韩一区二区三区在线观看 | 久久嫩草精品久久久精品| 亚洲国产综合视频在线观看| 97久久精品人人做人人爽| 国产精品毛片久久久久久| 成人激情小说网站| 久久精品亚洲一区二区三区浴池| 久久成人免费电影| 日韩一区二区三区精品视频| 日本一区中文字幕| 日韩欧美国产电影| 激情综合色丁香一区二区| 欧美电影免费观看高清完整版在线观看| 亚洲一区二区视频| 69堂精品视频| 日本成人在线看| 日韩一区二区视频| 国模一区二区三区白浆| 久久免费电影网| 国产成人av资源| 中文字幕在线不卡一区二区三区| 92国产精品观看| 亚洲成人动漫在线免费观看| 欧美日韩国产a| 美国欧美日韩国产在线播放| 精品国产凹凸成av人导航| 国产麻豆91精品| 国产精品久久久久aaaa樱花| 成人手机在线视频| 一区二区三区小说| 欧美另类z0zxhd电影| 美女视频黄a大片欧美| 久久久久久久电影| 91在线高清观看| 亚洲午夜电影在线| 日韩精品中文字幕一区二区三区 | 狠狠色丁香婷婷综合| 日韩一区二区电影网| 国产电影一区在线| 一区二区成人在线| 日韩一二三四区| 成人av网站在线| 亚洲成人黄色影院| 欧美激情自拍偷拍| 欧美日本一区二区| 大陆成人av片| 日本成人中文字幕| 国产精品福利在线播放| 91精品国产综合久久婷婷香蕉 | 国产亚洲欧美日韩在线一区| 91浏览器打开| 精品一区二区三区免费毛片爱| 欧美—级在线免费片| 欧美日韩久久久一区| 国产成人精品亚洲777人妖| 一区二区成人在线视频 | 激情久久五月天| 一区二区三区四区高清精品免费观看| 精品捆绑美女sm三区| 91老司机福利 在线| 国产精品123| 免费在线观看一区| 亚洲夂夂婷婷色拍ww47| 欧美激情综合在线| 欧美成人精精品一区二区频| 在线观看不卡一区| 不卡电影免费在线播放一区| 久久99精品一区二区三区三区| 亚洲天堂福利av| 中文字幕不卡在线播放| 日韩一区二区视频| 欧美日本视频在线| 欧美色涩在线第一页| 不卡视频免费播放| 成人午夜在线播放| 国产自产v一区二区三区c| 午夜久久久久久| 亚洲国产成人va在线观看天堂| 国产精品乱码久久久久久| 久久综合九色综合97_久久久| 欧美丰满美乳xxx高潮www| 色噜噜狠狠成人中文综合| 91丝袜高跟美女视频| 菠萝蜜视频在线观看一区| 国产高清精品在线| 国产一区二区影院| 国产一区二区三区蝌蚪| 国产精品正在播放| 国产在线一区观看| 极品尤物av久久免费看| 激情文学综合网| 国产一区二区三区免费在线观看| 另类小说图片综合网| 日本欧美一区二区三区| 免费成人在线播放| 激情文学综合网| 国产福利一区二区三区在线视频| 国产一区视频导航| 成人网在线免费视频| 福利一区在线观看| 色综合天天综合网天天看片| 91同城在线观看| 欧美日韩激情一区二区| 欧美一区二区精品| 精品国产免费一区二区三区四区 | 国产精品影视天天线| 国产成人在线色| 97久久精品人人澡人人爽| 99精品欧美一区| 欧美午夜一区二区三区| 精品视频免费看| 精品国产三级电影在线观看| 日本一区二区三区久久久久久久久不| 国产精品每日更新| 亚洲va欧美va人人爽| 激情综合一区二区三区| 成人aa视频在线观看| 欧美视频一区在线观看| 91精品国产91久久久久久一区二区 | 91高清在线观看| 日韩一区二区三区精品视频| 国产亚洲欧美日韩日本| 亚洲码国产岛国毛片在线| 视频一区二区三区在线| 国产又粗又猛又爽又黄91精品| 99久久777色| 日韩视频国产视频| 1024国产精品| 奇米影视一区二区三区| 不卡av在线网| 91精品国产91久久久久久一区二区| 国产日韩av一区二区| 亚洲国产精品尤物yw在线观看| 国产美女久久久久| 欧美视频完全免费看| 久久久亚洲午夜电影| 亚洲国产精品一区二区www在线| 韩国欧美一区二区| 欧美日韩国产不卡| 国产精品女同一区二区三区| 午夜成人在线视频| 成人久久视频在线观看| 精品日韩99亚洲| 一区二区在线观看视频在线观看| 麻豆成人免费电影| 欧美无砖专区一中文字| 中文一区在线播放| 精品一区二区三区在线视频| 日本韩国一区二区三区| 欧美激情综合五月色丁香| 日本v片在线高清不卡在线观看| 99精品欧美一区二区蜜桃免费| 久久综合一区二区| 风间由美一区二区三区在线观看 | 国产91丝袜在线18| 欧美一区二区三区四区五区| 一区二区三区不卡在线观看| 国产精品伊人色| 欧美一级在线免费| 一区二区三区四区在线| 99re6这里只有精品视频在线观看| 精品乱人伦一区二区三区| 日本不卡一区二区| 欧美人牲a欧美精品| 亚洲精品日韩专区silk| 91美女在线观看| 欧美激情自拍偷拍| 成人午夜视频福利| 久久久99精品久久| 紧缚奴在线一区二区三区| 日韩女优视频免费观看| 久久精品国产99久久6| 日韩欧美中文一区| 免费精品视频在线| 精品国精品国产|