AKT un outil pour
sécuriser vos données et
documents sensibles
Stéphane Carrez POSS 2019
https://github.com/stcarrez/ada-keystore 2
Les (mauvaises) pratiques de
sécurité (1)
● Mon mot de passe sur post-it
https://github.com/stcarrez/ada-keystore 3
Les (mauvaises) pratiques de
sécurité (2)
● Mes clefs d’API dans le code sous GitHub
(100 000 repo)
● 57 million de comptes
● 100 000 $ de ranson
● 148 million $ d’amende
https://github.com/stcarrez/ada-keystore 4
Les (mauvaises) pratiques de
sécurité (3)
● Mes documents confidentiels dans le Cloud
https://github.com/stcarrez/ada-keystore 5
Pourquoi AKT?
● Plusieurs besoins :
– stocker les paramètres sensibles d’un serveur
écrit en Ada
– sauver des numéros de comptes, mots de
passe
– sauver des documents cryptés complets sans
exposer les clefs
https://github.com/stcarrez/ada-keystore 6
Pourquoi Ada?
● Ada n’est pas qu’un vieux langage : Ada 2012
● Ada n’est pas que pour les militaires, l’aviation
● Ada est fortement typé et détecte les erreurs de
programmation
● Moins de CWE
(Common Weakness Enumeration)
– Pas de buffer overflow (CWE 120)
https://github.com/stcarrez/ada-keystore 7
AKT: un stockage sécurisé
AKT
User passwordGPG protected key
Encrypted Data
Keystore
https://github.com/stcarrez/ada-keystore 8
AKT: avec plusieurs clefs
Directory key
Master key block
Data info key
Data key key
Data keys
Data keys
Signature key
User password
GPG protected
key
Data fragment
Data fragment
Data fragment
Data fragment
Data fragment
Directory keys Encrypted Data
https://github.com/stcarrez/ada-keystore 9
AKT: des keystores récursifs
Directory key
Master key block
Data info key
Data key key
Data keys
Data keys
Signature key
Second key
First key
Directory keys
Directory key
Master key block
Data info key
Data key key
Signature key
https://github.com/stcarrez/ada-keystore 10
AKT: des blocs sans chaine
HMAC-256HDR
(1815-12-10)
(1852-11-27)
Ada
HMAC-256UUID
Storage
ID
HDR Data Storage Info + HMAC
Directory Name Entry Data block indexes & keys
HMAC-256HDR Data fragment info HMAC-256 Data Fragment
Header block
Directory block
Data block
Master key block
...
HMAC-256HDR Wallet info Key slot 1UUID Key slot 7...
4K
https://github.com/stcarrez/ada-keystore 11
AKT: protection des clefs (1)
Wallet master key slot N (512 bytes)
key slot Nsalt key N
HMAC
256
= ?
AES-256
CBC
Wallet Master Keys
(32 bytes) (240 bytes)
key key
(256 bits)
key IV
(128 bits)
dat key
(256 bits)
dat IV
(128 bits)
dir key
(256 bits)
dir IV
(128 bits)
Wallet master key block
AES-256
CBC
PBKDF2
HMAC
256
ctr slot N
(4 bytes)
Sign N HMAC
(32 bytes) (32 bytes)
PBKDF2
HMAC
256
(4 bytes)
salt IV N
(32 bytes)
HMAC-256HDR Wallet info Key slot 1UUID Key slot 7...
Wallet Header Key, wallet header IV, Block ID
User password NO, invalid
password
YES, valid password
dir sign
(256 bits)
dat sign
(256 bits)
key sign
(256 bits)
Key
IV
HMAC
256
= ?
NO, invalid
block
YES, valid block
Wallet Sign
https://github.com/stcarrez/ada-keystore 12
AKT: protection des clefs (2)
Wallet master key slot N (512 bytes)
key slot N
HMAC
256
= ?
AES-256
CBC
Wallet Master Keys
(240 bytes)
key key
(256 bits)
key IV
(128 bits)
dat key
(256 bits)
dat IV
(128 bits)
dir key
(256 bits)
dir IV
(128 bits)
Wallet master key block
AES-256
CBC
Sign N HMAC
(32 bytes) (32 bytes)
HMAC-256HDR Wallet info Key slot 1UUID Key slot 7...
NO, invalid
password
YES, valid password
dir sign
(256 bits)
dat sign
(256 bits)
key sign
(256 bits)
Key, IV
GPG2
GPG Private key
Header block
Key
(32 bytes)
IV
(16 bytes)
IV Key
(16 bytes) (32 bytes)
(1815-12-10)
(1852-11-27)
Ada
HMAC-256UUID
Storage
ID
HDR Data Storage Info + HMAC
Sign
(32 bytes)
HMAC
256
= ? NO, invalid
block
YES, valid block
header tag
(4 bytes)
https://github.com/stcarrez/ada-keystore 13
AKT: protection des clefs (3)
Directory block
AES-256
CBC
HMAC-256HDR ...
Directory Key, directory IV, Block ID HMAC
256
= ?
NO, invalid
block
YES, valid block
Directory Sign
Directory Name Entry Data block indexes & keys...
Per data fragment encryption keys
Name
(N bytes)
Entry ID
(4 bytes)
key
(256 bits)
IV
(128 bits)
Block NumStore ID
(4 bytes)(4 bytes)(4 bytes)
Entry ID
HMAC-256HDR Data fragment info HMAC-256 Data Fragment HMAC-256HDR Data fragment info HMAC-256 Data Fragment
https://github.com/stcarrez/ada-keystore 14
AKT : à retenir
● Plusieurs clefs AES-256 pour un même document
● Intégrité par HMAC-256 sur plusieurs niveaux
● Blocs avec des classes de sécurités différentes
● Partage sécurisé entre N participants (N<=7)
https://github.com/stcarrez/ada-keystore 15
AKT : création du Keystore
● Protection par mot de passe :
akt create ks.akt ­p admin
● Protection par GPG:
akt create ks.akt ­­gpg user
● Protection par GPG et séparation des données:
akt create ks.akt ­­split 10 ­­gpg user
https://github.com/stcarrez/ada-keystore 16
AKT : protection de documents
● Protéger un document:
akt store ks.akt mydoc.odt
● Utiliser akt get pour l’obtenir:
akt extract ks.akt mydoc.odt
https://github.com/stcarrez/ada-keystore 17
AKT : protégez vos scripts
● But : protéger une clef d’API de type OAuth2:
akt set ks.akt api.key Ahn1kos8Ahn1k
● Utiliser akt get pour l’obtenir:
key=`akt get ks.akt api.key`
https://github.com/stcarrez/ada-keystore 18
AKT : pas de secret dans le code
● Intégration python
import subprocess
result = subprocess.run([‘akt’, ‘get’, 
‘ks.akt’, ‘api.key’], 
stdout=subprocess.PIPE)
key = result.stdout
https://github.com/stcarrez/ada-keystore 19
AKT : une sauvegarde sécurisée
● Création de la sauvegarde:
tar czf ­ . | akt store ks.akt ­­ backup
● Extraction:
akt extract ks.akt ­­ backup | tar xzf ­
https://github.com/stcarrez/ada-keystore 20
AKT : un partage sécurisé
● Importer les clefs GPG des participants
● Création du keystore:
akt create ks.akt ­­gpg key­id­1 key­id­2
● Chaque participant utilise sa propre clef GPG
privée
akt store ks.akt documents.zip
https://github.com/stcarrez/ada-keystore 21
AKT : évolutions
● Support de ChaCha20 (alternative à AES-256)
● Support de SmartCart/PKCS#11
● Scellement des blocs avec arbre de Merkle
● Intégration avec le Cloud dans GAKT
https://github.com/stcarrez/ada-keystore 22
Conclusion
● Pas de post-it pour les mots de passe
● Pas d’excuse pour les clefs d’API dans GitHub
● AKT pour crypter vos documents sur le Cloud !
● Disponible pour GNU/Linux, FreeBSD, NetBSD
● Open Source, Contributions Welcome !,
License Apache 2.0
● Documentation
– https://ada-keystore.readthedocs.io/en/latest/

