LRESULT FiltersDialog::OnMovement(WPARAM w, LPARAM l)
{
	SetStaticData();
	if(w == TB_ENDTRACK)
	{
		// TODO : возможно, пересчитать фильтр
	}
	return 0l;
}
BOOL FiltersDialog::OnInitDialog()
{
	CDialog::OnInitDialog();
	_weight_slider.SetRange(1, 5);
	_weight_slider.SetPos(3);
	CheckFilterType();
	SetStaticData();
	return TRUE;
}
Ejemplo n.º 3
0
int GenerateTicket(USER_CONTEXT *ctx)
{
	if(ctx->flags[verbose]) { printf("[+] Generating Ticket\n"); }
	ctx->cia_section[tik].size = (sizeof(TICKET_STRUCTURE)+ sizeof(TIK_2048_SIG_CONTEXT));
	ctx->cia_section[tik].buffer = malloc(ctx->cia_section[tik].size);
	if(ctx->cia_section[tik].buffer == NULL){
		printf("[!] Failed to allocated memory for ticket\n");
		return 1;
	}
	
	TICKET_STRUCTURE ticket;
	TIK_2048_SIG_CONTEXT sig;
	memset(&sig,0x0,sizeof(TIK_2048_SIG_CONTEXT));
	memset(&ticket,0x0,sizeof(TICKET_STRUCTURE));
	
	if(ctx->flags[verbose]) { printf(" > Collecting Data\n"); }
	ticket.TicketFormatVersion = ctx->core.ticket_format_ver;
	ticket.ca_crl_version = ctx->core.ca_crl_version;
	ticket.signer_crl_version = ctx->core.signer_crl_version;
	ticket.CommonKeyID = ctx->keys.common_key_id;
	
	memcpy(ticket.Issuer,ctx->core.TicketIssuer,0x40);
	memcpy(ticket.TicketID,ctx->core.TicketID,0x8);
	memcpy(ticket.DeviceID,ctx->core.DeviceID,0x4);
	memcpy(ticket.TitleID,ctx->core.TitleID,0x8);
	memcpy(ticket.TicketVersion,ctx->core.TicketVersion,0x2);
	
	if(ctx->flags[verbose]) { printf(" > Encrypting Titlekey\n"); }
	if(EncryptTitleKey(ticket.EncryptedTitleKey,ctx->keys.title_key,ctx->keys.common_key,ctx->core.TitleID) != 0){
		printf("[!] Failed to encrypt titlekey\n");
		return Fail;
	}
	if(ctx->flags[showkeys])
		memdump(stdout,"\n[+] Encrypted Title Key:   ",ticket.EncryptedTitleKey,0x10);
	
	if(SetStaticData(dev,ticket.StaticData) != 0){
		printf("[!] ERROR in Generating Ticket\n");
		return Fail;
	}
	if(ctx->flags[verbose]) { printf(" > Signing Ticket\n"); }
	u32_to_u8(sig.sig_type,RSA_2048_SHA256,BE);
	u8 hash[0x20];
	ctr_sha(&ticket,sizeof(TICKET_STRUCTURE),hash,CTR_SHA_256);
	if(ctr_rsa(hash,sig.data,ctx->keys.ticket.n,ctx->keys.ticket.d,RSA_2048_SHA256,CTR_RSA_SIGN) != Good){
		printf("[!] Failed to sign ticket\n");
		return ticket_gen_fail;
	}
	
	if(ctx->flags[info]){
		memdump(stdout,"[+] Ticket Signature:   ",sig.data,0x100);
	}
	
	memcpy(ctx->cia_section[tik].buffer,&sig,sizeof(TIK_2048_SIG_CONTEXT));
	memcpy((ctx->cia_section[tik].buffer + sizeof(TIK_2048_SIG_CONTEXT)),&ticket,sizeof(TICKET_STRUCTURE));
	return 0;
}