Hackster is hosting Hackster Holidays, Ep. 6: Livestream & Giveaway Drawing. Watch previous episodes or stream live on Monday!Stream Hackster Holidays, Ep. 6 on Monday!
James Caska
Published © MIT

Proof of Life: Authenticate Critical Arduino Actions w/ ADA

Use VBBMicro to add an extra layer of security to your Arduino app by proving mission critical actions in real-time, in-circuit, and in ADA.

IntermediateProtip1 hour2,153
Proof of Life: Authenticate Critical Arduino Actions w/ ADA

Things used in this project

Hardware components

Arduino UNO
Arduino UNO
×1
Virtual Breadboard VBBMicro
×1

Software apps and online services

AdaCore JGNAT [Java Virtual Machine on Windows]
To download : * Select Java Virtual Machine on Windows from the dropdown list * Download gnat-gpl-2012-avr-windows-bin.exe
Virtual Breadboard VBB App
Virtual Breadboard VBB Debug VSCode Extension
VSCode ADA Extension
Microsoft VSCode PowerShell Extension

Schematics

Keypad Schematics

Virtual Breadboard Keypad Test Schematic

Code

ProofOfLife

ADA
Code from Repository describing the Contracts framework
with Ada.Text_IO; use Ada.Text_IO;
with ProofOfLifeVBB;

package body ProofOfLife is
 
   function IsNoKeyAttack(Samples : in ProofOfLifeVBB.KeySampleData ; LastSampleIndex : in Integer) return Boolean is 
    
   begin

      if LastSampleIndex = 0 then
         -- Maybe it wrapped
         if Samples(1) = 0 then
            -- Maybe it happened to overflow to zero
            if Samples(2) = 0 then
               return True;
            end if;
         end if;
      end if;

      return False;

   end IsNoKeyAttack;

   function IsKeyScanningAttack(Samples : in ProofOfLifeVBB.KeySampleData ; LastSampleIndex : in Integer) return Boolean is 
       
   begin
      -- TODO

      return False;

   end IsKeyScanningAttack;

   function UniqueKeyPresses(Samples : in ProofOfLifeVBB.KeySampleData ; LastSampleIndex : in Integer) return Integer is 
       
   begin
      -- TODO

      return 5;

   end UniqueKeyPresses;

 
   procedure ProofOfLife(Samples : in ProofOfLifeVBB.KeySampleData ; LastSampleIndex : in Integer)  is
    --  N : Integer;
   begin
         if IsNoKeyAttack(Samples, LastSampleIndex) then
            Put_Line ("--Alert IsNoKeyAttack--");
         elsif IsKeyScanningAttack(Samples, LastSampleIndex) then
            Put_Line ("--Alert IsNoKeyAttack--");
         elsif UniqueKeyPresses(Samples,LastSampleIndex) = 5 then
            Put_Line ("--Unlock Authenticated--");
         else
            Put_Line ("--Uknown Attack--");
         end if;
 
   end ProofOfLife;
 
   procedure WaitForEvent is

      Samples : ProofOfLifeVBB.KeySampleData ;
      N : Integer;

   begin

         Put_Line ("--Sampling Keys while waiting for Unlock event--");
      
         N := ProofOfLifeVBB.CaptureKeyEvents(Samples);

         ProofOfLife(Samples, N);
 
 
   end WaitForEvent;

end ProofOfLife;

 

Keypad

Arduino
Keypad testing application for Arduino
 
#include <Keypad.h>

const byte ROWS = 4; //four rows
const byte COLS = 4; //four columns
//define the cymbols on the buttons of the keypads
char hexaKeys[ROWS][COLS] = {
  {'0','1','2','3'},
  {'4','5','6','7'},
  {'8','9','A','B'},
  {'C','D','E','F'}
};
byte rowPins[ROWS] = {5, 4, 3, 2}; //connect to the row pinouts of the keypad
byte colPins[COLS] = {9, 8, 7, 6}; //connect to the column pinouts of the keypad

//initialize an instance of class NewKeypad
Keypad customKeypad = Keypad( makeKeymap(hexaKeys), rowPins, colPins, ROWS, COLS); 
char customKey = 0;
long mark;
void setup(){
 
  Serial.begin(9600);
  Serial.println("Begin Keypad");
}
  
void loop(){
   if( millis() > mark )
      customKey = customKeypad.getKey();
   
  if (customKey){
    Serial.println(customKey);
    mark = millis() + 100;
    customKey = 0;
  }
}

Proof of life

Extract to your computer and follow the youtube tutorial

Credits

James Caska

James Caska

18 projects • 33 followers
Creator of VirtualBreadboard

Comments