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

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

?? sps_dve.c

?? LINUX AU12XX BOOTLADER
?? C
字號:
/** * @file sps_dve.c * SPS module for decryption and signature verfication *  (dve = decryption and verification engine :-) * * @version $Revision$ $State$ * * @date @(#) Sep 30 2004, 21:24:01 * * @author Reinhard Wobst * *****************************************************************************//* * Copyright 2002 ADVANCED MICRO DEVICES, INC. All Rights Reserved. * * This software and any related documentation (the "Materials") are the * confidential proprietary information of AMD. Unless otherwise provided * in an agreement specifically licensing the Materials, the Materials are * provided in confidence and may not to be used, distributed, modified, or * reproduced in whole or in part by any means. * * LIMITATION OF LIABILITY: THE MATERIALS ARE PROVIDED "AS IS" WITHOUT ANY * EXPRESS OR IMPLIED WARRANTY OF ANY KIND, INCLUDING BUT NOT LIMITED TO * WARRANTIES OF MERCHANTABILITY, NONINFRINGEMENT, TITLE, FITNESS FOR ANY * PARTICULAR PURPOSE, OR WARRANTIES ARISING FORM CONDUCT, COURSE OF * DEALING, OR USAGE OF TRADE.  IN NO EVENT SHALL AMD OR ITS LICENSORS BE * LIABLE FOR ANY DAMAGES WHATSOEVER (INCLUDING, WITHOUT LIMITATION, * DAMAGES FOR LOSS OF PROFITS, BUSINESS INTERRUPTION, OR LOSS OF * INFORMATION) ARISING OUT OF THE USE OF OR INABILITY TO USE THE * MATERIALS, EVEN IF AMD HAS BEEN ADVISED OF THE POSSIBILITY OF SUCH * DAMAGES.  BECAUSE SOME JURISDICTIONS PROHIBIT THE EXCLUSION OR * LIMITATION OF LIABILITY FOR CONSEQUENTIAL OR INCIDENTAL DAMAGES, THE * ABOVE LIMITATION MAY NOT APPLY TO YOU. * * AMD does not assume any responsibility for any errors which may appear * in the Materials nor any responsibility to support or update the * Materials.  AMD retains the right to modify the Materials at any time, * without notice, and is not obligated to provide such modified Materials * to you. * * NO SUPPORT OBLIGATION: AMD is not obligated to furnish, support, or make * any further information, software, technical information, know-how, or * show-how available to you. * *//******************************************************************************  Defines and includes*****************************************************************************/#include "sec.h"#include "debug.h"/* standard interfaces */#include <string.h>#include <stdlib.h>#include <stdio.h>#if STANDALONE == 0    /* Firmware interfaces */#include "sec.h"#include "ssfif.h"#endif#include "conf.h"#include "dve_api.h"#include "modules.h"#include "debug.h"#ifdef MSDOS#include "bn.h"#include "aes_api.h"#include "sha1.h"#else#include "Bn/bn.h"#include "Aes/aes_api.h"#include "Sha/sha1.h"#endif/******************************************************************************  Data*****************************************************************************/static struct MY_WORKSPACE *wsp;static int key_select[NUMSIG];static int my_first;/******************************************************************************  local function declarations*****************************************************************************/static void dve_sigstore(unsigned char *header);static unsigned char *sps_compose(const unsigned char part[16]);/******************************************************************************  global interface*****************************************************************************//** * @brief       initialize symmetric decryption/verification * * allocate SHA context, decrypt session key, set IV, compute round keys, * set my_first to 1 (used in dve_process()) * * @param iv        initialization vector of length MY_BLOCKSIZE/8 * @param cipertext at least MY_HEADSIZE bytes of ciphertext - see *          conf.h (not checked!) * @param workspace pointer to workspace structure */void dve_init(unsigned char *ciphertext,	      unsigned char *iv, struct MY_WORKSPACE *workspace){    unsigned char lociv[MY_KEYSIZE / 8], start;    static unsigned char fixedkey[MY_KEYSIZE / 8];    const static unsigned char const_part[16] = {	'w', 'h', 'i', 't',	'e', 'h', 'o', 'r',	's', 'e', 'e', 'd',	'u', 'c', 'a', 't',    };    int n, alt;    DP0(("*** Initialization"));    my_first = 1;    wsp = workspace;    memcpy(workspace->AesOfbDecryptIv, iv, MY_BLOCKSIZE / 8);    /* initialize NUMSIG SHA1 instances and diversify them */    for (n = NUMSIG; n--;) {	SHA1Init(wsp->sha1_ctx + n);	start = n & 0xff;	SHA1Update(wsp->sha1_ctx + n, &start, 1);    }    /* initialize symmetric OFB decryption */    for (alt = 0, n = MY_KEYSIZE / 8; n--;)	alt |= iv[n];    if (!alt)	for (n = MY_KEYSIZE / 8; n--;)	    fixedkey[n] = n & 0xff;    memcpy(lociv, iv, sizeof(lociv));    /* initialise AES module with IV to decrypt Session Key */    decrypt_aes_init(alt ? sps_compose(const_part) : fixedkey, lociv,		     &(wsp->Rkeys));    /* decrypt SK from ESK */    decrypt_aes_ofb(ciphertext, MY_KEYSIZE / 8);#if SPS_VERBOSE == 1    DP0(("master key: "));    for (n = 0; n < MY_KEYSIZE / 8; ++n)	DP0(("%02x", (alt ? sps_compose(const_part) : fixedkey)[n]));    DP0(("\n"));    DP0(("session key: "));    for (n = 0; n < MY_KEYSIZE / 8; ++n)	DP0(("%02x", ciphertext[n]));    DP0(("\n"));#endif    /* reinitialise AES module with SK for further decryption operations */    decrypt_aes_init(ciphertext, workspace->AesOfbDecryptIv,		     &(wsp->Rkeys));}/* ------------------------------------------------------------------ *//** * @brief routine which decrypts a data field encrypted with AES_128_OFB * * On first call (recognized by non-zero value of file-global variable * my_first), NUMSIG signatures and the following byte (for public key * selection) are read and stored after decryption. They are returned, * you have to skip them "by hand"! (the offset is MY_HEADSIZE) * * Hash computation is done background. * * @param cipherplaintext   [in,out] ciphertext buffer, will be *                   overwritten with plaintext * @param len           [in ]    # of bytes for in and output * * @return *      MY_PARMERR  len < MY_HEADSIZE on first call, *              len <= 0 on some following call *      number of decrypted bytes else * */int dve_process(unsigned char *cipherplaintext, int len,		SpsIntegrCheckMode_t IntCheckMode){    int m, n, ret;    DP0(("dve_process: %d bytes to decrypt", len));    /* store signatures and compute keyselect field */    if (my_first) {	if (len < MY_HEADSIZE)	    return MY_PARMERR;	my_first = 0;	/* for snowmass secure boot the signatures will not be encrypted! */	if (IntCheckMode == SPS_ENCRYPT_SIGNED) {	    decrypt_aes_ofb(cipherplaintext + MY_SIGOFF, len - MY_SIGOFF);	}	/* we check, if the three alignment bytes are 0, as expected.	 * if not - we have a decrypt error	 */	m = cipherplaintext[MY_HEADSIZE - 3];	m += cipherplaintext[MY_HEADSIZE - 2];	m += cipherplaintext[MY_HEADSIZE - 1];	if (m != 0) {	    DP0(("dve_process: decrypt error %02x\n", m));	    return MY_PARMERR;	}	/* store signatures and key select info in workspace */	/* starts @ session key offset */	dve_sigstore(cipherplaintext + MY_SIGOFF);	/* for including key_sel in hash adapt following calculations as to leave key_sel for SHA1Update below... */	/* replace all MY_HEADSIZE with (MY_HEADSIZE-(sizeof(key_sel) + sizeof(align))) */	cipherplaintext += MY_HEADSIZE;	len -= MY_HEADSIZE;	/* set len to zero to avoid SHA1 processing below.... */    } else {	if (len <= 0)	    return MY_PARMERR;	/* for snowmass secure boot first hash then decrypt! */	if (IntCheckMode == SPS_ENCRYPT_SIGNED) {	    decrypt_aes_ofb(cipherplaintext, len);	}    }    ret = len;    /* the included SHA1 implementation destroys the buffer, so we have     * to copy it and hash in portions     */    /* this will not fire for the PatchInfo field as len is asigned zero above... */    while (len > 0) {	n = sizeof(wsp->scratchbuf);	if (len < sizeof(wsp->scratchbuf))	    n = len;	for (m = NUMSIG; m--;) {	    memcpy(wsp->scratchbuf, cipherplaintext, n);	    SHA1Update(wsp->sha1_ctx + m, wsp->scratchbuf, n);	}	/* for snowmass secure boot first hash then decrypt! */	/* todo mgrell: review/test this construct for different length for streaming capabilities!: */	/* in original hss AES"de"crypt was done on entire block, here we do it in scratchbuf size manner... */	if (IntCheckMode == SPS_SIGN_ENCRYPTED) {	    decrypt_aes_ofb(cipherplaintext, n);	}	cipherplaintext += n;	len -= n;    }    return ret;}/* ------------------------------------------------------------------ *//** * @brief   store NUMSIG signatures, compute key numbers * * The select byte after the signatures is used to compute the * field key_select[NUMSIG] that determines which public keys * are used for encryption (and which signatures have to be skipped; * these values of key_select[] are negative). * * Structure of the select_byte: * * Bit 0  1  2  3  4  5  6  7 *     key0  key1  key2  exclude * * The key number 0...3 of key0 selects one key among keys 0...3, * key1 selects 4...7, and key2 selects 8...11. * If the 'exclude' bits are zero, all three fields are valid. * Otherwise, for values 1...3 the key0...key2 has to be skipped, * respectively. */static void dve_sigstore(unsigned char *header){    const unsigned char mask = 03;    int n, select_byte;    select_byte = header[NUMSIG * MY_SIGSIZE / 8];    for (n = 0; n < NUMSIG; ++n, select_byte >>= 2) {	memcpy((wsp->sigbuf)[n], header + n * MY_SIGSIZE / 8,	       MY_SIGSIZE / 8);	key_select[n] = (int) (select_byte & mask) + (n << 2);    }    /* check for deactivated field */    if (select_byte &= mask)	key_select[select_byte - 1] = -1;}/* ------------------------------------------------------------------ *//** * @brief   check signatures: compute final hashes, test against sigbuf * * @return *      MY_SIGFAIL  signature failed *      MY_ERR      some internal operation failed *      MY_OK       else */int dve_sigcheck(){    unsigned char cmpsig[MY_SIGSIZE / 8 + 1];	/* maybe, "...+1" is not necessary */    unsigned char hash1[MY_HASHSIZE / 8];    int n, len, signr, keynr, ret;    BN_CTX *ctx;    BIGNUM *mod, *bnsign, *pubex;    ret = MY_OK;    mod = NULL;    bnsign = NULL;    pubex = NULL;    /* compute hash over decrypted text */    for (n = NUMSIG; n--;)	SHA1Final(wsp->Hash[n], wsp->sha1_ctx + n);#if SPS_VERBOSE == 1    {	int k;	for (k = 0; k < NUMSIG; ++k) {	    DP0(("Hash %d:", k + 1));	    for (n = 0; n < MY_HASHSIZE / 8; ++n) {		DP0(("%02x ", wsp->Hash[k][n]));		if (n % 10 == 9)		    DP0(("\n"));	    }	    DP0(("\n"));	}    }#endif    /* create bignum context */    ctx = BN_CTX_new();    if (ctx == NULL)	return MY_ERR;    /* *** check signatures */    for (signr = 0; signr < NUMSIG; ++signr) {	if ((keynr = key_select[signr]) < 0)	    continue;		/* deselected field */	/* Cannabis part: hashhash */	SHA1Init(wsp->sha1_ctx);	SHA1Update(wsp->sha1_ctx, wsp->Hash[signr], MY_HASHSIZE / 8);	SHA1Final(hash1, wsp->sha1_ctx);	bnsign = pubex = mod = NULL;	/* convert modulus */	mod = BN_bin2bn(Modulus[keynr], sizeof(Modulus[keynr]), NULL);	DP0(("modulus %d converted", keynr));	if (mod == NULL) {	    ret = MY_ERR;	    break;	}	/* convert public exponent */	pubex = BN_bin2bn(publicExponent[keynr],			  sizeof(publicExponent[keynr]), NULL);	DP0(("public exponent %d converted", keynr));	if (pubex == NULL) {	    ret = MY_ERR;	    break;	}	/* convert signature */	bnsign = BN_bin2bn((wsp->sigbuf)[signr], MY_SIGSIZE / 8, NULL);	if (bnsign == NULL) {	    ret = MY_ERR;	    break;	}	/* public encrypt */	BN_mod_exp(bnsign, bnsign, pubex, mod, ctx);	len = BN_bn2bin(bnsign, cmpsig);	if (memcmp	    (hash1, cmpsig + MY_SIGSIZE / 8 - 1 - MY_HASHSIZE / 8,	     MY_HASHSIZE / 8)) {	    ret = MY_SIGFAIL;	    break;	}	DP0(("--> signature %d verified successfully", signr));	BN_free(bnsign);	BN_free(pubex);	BN_free(mod);    }    BN_CTX_free(ctx);    if (ret != MY_OK) {	if (bnsign != NULL)	    BN_free(bnsign);	if (pubex != NULL)	    BN_free(pubex);	if (mod != NULL)	    BN_free(mod);    }    return ret;}/* ------------------------------------------------------------------ *//** * @brief   provide workspace for bignum library * * @param requ_size size of block, can be at most sizeof(BIGNUM)*32 *          where the macro TABLE_SIZE defined as 32 in *          bn/bn_exp.c is used (dirty, but with least *          code modification) */BIGNUM *sps_dve_get_valbuf(int requ_size){    if (requ_size <= sizeof(BIGNUM) * 32) {	return &(wsp->bn_buf[0]);    }    SsfFatalError(1);    return NULL;		/* dummy, for supressing compiler warning only */}/* ------------------------------------------------------------------ *//** * @brief   generate a 16 byte data array * * @param */unsigned char *sps_compose(const unsigned char part[16]){#ifdef PATCH_SYSTEM_WITH_TEST_KEYS#ifndef MSDOS#warning using test symmetric keys#endif    static unsigned char mykey[16] = {	0x5f, 0x44, 0x3a, 0x23,	0x5c, 0xc7, 0x5a, 0xbb,	0xdf, 0xbc, 0x97, 0xf2,	0xa9, 0xef, 0xa9, 0x51    };#else#warning using secure symmetric keys    unsigned char *p, *q;    int n;    static unsigned char mykey[16] = {	'i', 'o', 'n', 'S',	'c', 'h', 'i', 'm',	'm', 'e', 'l', 'b',	'i', 'l', 'd', 'g',    };    for (n = 16, p = &mykey[0], q = (unsigned char *) &part[0]; n--;) {	*p++ ^= *q++;    }#endif#ifdef USE_TDDFW_ENVIRONMENT    return get_key();#else    return mykey;#endif}static const unsigned char localaeskeywhichisnotsecurehere[] = {    0x5f, 0x44, 0x3a, 0x23, 0x5c, 0xc7, 0x5a, 0xbb, 0xdf, 0xbc, 0x97, 0xf2,	0xa9, 0xef, 0xa9, 0x51};unsigned char *get_key(){    return (unsigned char *) localaeskeywhichisnotsecurehere;}

