2 * Copyright (C) 2014 Spreadtrum Communications Inc.
4 * This program is free software; you can redistribute it and/or
5 * modify it under the terms of the GNU General Public License
6 * as published by the Free Software Foundation; either version 2
7 * of the License, or (at your option) any later version.
9 * This program is distributed in the hope that it will be useful,
10 * but WITHOUT ANY WARRANTY; without even the implied warranty of
11 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12 * GNU General Public License for more details.
17 #include "efuse_operate.h"
18 #include "secure_efuse.h"
20 extern int get_spl_hash(void* hash_data);
22 int secure_efuse_program(void){
25 //printf("secure efuse ------------------------\n");
26 ret = calc_sha1_write_efuse();
32 int calc_sha1_write_efuse(void){
35 unsigned char sha1_char[24];
36 unsigned int sha1_int[6];
41 memset(&sha1, 0x0, 24);
42 memset(sha1_string, 0x0, 41);
43 // ----- generate SHA1 key -----
44 get_spl_hash((void*)sha1.sha1_char);
45 /*sprintf(sha1_string,"%02x%02x%02x%02x%02x%02x%02x%02x%02x%02x%02x%02x%02x%02x%02x%02x%02x%02x%02x%02x", sha1.sha1_char[0],
64 sha1.sha1_char[19]);*/
65 sprintf(sha1_string,"%08x%08x%08x%08x%08x", sha1.sha1_int[0],
70 // ----- write SHA1 key Efuse -----
71 ret = efuse_hash_write_1(sha1_string, 40);
73 printf("sha1 efuse write Error [%d]\n", ret);
77 if ( efuse_secure_is_enabled() ){
81 efuse_secure_enable();
84 memset(sha2_string, 0x0, 41);
85 efuse_hash_read_1(sha2_string, 40);
86 printf("~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~\n~~~~~~~[%s]\n~~~~~~~~~~~~~~~~~~~~~~~\n", sha2_string);