From 5684bfaa23e1549e9e1263371fbaf112b5f49a20 Mon Sep 17 00:00:00 2001 From: lukas-heilgenbrunner Date: Tue, 22 Oct 2024 15:11:53 +0200 Subject: [PATCH] add flowchart --- main.typ | 51 ++++++++++++++++++++++++++++++++++++++++++++++++++- 1 file changed, 50 insertions(+), 1 deletion(-) diff --git a/main.typ b/main.typ index fe640a9..fe113d3 100644 --- a/main.typ +++ b/main.typ @@ -1,6 +1,18 @@ #import "@preview/ichigo:0.1.0": config, prob #import "@preview/algorithmic:0.1.0" #import algorithmic: algorithm +#import "@preview/fletcher:0.5.1" as fletcher: diagram, node, edge +#import fletcher.shapes: house, hexagon + +#let blob(pos, label, tint: white, ..args) = node( + pos, align(center, label), + width: 26mm, + fill: tint.lighten(60%), + stroke: 1pt + tint.darken(20%), + corner-radius: 5pt, + ..args, +) + #show: config.with( course-name: "SMART CARDS & NFC", @@ -20,7 +32,7 @@ ) ][ -- The PiN_TRY_COUNTER is prone to turn off attacks. +- The PIN_TRY_COUNTER is prone to turn off attacks. Each time the chip resets the ram value of the counter is cleared and one gets basically infinite retries. Solution: @@ -32,6 +44,43 @@ Solution: - Implement a constant time comparison operation. + +- PIN_TRY_COUNTER is incremented after the comparison operation. + If the operation is interrupted due to a non atomic operation, the counter not incremented. + + Solution: + - Do counter++ before comparison. This way the attacker can't determine if the counter is incremented or not. + + #sym.arrow.r See flowchart + - Implement a atomic operation for the counter incrementation. + + #align(center)[ + #diagram( + spacing: 8pt, + cell-size: (8mm, 10mm), + edge-stroke: 1pt, + edge-corner-radius: 5pt, + mark-scale: 70%, + debug: false, + + blob((2,0), [PIN Verification], tint: yellow, shape: fletcher.shapes.pill), + edge("-|>"), + blob((2,1), [PIN_Try_Counter < LIMIT], tint: green, shape: fletcher.shapes.hexagon, width: 35mm), + edge("ll,dddd", "-|>", label: "No"), + edge("-|>", "d"), + blob((0,5), [Result: Card/Pin blocked], tint: yellow, shape: fletcher.shapes.pill), + + blob((2,2), [Pin_try_counter++], tint: blue, shape: fletcher.shapes.rect, width: auto), + edge("-|>"), + blob((2,3), [PIN == Ref_PIN?], tint: green, shape: fletcher.shapes.hexagon, width: auto), +edge("l,d", "-|>", label: "Yes"), +edge( "r,dd", "-|>", label: "No"), + blob((1,4), [Pin_try_counter = 0], tint: blue, shape: fletcher.shapes.rect, width: auto), + edge("-|>"), + blob((1,5), [PIN Verification], tint: yellow, shape: fletcher.shapes.pill), + blob((3,5), [PIN Verification], tint: yellow, shape: fletcher.shapes.pill), + ) + ] ] #prob[