AKT un outil pour sécuriser vos données et documents sensibles

  • 1.
    AKT un outilpour sécuriser vos données et documents sensibles Stéphane Carrez POSS 2019
  • 2.
    https://github.com/stcarrez/ada-keystore 2 Les (mauvaises)pratiques de sécurité (1) ● Mon mot de passe sur post-it
  • 3.
    https://github.com/stcarrez/ada-keystore 3 Les (mauvaises)pratiques de sécurité (2) ● Mes clefs d’API dans le code sous GitHub (100 000 repo) ● 57 million de comptes ● 100 000 $ de ranson ● 148 million $ d’amende
  • 4.
    https://github.com/stcarrez/ada-keystore 4 Les (mauvaises)pratiques de sécurité (3) ● Mes documents confidentiels dans le Cloud
  • 5.
    https://github.com/stcarrez/ada-keystore 5 Pourquoi AKT? ●Plusieurs besoins : – stocker les paramètres sensibles d’un serveur écrit en Ada – sauver des numéros de comptes, mots de passe – sauver des documents cryptés complets sans exposer les clefs
  • 6.
    https://github.com/stcarrez/ada-keystore 6 Pourquoi Ada? ●Ada n’est pas qu’un vieux langage : Ada 2012 ● Ada n’est pas que pour les militaires, l’aviation ● Ada est fortement typé et détecte les erreurs de programmation ● Moins de CWE (Common Weakness Enumeration) – Pas de buffer overflow (CWE 120)
  • 7.
    https://github.com/stcarrez/ada-keystore 7 AKT: unstockage sécurisé AKT User passwordGPG protected key Encrypted Data Keystore
  • 8.
    https://github.com/stcarrez/ada-keystore 8 AKT: avecplusieurs clefs Directory key Master key block Data info key Data key key Data keys Data keys Signature key User password GPG protected key Data fragment Data fragment Data fragment Data fragment Data fragment Directory keys Encrypted Data
  • 9.
    https://github.com/stcarrez/ada-keystore 9 AKT: deskeystores récursifs Directory key Master key block Data info key Data key key Data keys Data keys Signature key Second key First key Directory keys Directory key Master key block Data info key Data key key Signature key
  • 10.
    https://github.com/stcarrez/ada-keystore 10 AKT: desblocs sans chaine HMAC-256HDR (1815-12-10) (1852-11-27) Ada HMAC-256UUID Storage ID HDR Data Storage Info + HMAC Directory Name Entry Data block indexes & keys HMAC-256HDR Data fragment info HMAC-256 Data Fragment Header block Directory block Data block Master key block ... HMAC-256HDR Wallet info Key slot 1UUID Key slot 7... 4K
  • 11.
    https://github.com/stcarrez/ada-keystore 11 AKT: protectiondes clefs (1) Wallet master key slot N (512 bytes) key slot Nsalt key N HMAC 256 = ? AES-256 CBC Wallet Master Keys (32 bytes) (240 bytes) key key (256 bits) key IV (128 bits) dat key (256 bits) dat IV (128 bits) dir key (256 bits) dir IV (128 bits) Wallet master key block AES-256 CBC PBKDF2 HMAC 256 ctr slot N (4 bytes) Sign N HMAC (32 bytes) (32 bytes) PBKDF2 HMAC 256 (4 bytes) salt IV N (32 bytes) HMAC-256HDR Wallet info Key slot 1UUID Key slot 7... Wallet Header Key, wallet header IV, Block ID User password NO, invalid password YES, valid password dir sign (256 bits) dat sign (256 bits) key sign (256 bits) Key IV HMAC 256 = ? NO, invalid block YES, valid block Wallet Sign
  • 12.
    https://github.com/stcarrez/ada-keystore 12 AKT: protectiondes clefs (2) Wallet master key slot N (512 bytes) key slot N HMAC 256 = ? AES-256 CBC Wallet Master Keys (240 bytes) key key (256 bits) key IV (128 bits) dat key (256 bits) dat IV (128 bits) dir key (256 bits) dir IV (128 bits) Wallet master key block AES-256 CBC Sign N HMAC (32 bytes) (32 bytes) HMAC-256HDR Wallet info Key slot 1UUID Key slot 7... NO, invalid password YES, valid password dir sign (256 bits) dat sign (256 bits) key sign (256 bits) Key, IV GPG2 GPG Private key Header block Key (32 bytes) IV (16 bytes) IV Key (16 bytes) (32 bytes) (1815-12-10) (1852-11-27) Ada HMAC-256UUID Storage ID HDR Data Storage Info + HMAC Sign (32 bytes) HMAC 256 = ? NO, invalid block YES, valid block header tag (4 bytes)
  • 13.
    https://github.com/stcarrez/ada-keystore 13 AKT: protectiondes clefs (3) Directory block AES-256 CBC HMAC-256HDR ... Directory Key, directory IV, Block ID HMAC 256 = ? NO, invalid block YES, valid block Directory Sign Directory Name Entry Data block indexes & keys... Per data fragment encryption keys Name (N bytes) Entry ID (4 bytes) key (256 bits) IV (128 bits) Block NumStore ID (4 bytes)(4 bytes)(4 bytes) Entry ID HMAC-256HDR Data fragment info HMAC-256 Data Fragment HMAC-256HDR Data fragment info HMAC-256 Data Fragment
  • 14.
    https://github.com/stcarrez/ada-keystore 14 AKT :à retenir ● Plusieurs clefs AES-256 pour un même document ● Intégrité par HMAC-256 sur plusieurs niveaux ● Blocs avec des classes de sécurités différentes ● Partage sécurisé entre N participants (N<=7)
  • 15.
    https://github.com/stcarrez/ada-keystore 15 AKT :création du Keystore ● Protection par mot de passe : akt create ks.akt ­p admin ● Protection par GPG: akt create ks.akt ­­gpg user ● Protection par GPG et séparation des données: akt create ks.akt ­­split 10 ­­gpg user
  • 16.
    https://github.com/stcarrez/ada-keystore 16 AKT :protection de documents ● Protéger un document: akt store ks.akt mydoc.odt ● Utiliser akt get pour l’obtenir: akt extract ks.akt mydoc.odt
  • 17.
    https://github.com/stcarrez/ada-keystore 17 AKT :protégez vos scripts ● But : protéger une clef d’API de type OAuth2: akt set ks.akt api.key Ahn1kos8Ahn1k ● Utiliser akt get pour l’obtenir: key=`akt get ks.akt api.key`
  • 18.
    https://github.com/stcarrez/ada-keystore 18 AKT :pas de secret dans le code ● Intégration python import subprocess result = subprocess.run([‘akt’, ‘get’,  ‘ks.akt’, ‘api.key’],  stdout=subprocess.PIPE) key = result.stdout
  • 19.
    https://github.com/stcarrez/ada-keystore 19 AKT :une sauvegarde sécurisée ● Création de la sauvegarde: tar czf ­ . | akt store ks.akt ­­ backup ● Extraction: akt extract ks.akt ­­ backup | tar xzf ­
  • 20.
    https://github.com/stcarrez/ada-keystore 20 AKT :un partage sécurisé ● Importer les clefs GPG des participants ● Création du keystore: akt create ks.akt ­­gpg key­id­1 key­id­2 ● Chaque participant utilise sa propre clef GPG privée akt store ks.akt documents.zip
  • 21.
    https://github.com/stcarrez/ada-keystore 21 AKT :évolutions ● Support de ChaCha20 (alternative à AES-256) ● Support de SmartCart/PKCS#11 ● Scellement des blocs avec arbre de Merkle ● Intégration avec le Cloud dans GAKT
  • 22.
    https://github.com/stcarrez/ada-keystore 22 Conclusion ● Pasde post-it pour les mots de passe ● Pas d’excuse pour les clefs d’API dans GitHub ● AKT pour crypter vos documents sur le Cloud ! ● Disponible pour GNU/Linux, FreeBSD, NetBSD ● Open Source, Contributions Welcome !, License Apache 2.0 ● Documentation – https://ada-keystore.readthedocs.io/en/latest/