Hardware components | ||||||
| × | 1 | ||||
| × | 1 | ||||
Software apps and online services | ||||||
| ||||||
| ||||||
| ||||||
| ||||||
|
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;
#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;
}
}
Comments