@@ -666,19 +666,24 @@ void getRandNum(char *dst, size_t size, int base){
666666#pragma mark tss functions
667667int tss_populate_devicevals (plist_t tssreq , uint64_t ecid , char * nonce , size_t nonce_size , char * sep_nonce , size_t sep_nonce_size , int image4supported ){
668668 plist_dict_set_item (tssreq , "ApECID" , plist_new_uint (ecid )); //0000000000000000
669+ plist_dict_set_item (tssreq , "Rap,ECID" , plist_new_uint (ecid )); //0000000000000000
669670 if (nonce ) {
670671 plist_dict_set_item (tssreq , "ApNonce" , plist_new_data (nonce , nonce_size ));//aa aa aa aa bb cc dd ee ff 00 11 22 33 44 55 66 77 88 99 aa
672+ plist_dict_set_item (tssreq , "Rap,Nonce" , plist_new_data (nonce , nonce_size ));//aa aa aa aa bb cc dd ee ff 00 11 22 33 44 55 66 77 88 99 aa
671673 }
672674
673675 if (sep_nonce ) {//aa aa aa aa bb cc dd ee ff 00 11 22 33 44 55 66 77 88 99 aa
674676 plist_dict_set_item (tssreq , "ApSepNonce" , plist_new_data (sep_nonce , sep_nonce_size ));
675677 }
676678
677679 plist_dict_set_item (tssreq , "ApProductionMode" , plist_new_bool (1 ));
678-
680+ plist_dict_set_item (tssreq , "Rap,ProductionMode" , plist_new_bool (1 ));
681+
679682 if (image4supported ) {
680683 plist_dict_set_item (tssreq , "ApSecurityMode" , plist_new_bool (1 ));
681684 plist_dict_set_item (tssreq , "ApSupportsImg4" , plist_new_bool (1 ));
685+
686+ plist_dict_set_item (tssreq , "Rap,SecurityMode" , plist_new_bool (1 ));
682687 } else {
683688 plist_dict_set_item (tssreq , "ApSupportsImg4" , plist_new_bool (0 ));
684689 }
@@ -756,7 +761,7 @@ int parseHex(const char *nonce, size_t *parsedLen, char *ret, size_t *retSize){
756761 return 0 ;
757762}
758763
759- int tss_populate_random (plist_t tssreq , int is64bit , t_devicevals * devVals ){
764+ int tss_populate_random (plist_t tssreq , int isIMG4Supported , t_devicevals * devVals ){
760765 size_t nonceLen = 32 ; //valid for all devices with KTRR
761766 if (!devVals -> deviceModel )
762767 return error ("[TSSR] internal error: devVals->deviceModel is missing\n" ),-1 ;
@@ -857,7 +862,7 @@ int tss_populate_random(plist_t tssreq, int is64bit, t_devicevals *devVals){
857862 debug ("[TSSR] ApNonce=%s\n" ,devVals -> apnonce );
858863 debug ("[TSSR] SepNonce=%s\n" ,devVals -> sepnonce );
859864
860- int rt = tss_populate_devicevals (tssreq , devVals -> ecid , devVals -> apnonce , devVals -> parsedApnonceLen , devVals -> sepnonce , devVals -> parsedSepnonceLen , is64bit );
865+ int rt = tss_populate_devicevals (tssreq , devVals -> ecid , devVals -> apnonce , devVals -> parsedApnonceLen , devVals -> sepnonce , devVals -> parsedSepnonceLen , isIMG4Supported );
861866 return rt ;
862867}
863868
@@ -891,27 +896,45 @@ int tssrequest(plist_t *tssreqret, char *buildManifest, t_devicevals *devVals, t
891896 plist_t sep = plist_dict_get_item (manifestdict , "SEP" );
892897 int is64Bit = !(!sep || plist_get_node_type (sep ) != PLIST_DICT );
893898
894- if (tss_populate_random (tssparameter ,is64Bit ,devVals ))
899+ plist_t Rap_BoardID = plist_dict_get_item (id0 , "Rap,BoardID" );
900+ int isRapDevice = !(!Rap_BoardID || plist_get_node_type (Rap_BoardID ) != PLIST_UINT );
901+
902+ if (tss_populate_random (tssparameter ,is64Bit || isRapDevice ,devVals ))
895903 reterror ("[TSSR] failed to populate tss request\n" );
896904
897905 tss_parameters_add_from_manifest (tssparameter , id0 );
898- if (tss_request_add_common_tags (tssreq , tssparameter , NULL ) < 0 ) {
899- reterror ("[TSSR] ERROR: Unable to add common tags to TSS request\n" );
900- }
901-
906+
902907 if (tss_request_add_ap_tags (tssreq , tssparameter , NULL ) < 0 ) {
903908 reterror ("[TSSR] ERROR: Unable to add common tags to TSS request\n" );
904909 }
905910
906- if (is64Bit ) {
907- if (tss_request_add_ap_img4_tags (tssreq , tssparameter ) < 0 ) {
911+ if (isRapDevice ) {
912+ if (tss_request_add_rose_tags (tssreq , tssparameter , NULL ) < 0 ) {
908913 reterror ("[TSSR] ERROR: Unable to add img4 tags to TSS request\n" );
909914 }
910- } else {
911- if (tss_request_add_ap_img3_tags (tssreq , tssparameter ) < 0 ) {
912- reterror ("[TSSR] ERROR: Unable to add img3 tags to TSS request\n" );
915+ }else {
916+ if (tss_request_add_common_tags (tssreq , tssparameter , NULL ) < 0 ) {
917+ reterror ("[TSSR] ERROR: Unable to add common tags to TSS request\n" );
918+ }
919+ if (is64Bit ) {
920+ if (tss_request_add_ap_img4_tags (tssreq , tssparameter ) < 0 ) {
921+ reterror ("[TSSR] ERROR: Unable to add img4 tags to TSS request\n" );
922+ }
923+ } else {
924+ if (tss_request_add_ap_img3_tags (tssreq , tssparameter ) < 0 ) {
925+ reterror ("[TSSR] ERROR: Unable to add img3 tags to TSS request\n" );
926+ }
927+ }
928+ if (basebandMode == kBasebandModeOnlyBaseband ) {
929+ if (plist_dict_get_item (tssreq , "@ApImg4Ticket" ))
930+ plist_dict_set_item (tssreq , "@ApImg4Ticket" , plist_new_bool (0 ));
931+ if (plist_dict_get_item (tssreq , "@APTicket" ))
932+ plist_dict_set_item (tssreq , "@APTicket" , plist_new_bool (0 ));
933+ //TODO: don't use .shsh2 ending and don't save generator when saving only baseband
934+ info ("[TSSR] User specified to request only a Baseband ticket.\n" );
913935 }
914936 }
937+
915938 if (plist_dict_get_item (tssreq , "Savage,BE-Dev-Patch" ))
916939 plist_dict_remove_item (tssreq , "Savage,BE-Dev-Patch" );
917940 if (plist_dict_get_item (tssreq , "Savage,BE-Prod-Patch" ))
@@ -920,14 +943,6 @@ int tssrequest(plist_t *tssreqret, char *buildManifest, t_devicevals *devVals, t
920943 plist_dict_remove_item (tssreq , "Savage,BF-Dev-Patch" );
921944 if (plist_dict_get_item (tssreq , "Savage,BF-Prod-Patch" ))
922945 plist_dict_remove_item (tssreq , "Savage,BF-Prod-Patch" );
923- if (basebandMode == kBasebandModeOnlyBaseband ) {
924- if (plist_dict_get_item (tssreq , "@ApImg4Ticket" ))
925- plist_dict_set_item (tssreq , "@ApImg4Ticket" , plist_new_bool (0 ));
926- if (plist_dict_get_item (tssreq , "@APTicket" ))
927- plist_dict_set_item (tssreq , "@APTicket" , plist_new_bool (0 ));
928- //TODO: don't use .shsh2 ending and don't save generator when saving only baseband
929- info ("[TSSR] User specified to request only a Baseband ticket.\n" );
930- }
931946
932947 if (basebandMode != kBasebandModeWithoutBaseband ) {
933948 //TODO: verify that this being int64_t instead of uint64_t doesn't actually break something
@@ -1000,7 +1015,7 @@ int isManifestBufSignedForDevice(char *buildManifestBuffer, t_devicevals *devVal
10001015 devVals -> parsedApnonceLen = 0 ;
10011016 devVals -> apnonce = (char * )0x1337 ;
10021017 devVals -> installType = kInstallTypeErase ;
1003- if (!tssrequest (& tssreq2 , buildManifestBuffer , devVals , kBasebandModeWithoutBaseband )){
1018+ if (tssreq2 && !tssrequest (& tssreq2 , buildManifestBuffer , devVals , kBasebandModeWithoutBaseband )){
10041019 apticket3 = tss_request_send (tssreq2 , server_url_string );
10051020 if (print_tss_response ) debug_plist (apticket3 );
10061021 }
0 commit comments