return 0;
}
+uint8_t prf_tls12_fill(void* dest, uint16_t length_B, prf_tls12_ctx_t* ctx){
+ uint16_t bs = ctx->blocklength_b/8;
+ while(length_B>=bs){
+ if(prf_tls12_next(dest, ctx)){
+ return 1;
+ }
+ length_B -= bs;
+ dest = (uint8_t*)dest + bs;
+ }
+ if(length_B){
+ uint8_t buffer[bs];
+ if(prf_tls12_next(buffer, ctx)){
+ return 2;
+ }
+ memcpy(dest, buffer, length_B);
+ }
+ return 0;
+}
void prf_tls12_free(prf_tls12_ctx_t* ctx);
uint8_t prf_tls12_next(void* dest, prf_tls12_ctx_t* ctx);
+uint8_t prf_tls12_fill(void* dest, uint16_t length_B, prf_tls12_ctx_t* ctx);
#endif /* PRF_TLS12_H_ */
void test_prf(const hfdesc_t* hash){
prf_tls12_ctx_t ctx;
+ uint8_t buffer[100];
prf_tls12_init_w_label(&ctx, hash, test_secret, 16*8, test_label, strlen(test_label), test_seed, 16*8);
- uint8_t buffer[ctx.blocklength_b/8];
- uint16_t i=0;
cli_putstr("\r\n== Testing PRF-TLSv1.2 with ");
cli_putstr(hash->name);
cli_putstr(" ==\r\n");
- do{
- prf_tls12_next(buffer, &ctx);
- cli_hexdump_block(buffer, ctx.blocklength_b/8, 4, 8);
- i += ctx.blocklength_b/8;
- }while(i<100);
+ prf_tls12_fill(buffer, 100, &ctx);
+ cli_hexdump_block(buffer, 100, 4, 8);
prf_tls12_free(&ctx);
}