?? 快捷鍵說明

復制代碼 Ctrl + C
搜索代碼 Ctrl + F
全屏模式 F11
切換主題 Ctrl + Shift + D
顯示快捷鍵 ?
增大字號 Ctrl + =
減小字號 Ctrl + -
亚洲欧美第一页_禁久久精品乱码_粉嫩av一区二区三区免费野_久草精品视频
国产精品素人视频| 日韩国产精品久久| 亚洲成人免费观看| 久久疯狂做爰流白浆xx| 99天天综合性| 精品美女在线播放| 亚洲国产精品一区二区久久| 精品无人区卡一卡二卡三乱码免费卡| 色综合天天综合网天天狠天天| 精品日韩欧美一区二区| 亚洲午夜久久久久久久久电影院| 国产成人免费9x9x人网站视频| 日韩三级视频中文字幕| 亚洲一区视频在线| 91视视频在线观看入口直接观看www | 91激情五月电影| 国产视频视频一区| 美女视频黄 久久| 欧美三级中文字| 亚洲综合色自拍一区| 91尤物视频在线观看| 亚洲国产精品成人综合色在线婷婷| 美女视频网站久久| 日韩一卡二卡三卡国产欧美| 日韩精品福利网| 欧美日韩视频在线第一区| 亚洲欧美日韩国产手机在线 | 久久久亚洲精品石原莉奈| 免费在线一区观看| 日韩一区二区在线免费观看| 日韩在线a电影| 日韩视频一区二区| 国产自产视频一区二区三区| 国产午夜精品在线观看| 国产精品自拍三区| 国产精品―色哟哟| 97久久久精品综合88久久| 亚洲欧美日韩一区| 在线免费精品视频| 亚洲小少妇裸体bbw| 91精品国产综合久久福利| 七七婷婷婷婷精品国产| 欧美精品一区男女天堂| 成人精品电影在线观看| ...中文天堂在线一区| 91啪在线观看| 调教+趴+乳夹+国产+精品| 欧美va亚洲va国产综合| 国产乱妇无码大片在线观看| 国产精品理论片| 欧美性做爰猛烈叫床潮| 日韩精品电影在线| 久久久久久久久久看片| 99国产欧美久久久精品| 午夜伊人狠狠久久| 精品欧美一区二区三区精品久久| 国产福利一区二区| 一区二区三区四区在线播放 | 91老司机福利 在线| 午夜成人免费视频| 久久青草国产手机看片福利盒子| 成人午夜电影久久影院| 亚洲电影一级黄| 国产日韩三级在线| 欧美亚洲高清一区二区三区不卡| 九九国产精品视频| 亚洲人精品午夜| 欧美mv和日韩mv的网站| 99国产欧美另类久久久精品| 麻豆一区二区在线| 亚洲少妇中出一区| 欧美精品一区二区三区四区 | av一本久道久久综合久久鬼色| 亚洲黄色尤物视频| 精品精品国产高清a毛片牛牛| 99国产精品久久久久久久久久久| 麻豆极品一区二区三区| 亚洲人成亚洲人成在线观看图片 | 亚洲另类在线制服丝袜| 精品久久一区二区| 欧美日韩中文一区| 国产成人免费视频网站高清观看视频 | 在线观看亚洲成人| 国产精品亚洲综合一区在线观看| 石原莉奈一区二区三区在线观看| 国产精品乱码一区二三区小蝌蚪| 日韩欧美国产成人一区二区| 欧美亚洲另类激情小说| www.99精品| 成人黄色在线看| 精品在线一区二区| 青草av.久久免费一区| 亚洲一区二区高清| 亚洲激情五月婷婷| 亚洲精选视频在线| 中文字幕第一区| 久久婷婷国产综合国色天香 | 老司机一区二区| 午夜在线成人av| 亚洲一区日韩精品中文字幕| 一区在线播放视频| 欧美高清在线精品一区| 久久久综合网站| 亚洲精品一区二区三区四区高清| 日韩一区二区免费电影| 欧美美女黄视频| 欧美精品一级二级三级| 欧美日韩综合在线| 欧美日韩免费一区二区三区 | 色婷婷狠狠综合| av成人老司机| 色哟哟欧美精品| 一本大道久久a久久精二百| 97国产精品videossex| 不卡一区二区中文字幕| www.成人网.com| 一本久久a久久精品亚洲| 91在线观看视频| 91麻豆精东视频| 欧洲国内综合视频| 欧美精选一区二区| 欧美成人r级一区二区三区| 欧美mv日韩mv国产网站app| 国产亚洲欧洲一区高清在线观看| 久久久午夜精品理论片中文字幕| 久久综合九色综合久久久精品综合 | 亚洲三级久久久| 亚洲一区二区成人在线观看| 视频一区欧美日韩| 精品综合免费视频观看| 风间由美一区二区三区在线观看 | 久久99久久精品欧美| 国产呦萝稀缺另类资源| 国产成人av福利| 91麻豆高清视频| 91精品国产欧美一区二区| 欧美xingq一区二区| 日本一区二区三区电影| 亚洲黄色av一区| 免费人成在线不卡| eeuss影院一区二区三区| 欧美亚洲国产一区二区三区va| 日韩视频免费观看高清完整版| 国产区在线观看成人精品| 亚洲精品乱码久久久久久| 麻豆精品久久精品色综合| 成人激情午夜影院| 欧美精品一卡二卡| 国产香蕉久久精品综合网| 亚洲香肠在线观看| 国产乱人伦偷精品视频免下载 | 一区二区在线观看免费视频播放| 亚洲成人一区二区| 国产精品亚洲专一区二区三区| 在线看国产一区| 久久蜜桃av一区二区天堂| 一区二区欧美在线观看| 韩国一区二区三区| 色国产精品一区在线观看| 精品国产露脸精彩对白| 亚洲欧美福利一区二区| 九九热在线视频观看这里只有精品| 91麻豆精品视频| 久久久精品免费免费| 日韩av一区二区在线影视| 91视频精品在这里| 久久久精品日韩欧美| 日本欧美久久久久免费播放网| 色综合天天综合给合国产| 亚洲精品在线电影| 免费观看日韩电影| 色噜噜狠狠色综合中国| 国产欧美精品一区二区色综合| 偷窥少妇高潮呻吟av久久免费| 91亚洲大成网污www| 久久久久久久久久久久久女国产乱| 亚洲成人av一区| 色丁香久综合在线久综合在线观看| 亚洲国产精品传媒在线观看| 九九视频精品免费| 日韩免费电影一区| 日韩影院精彩在线| 欧美日韩一区三区四区| 亚洲免费在线视频一区 二区| 成人一区二区视频| 国产欧美日韩麻豆91| 国内外成人在线| 精品国产乱码久久久久久浪潮| 蜜臀久久99精品久久久久久9| 7777精品伊人久久久大香线蕉最新版| 亚洲日本va在线观看| 不卡的av在线| 国产精品第四页| 成人黄色在线看| 亚洲欧洲日韩av| 91免费看视频| 樱桃视频在线观看一区| 欧美综合一区二区| 亚洲国产视频一区| 欧美日韩国产区一|