Index: sw/common/lib/libbsl/Make.common =================================================================== RCS file: /home/routefree/gba/depot/sw/common/lib/libbsl/Make.common,v retrieving revision 1.11 retrieving revision 1.11.16.1 diff -r1.11 -r1.11.16.1 11c11 < CFILES = keystore.c bslutils.c bsl.c prng.c --- > CFILES = keystore.c bslutils.c bsl.c prng.c keyglobals.c Index: sw/common/lib/libbsl/keystore.c =================================================================== RCS file: /home/routefree/gba/depot/sw/common/lib/libbsl/keystore.c,v retrieving revision 1.25 retrieving revision 1.25.14.1 diff -r1.25 -r1.25.14.1 25,26c25,28 < keyMetaElem keyMeta[KEY_META_MAX_SIZE]; < keyStoreElem keyStore[KEY_STORE_MAX_SIZE]; --- > extern keyMetaElem keyMeta[KEY_META_MAX_SIZE]; > extern keyStoreElem keyStore[KEY_STORE_MAX_SIZE]; > keyMetaElem keyMetaDummy[KEY_META_MAX_SIZE]; > keyStoreElem keyStoreDummy[KEY_STORE_MAX_SIZE]; Index: sw/common/lib/libcsl/Make.common =================================================================== RCS file: /home/routefree/gba/depot/sw/common/lib/libcsl/Make.common,v retrieving revision 1.3 retrieving revision 1.3.20.1 diff -r1.3 -r1.3.20.1 5a6,8 > ifndef DS_ROOT > TARGETS = libcsl.a libcsl_dev.a > endif 7,9c10 < TARGETS = libcsl.a < < CFILES = aes.c aes_api.c aes_imp.c sha1.c integer_math.c poly_math.c elliptic_math.c algorithms.c convecc.c convrsa.c cslecc.c cslrsa.c --- > CFILES = aes.c aes_api.c aes_imp.c sha1.c integer_math.c poly_math.c elliptic_math.c algorithms.c convecc.c convrsa.c cslecc.c 13c14 < $(TARGETS): %: %($(OBJECTS)) --- > libcsl.a: $(OBJECTS) cslrsa.o 14a16,22 > > cslrsa_dev.o: cslrsa.c > $(CC) $(CFLAGS) -DRVL_DEVEL -c $^ -o $@ > > libcsl_dev.a: $(OBJECTS) cslrsa_dev.o > ar cru $@ $? > Index: sw/common/lib/libcsl/cslrsa.c =================================================================== RCS file: /home/routefree/gba/depot/sw/common/lib/libcsl/cslrsa.c,v retrieving revision 1.3 retrieving revision 1.3.18.2 diff -r1.3 -r1.3.18.2 33d32 < 46c45 < u32 eDigits, nDigits; --- > u32 eDigits, nDigits, n; 47a47 > u8 *p, match; 52a53,56 > static u8 sha1_sig[16] = { 0x00, > 0x30, 0x21, 0x30, 0x09, 0x06, 0x05, 0x2b, 0x0e, > 0x03, 0x02, 0x1a, 0x05, 0x00, 0x04, 0x14 > }; 54,57d57 < OS2IP (bign, keysize/sizeof(u32), certpublickey, keysize); < OS2IP (bigm, keysize/sizeof(u32), certsign, keysize); < OS2IP (bige, 1, certexponent, expsize); < eDigits = 1; 58a59,63 > eDigits = 1; > > OS2IP (bign, nDigits, certpublickey, keysize); > OS2IP (bigm, nDigits, certsign, keysize); > OS2IP (bige, eDigits, certexponent, expsize); 64,66c69,72 < < if(strncmp(result + (keysize) - sizeof(CSLOSSha1Hash), hash, sizeof(CSLOSSha1Hash)) == 0){ < return CSL_OK; --- > p = result; > match = (p[0] == 0x00) & (p[1] == 0x01); > for(p += 2; p < result + keysize - sizeof(CSLOSSha1Hash) - sizeof(sha1_sig); ) { > match &= (*p++ == 0xff); 68,69c74,75 < else{ < return CSL_VERIFY_ERROR; --- > for(n = 0; n < sizeof(sha1_sig); n++) { > match &= (*p++ == sha1_sig[n]); 71,72c77,92 < < --- > #if defined(RVL_DEVEL) > /* > * This ifdef is to support existing tools for developers that incorrectly > * generate the padding for the RSA signature. Therefore, to remain > * backward compatible, we can only check the 20-byte hash and not the > * entire signature which should be padded using PKCS#1 v1.5 type 2 > * padding (officially EMSA-PKCS1-v1_5). > * For production images, we are using the correct padding (via HSM). > * See bug #2855, #2876. > */ > match = 1; > #endif > for(n = 0; n < sizeof(CSLOSSha1Hash); n++) { > match &= (*p++ == *hash++); > } > return(match? CSL_OK : CSL_VERIFY_ERROR); 112,116d131 < < OS2IP (bign, keysize/sizeof(u32), certpublickey, keysize); < OS2IP (bigm, keysize/sizeof(u32), paddedmessage, keysize); < OS2IP (bigd, keysize/sizeof(u32), secretexponent, keysize); < 118a134,137 > > OS2IP (bign, nDigits, certpublickey, keysize); > OS2IP (bigm, nDigits, paddedmessage, keysize); > OS2IP (bigd, dDigits, secretexponent, keysize); Index: sw/common/os/es/es_mgr.c =================================================================== RCS file: /home/routefree/gba/depot/sw/common/os/es/es_mgr.c,v retrieving revision 1.55 retrieving revision 1.55.8.1 diff -r1.55 -r1.55.8.1 633c633,634 < if (args->readCount != 4 || --- > if (ctx->uid != IOS_DI_PROCESS || /* Only accept this from DI RM */ > args->readCount != 4 || Index: sw/common/os/fs/fs_mgr.c =================================================================== RCS file: /home/routefree/gba/depot/sw/common/os/fs/fs_mgr.c,v retrieving revision 1.18 retrieving revision 1.18.4.1 diff -r1.18 -r1.18.4.1 467c467 < flashReq = 1; --- > flashReq = 0; Index: sw/tools/lib/librsa/rsautil.c =================================================================== RCS file: /home/routefree/gba/depot/sw/tools/lib/librsa/rsautil.c,v retrieving revision 1.14 retrieving revision 1.14.20.2 diff -r1.14 -r1.14.20.2 12a13,17 > /* sha1 rsa signature, PKCS1 type 2 */ > > unsigned char RUTIL_sha1_sig[16] = { 0x00, > 0x30, 0x21, 0x30, 0x09, 0x06, 0x05, 0x2b, 0x0e, > 0x03, 0x02, 0x1a, 0x05, 0x00, 0x04, 0x14 }; 57a63 > 65a72 > printf("rsasize = %d\n", rsasize); 71c78,82 < RSA_padding_add_PKCS1_type_2(padded_data, rsasize, hash_data, sizeof(hash_data)); --- > i = RSA_padding_add_PKCS1_type_1(padded_data, rsasize, hash_data, sizeof(hash_data)); > if(i != 1) > printf("RSA_padding_add_PKCS1_type_2() error\n"); > memcpy(padded_data + rsasize - sizeof(hash_data) - sizeof(RUTIL_sha1_sig), > RUTIL_sha1_sig, sizeof(RUTIL_sha1_sig)); 75,76c86,87 < for(i = 0; i < data_size; i++){ < printf("padded hash = %02x\n", padded_data[i]); --- > for(i = 0; i < rsasize; i++){ > printf("padded hash[%d] = %02x\n", i, padded_data[i]); 106a118 > unsigned char *p, match; 114a127 > printf("rsasize = %d\n", rsasize); 124,129c137,140 < < if(memcmp(verify + newsize - sizeof(hash_data), hash_data, sizeof(hash_data)) ==0){ < return 0; < } < else{ < return -1; --- > > #ifdef DEBUG > for( i = 0; i < rsasize; i++){ > printf("verify[%d] = 0x%02x;\n", i, verify[i]); 130a142 > #endif 131a144,155 > p = verify; > match = (p[0] == 0x00) & (p[1] == 0x01); > for(p += 2; p < verify + newsize - sizeof(CSLOSSha1Hash) - sizeof(RUTIL_sha1_sig);) { > match &= (*p++ == 0xff); > } > for(i = 0; i < sizeof(RUTIL_sha1_sig); i++) { > match &= (*p++ == RUTIL_sha1_sig[i]); > } > for(i = 0; i < sizeof(CSLOSSha1Hash); i++) { > match &= (*p++ == hash_data[i]); > } > return(match? 0 : -1);