mirror of
https://github.com/infiniteCable2/panda.git
synced 2026-02-22 03:03:56 +08:00
* Let refactoring begin! * Fix pedal build * Fix pedal safety tests * Forgot few TIM2 instances * Try this way with misra * More misras... * More misras... * Still fighting with misra blindfolded * Almost got it! * Last misra error.. * Last misra error.. * Misra works locally.. * Maybe this? * Looks like it was cppcheck bug, revert changes * Suggested changes and reverts * File structure change * revert includes * remove spaces * remove timer delay * endings * more typing * rename early to early_initialization * Remove delay_us * Revert RTC default values * Revert initialization sequence * Fix quotes * Revert * Return TIM6EN * Alias slow timer to TICK_TIMER * Refactor files structure * Remove definition of PANDA * Abstract timers * Fix include * tick_timer_init * Split usb driver * Move LL stuff: adc * Move LL stuff: usb * Fix include again... * Will check pedal builds also locally.. * Move LL stuff: CAN * Move LL stuff: clock * Rename common to peripherals and move * Move board HAL * Change include, not needed for pedal * llgpio to gpio and new lines fix * remove board_has_relay, not used * Remove board_functions.h and add to board struct * Move include * Fk MISRA... * has_onboard_gmlan to has_hw_gmlan * Typos * Move board_declarations include * Shuffle * More abstraction * fix paths, fix cppcheck test * Fix for pedal build with USB
35 lines
741 B
C
35 lines
741 B
C
/*
|
|
gcc -DTEST_RSA test_rsa.c ../crypto/rsa.c ../crypto/sha.c && ./a.out
|
|
*/
|
|
|
|
#include <stdio.h>
|
|
#include <stdlib.h>
|
|
|
|
#define MAX_LEN 0x40000
|
|
char buf[MAX_LEN];
|
|
|
|
#include "../crypto/sha.h"
|
|
#include "../crypto/rsa.h"
|
|
#include "../obj/cert.h"
|
|
|
|
int main() {
|
|
FILE *f = fopen("../obj/panda.bin", "rb");
|
|
int tlen = fread(buf, 1, MAX_LEN, f);
|
|
fclose(f);
|
|
printf("read %d\n", tlen);
|
|
uint32_t *_app_start = (uint32_t *)buf;
|
|
|
|
int len = _app_start[0];
|
|
char digest[SHA_DIGEST_SIZE];
|
|
SHA_hash(&_app_start[1], len-4, digest);
|
|
printf("SHA hash done\n");
|
|
|
|
if (!RSA_verify(&rsa_key, ((void*)&_app_start[0]) + len, RSANUMBYTES, digest, SHA_DIGEST_SIZE)) {
|
|
printf("RSA fail\n");
|
|
} else {
|
|
printf("RSA match!!!\n");
|
|
}
|
|
|
|
return 0;
|
|
}
|