SlideShare a Scribd company logo
Dependent Types For Cryptography
Implementations
Paulo Silva

Manuel Barbosa

HASLab, Departamento de Informática
Universidade do Minho
Portugal

June 14, 2011
Motivation

Cryptographic software demands high-quality
implementations
The CAO language was developed close to cryptographic
standards making the implementation easier and more
reliable
This language is strongly typed with explicit type sizes
Improves safety but makes it less general and usable
Proposed solution: dependent types ⇒ CALF language
CAO Language
Small and simple domain specific language with imperative
flavour
Geared toward the automatic production of highly efficient
target code subject to security-aware optimizations
Type system supports cryptography types such as bit
strings, matrices and field extensions
CAO has a complete formalization of its:
Syntax
Semantics
Type system

We have proved that CAO type system is sound, i.e.,
“well-typed programs do not go wrong”
A fully functional CAO interpreter is also available
CAO Example
AES fragment

typedef GF2 := mod[ 2 ];
typedef GF2N :=
mod[ GF2<X> / X**8 + X**4 + X**3 + X + 1 ];
typedef S
:= matrix[4,4] of GF2N;
def mix : matrix[4,4] of GF2N
{[X], [X+1],[1], [1],
[1], [X], [X+1],[1],
[1], [1], [X], [X+1],
[X+1],[1], [1], [X]};

:=

def MixColumns( s : S ) : S {
def r : S;
seq i := 0 to 3 {
r[0..3,i] := mix * s[0..3,i]; }
return r; }
Limitations of CAO

In CAO all type sizes have to be statically determined
In the previous example, the MixColumns function only
works with 4 × 4 matrices
We would like to allow parametrisation of these sizes. For
instance:
typedef S<(n : int)> := matrix[n,n] of GF2N;
def MixColumns<(n : int)>( s : S<(n)> ) : S<(n)> {
def r : S<(n)>;
seq i := 0 to n-1 {
r[0..n,i] := mix * s[0..n,i]; }
return r; }
Dependent types
A dependent type depends on a value belonging to the
realm of program expressions
Can be seen as families of types indexed by values
In polymorphism, the type depends on another type
parameter, e.g.,
∀ α ∈ types . Vector of α
leading to vectors of integers, vectors of booleans, etc.
Using dependent types, the type depends on a value, e.g.,
Π n : Int . Vector[n]
leading to vectors of length 5, vectors of length 13, etc.
Dependent types
Dependent types allow for specification of program
properties in types, reducing verification of correctness to
type checking
Implementation and specification are kept synchronized
However, type checking of programs using full-fledge
dependent types is not decidable and cannot be done
automatically
To overcome this problem, is is necessary to limit their
expressive power reducing the amount of verifiable
properties
Most existing work is theoretical or in the context of
functional languages
CALF Language

CALF is a higher-level extension of the CAO language,
additionally providing:
Dependent types
Higher-order polymorphic operators (map, fold, and
zip-with)
User-defined parametric data types
Explicit constant definitions
Module system (allowing module instantiation)
CALF Language

The CALF compiler translates CALF source code to CAO
CALF programs are like templates which can be
instantiated with concrete values, leading to multiple CAO
programs
Dependent types allow for verifying some important
properties, without requiring code annotations or deductive
tools, directly in the generic CALF code
For instance, this allows for detecting many out-of-bounds
accesses in vectors, matrices or bit strings
The translation guarantees the safety properties
Dependent types in CALF
CALF has three different kinds of variable-like identifiers:
Language variables
Constants
Index variables

All variable-like identifiers have to be explicitly declared
with their respective type (type inference may be
considered in the future)
Index variables allow the introduction of dependent types
These are variables which can be used, not only in type
declarations, but also in program expressions
In the scope of their declaration, they are treated as
constants
They can be instantiated with any value of their domain
type
Type Expression Evaluation and Type Equality

The implementation of dependent types poses two key
questions:
How to deal with type expressions which are not known at
compile time?
How to define equality, since we cannot rely on syntactic
equality any more?

CALF evaluation mechanism deals with type expressions
that either evaluate to a value or to an expression
depending solely on index variables
Type equality is defined in evaluated type expressions,
possibly generating additional constraints
Type Equality Decision

Two approaches are used to solve generated constraints to
decide equality:
Syntactic manipulation of the constraint expressions
A Satisfiability Modulo Theories (SMT) solver

In our approach, two index variables are equal if and only if
they have the same symbolic value
Some additional restrictions (not discussed here) are
imposed in order to guarantee a less complex
implementation while maintaining the expressive power
In practice, we often need unification and substitution
instead of equality
Safety conditions

Sometimes the constraints cannot be verified although the
program is correct
Given a set of constraints, we have three possible results:
The constraints are satisfied — The code is safe
The exists one value for which the constraints are not
satisfied — The code is not safe
It is not possible to decide if the constraints are satisfied —
Unknown case

In the last case, the result is set by the user: succeed,
issue a warning or fail
Translation from CALF to CAO

The translation requires two files:
CALF source file Definition of data types, constants and
function
Specification file Concrete instantiations for the global
index variables
When modules are used, the import declarations have to
be checked and processed accordingly
Translation from CALF to CAO

The process occurs in three phases:
1
2

3

The CALF source file is type checked
The specification file is type checked against the
information collected during the previous phase. A list of
substitutions is returned with the required instantiations.
This list of substitutions is used to generate the output CAO
source. This requires collecting all dependencies between
functions and types

Several instances of the same function or data type may
be generated
CALF Example
RSA fragment

typedef RSAPub<(m : int)>
:=
struct [ def encExp : int; ];
typedef RSAPrivShort<(m : int)> :=
struct [ def decExp : int; ];
def RSA<(n : int)>(k : RSAPub<(n)>, m : int ) : int {
def c : mod[n];
c := (mod[n]) m; c := c ** k.encExp;
return (int) c;
}
def RSAInvShort<(n : int)>
(k : RSAPrivShort<(n)>, c : int) : int {
def m : mod[n];
m := (mod[n]) c;
return (int) m;
}

m := m ** k.decExp;
CALF Example
RSA fragment

def const pq : int;
def const d : int;
def const e : int;
def x : int;
def y : int;
def myPub : RSAPub<(pq)>;
def myPriv : RSAPrivShort<(pq)>;
def Calc() : void {
myPub.encExp := e;
y := RSA<(pq)>(myPub,x);
}
CALF Example
Specification file

def const pq : int := 35;
def const d : int := 11;
def const e : int := 11;
CALF Example
Generated CAO code

typedef RSAPub_35 := struct[def encExp_35 : int;];
def RSA_35(k : RSAPub_35, m : int) : int {
def c : mod[35];
c := (mod[35]) m;
c := c ** k.encExp_35;
return (int) c;
}
def myPub : RSAPub_35;
def x : int;
def y : int;
def Calc() : void {
myPub.encExp_35 := 11;
y := RSA_35(myPub, x);
}
The Overall Picture
Ongoing Work

Introducing explicit constraints in index variables (very
important for practical usage)
Improving the generation and solving of constraints in
iterative statements
Improving the module system (object oriented?)
Publication of results

More Related Content

What's hot

DISE - Programming Concepts
DISE - Programming ConceptsDISE - Programming Concepts
DISE - Programming Concepts
Rasan Samarasinghe
 
Unit 2 Principles of Programming Languages
Unit 2 Principles of Programming LanguagesUnit 2 Principles of Programming Languages
Unit 2 Principles of Programming LanguagesVasavi College of Engg
 
Subprogram
SubprogramSubprogram
Subprogram
baran19901990
 
Unit 3 principles of programming language
Unit 3 principles of programming languageUnit 3 principles of programming language
Unit 3 principles of programming languageVasavi College of Engg
 
OOP Poster Presentation
OOP Poster PresentationOOP Poster Presentation
OOP Poster Presentation
Md Mofijul Haque
 
Structure of the compiler
Structure of the compilerStructure of the compiler
Structure of the compiler
Sudhaa Ravi
 
FPL -Part 2 ( Sem - I 2013)
FPL -Part 2 ( Sem - I 2013)FPL -Part 2 ( Sem - I 2013)
FPL -Part 2 ( Sem - I 2013)Yogesh Deshpande
 
Procedural programming
Procedural programmingProcedural programming
Procedural programming
Anbarasan Gangadaran
 
Unit1 principle of programming language
Unit1 principle of programming languageUnit1 principle of programming language
Unit1 principle of programming languageVasavi College of Engg
 
Different phases of a compiler
Different phases of a compilerDifferent phases of a compiler
Different phases of a compiler
Sumit Sinha
 
Introduction to Procedural Programming in C++
Introduction to Procedural Programming in C++Introduction to Procedural Programming in C++
Introduction to Procedural Programming in C++
Salahaddin University-Erbil
 
phases of compiler-analysis phase
phases of compiler-analysis phasephases of compiler-analysis phase
phases of compiler-analysis phase
Suyash Srivastava
 
Programming In C++
Programming In C++ Programming In C++
Programming In C++
shammi mehra
 
Problem solving methodology
Problem solving methodologyProblem solving methodology
Problem solving methodology
Prof. Dr. K. Adisesha
 
1 compiler outline
1 compiler outline1 compiler outline
1 compiler outline
ASHOK KUMAR REDDY
 
CProgrammingTutorial
CProgrammingTutorialCProgrammingTutorial
CProgrammingTutorial
Muthuselvam RS
 

What's hot (20)

DISE - Programming Concepts
DISE - Programming ConceptsDISE - Programming Concepts
DISE - Programming Concepts
 
Unit 2 Principles of Programming Languages
Unit 2 Principles of Programming LanguagesUnit 2 Principles of Programming Languages
Unit 2 Principles of Programming Languages
 
Subprogram
SubprogramSubprogram
Subprogram
 
Unit 3 principles of programming language
Unit 3 principles of programming languageUnit 3 principles of programming language
Unit 3 principles of programming language
 
OOP Poster Presentation
OOP Poster PresentationOOP Poster Presentation
OOP Poster Presentation
 
Structure of the compiler
Structure of the compilerStructure of the compiler
Structure of the compiler
 
FPL -Part 2 ( Sem - I 2013)
FPL -Part 2 ( Sem - I 2013)FPL -Part 2 ( Sem - I 2013)
FPL -Part 2 ( Sem - I 2013)
 
Procedural programming
Procedural programmingProcedural programming
Procedural programming
 
Mit gnu scheme reference manual
Mit gnu scheme reference manualMit gnu scheme reference manual
Mit gnu scheme reference manual
 
Unit1 principle of programming language
Unit1 principle of programming languageUnit1 principle of programming language
Unit1 principle of programming language
 
Analysis of the source program
Analysis of the source programAnalysis of the source program
Analysis of the source program
 
Different phases of a compiler
Different phases of a compilerDifferent phases of a compiler
Different phases of a compiler
 
Introduction to Procedural Programming in C++
Introduction to Procedural Programming in C++Introduction to Procedural Programming in C++
Introduction to Procedural Programming in C++
 
C# chap 4
C# chap 4C# chap 4
C# chap 4
 
phases of compiler-analysis phase
phases of compiler-analysis phasephases of compiler-analysis phase
phases of compiler-analysis phase
 
Programming In C++
Programming In C++ Programming In C++
Programming In C++
 
Compiler1
Compiler1Compiler1
Compiler1
 
Problem solving methodology
Problem solving methodologyProblem solving methodology
Problem solving methodology
 
1 compiler outline
1 compiler outline1 compiler outline
1 compiler outline
 
CProgrammingTutorial
CProgrammingTutorialCProgrammingTutorial
CProgrammingTutorial
 

Similar to Dependent Types for Cryptography Implementations

Porcorn tutorial
Porcorn tutorialPorcorn tutorial
Parameter Validation for Software Reliability
Parameter Validation for Software ReliabilityParameter Validation for Software Reliability
Parameter Validation for Software Reliability
Glen Alleman
 
Chapter 5( programming) answer
Chapter 5( programming) answerChapter 5( programming) answer
Chapter 5( programming) answersmkengkilili2011
 
c#.pptx
c#.pptxc#.pptx
Introduction to Compilers
Introduction to CompilersIntroduction to Compilers
Introduction to Compilers
vijaya603274
 
Switch case and looping statement
Switch case and looping statementSwitch case and looping statement
Switch case and looping statement_jenica
 
Introduction to C Programming - I
Introduction to C Programming - I Introduction to C Programming - I
Introduction to C Programming - I
vampugani
 
Prgramming paradigms
Prgramming paradigmsPrgramming paradigms
Prgramming paradigms
Anirudh Chauhan
 
X++ 1.pptx
X++ 1.pptxX++ 1.pptx
X++ 1.pptx
Vijay Shukla
 
Introduction to ‘C’ Language
Introduction to ‘C’ LanguageIntroduction to ‘C’ Language
Introduction to ‘C’ Language
Thesis Scientist Private Limited
 
Asp.net main
Asp.net mainAsp.net main
Asp.net main
YogeshDhamke2
 
Language design and translation issues
Language design and translation issuesLanguage design and translation issues
Language design and translation issues
SURBHI SAROHA
 
Unit 1
Unit  1Unit  1
Unit 1
donny101
 
Principles of Compiler Design - Introduction
Principles of Compiler Design - IntroductionPrinciples of Compiler Design - Introduction
Principles of Compiler Design - Introduction
sheelarajasekar205
 
Unit 1 question and answer
Unit 1 question and answerUnit 1 question and answer
Unit 1 question and answer
Vasuki Ramasamy
 
CSE 1201: Structured Programming Language
CSE 1201: Structured Programming LanguageCSE 1201: Structured Programming Language
CSE 1201: Structured Programming Language
Zubayer Farazi
 
ml mini project (1).pptx
ml mini project (1).pptxml mini project (1).pptx
ml mini project (1).pptx
SyedjawedAlijaffer
 

Similar to Dependent Types for Cryptography Implementations (20)

Porcorn tutorial
Porcorn tutorialPorcorn tutorial
Porcorn tutorial
 
Parameter Validation for Software Reliability
Parameter Validation for Software ReliabilityParameter Validation for Software Reliability
Parameter Validation for Software Reliability
 
Chapter 5( programming) answer
Chapter 5( programming) answerChapter 5( programming) answer
Chapter 5( programming) answer
 
c#.pptx
c#.pptxc#.pptx
c#.pptx
 
Introduction to Visual Basic
Introduction to Visual Basic Introduction to Visual Basic
Introduction to Visual Basic
 
Introduction to Compilers
Introduction to CompilersIntroduction to Compilers
Introduction to Compilers
 
Training 8051Report
Training 8051ReportTraining 8051Report
Training 8051Report
 
Switch case and looping statement
Switch case and looping statementSwitch case and looping statement
Switch case and looping statement
 
Introduction to C Programming - I
Introduction to C Programming - I Introduction to C Programming - I
Introduction to C Programming - I
 
Prgramming paradigms
Prgramming paradigmsPrgramming paradigms
Prgramming paradigms
 
X++ 1.pptx
X++ 1.pptxX++ 1.pptx
X++ 1.pptx
 
Introduction to ‘C’ Language
Introduction to ‘C’ LanguageIntroduction to ‘C’ Language
Introduction to ‘C’ Language
 
Asp.net main
Asp.net mainAsp.net main
Asp.net main
 
Language design and translation issues
Language design and translation issuesLanguage design and translation issues
Language design and translation issues
 
Pc module1
Pc module1Pc module1
Pc module1
 
Unit 1
Unit  1Unit  1
Unit 1
 
Principles of Compiler Design - Introduction
Principles of Compiler Design - IntroductionPrinciples of Compiler Design - Introduction
Principles of Compiler Design - Introduction
 
Unit 1 question and answer
Unit 1 question and answerUnit 1 question and answer
Unit 1 question and answer
 
CSE 1201: Structured Programming Language
CSE 1201: Structured Programming LanguageCSE 1201: Structured Programming Language
CSE 1201: Structured Programming Language
 
ml mini project (1).pptx
ml mini project (1).pptxml mini project (1).pptx
ml mini project (1).pptx
 

More from Paulo Silva

Compiling CAO: From Cryptographic Specifications to C Implementations
Compiling CAO: From Cryptographic Specifications to C ImplementationsCompiling CAO: From Cryptographic Specifications to C Implementations
Compiling CAO: From Cryptographic Specifications to C Implementations
Paulo Silva
 
Galois: A Language for Proofs Using Galois Connections and Fork Algebras
Galois: A Language for Proofs Using Galois Connections and Fork AlgebrasGalois: A Language for Proofs Using Galois Connections and Fork Algebras
Galois: A Language for Proofs Using Galois Connections and Fork Algebras
Paulo Silva
 
On the Design of a Galculator
On the Design of a GalculatorOn the Design of a Galculator
On the Design of a Galculator
Paulo Silva
 
Galculator: Functional Prototype of a Galois-connection Based Proof Assistant
Galculator: Functional Prototype of a Galois-connection Based Proof AssistantGalculator: Functional Prototype of a Galois-connection Based Proof Assistant
Galculator: Functional Prototype of a Galois-connection Based Proof Assistant
Paulo Silva
 
On the Design of a Galculator
On the Design of a GalculatorOn the Design of a Galculator
On the Design of a Galculator
Paulo Silva
 
Machine Assisted Verification Tools for Cryptography
Machine Assisted Verification Tools for CryptographyMachine Assisted Verification Tools for Cryptography
Machine Assisted Verification Tools for Cryptography
Paulo Silva
 

More from Paulo Silva (6)

Compiling CAO: From Cryptographic Specifications to C Implementations
Compiling CAO: From Cryptographic Specifications to C ImplementationsCompiling CAO: From Cryptographic Specifications to C Implementations
Compiling CAO: From Cryptographic Specifications to C Implementations
 
Galois: A Language for Proofs Using Galois Connections and Fork Algebras
Galois: A Language for Proofs Using Galois Connections and Fork AlgebrasGalois: A Language for Proofs Using Galois Connections and Fork Algebras
Galois: A Language for Proofs Using Galois Connections and Fork Algebras
 
On the Design of a Galculator
On the Design of a GalculatorOn the Design of a Galculator
On the Design of a Galculator
 
Galculator: Functional Prototype of a Galois-connection Based Proof Assistant
Galculator: Functional Prototype of a Galois-connection Based Proof AssistantGalculator: Functional Prototype of a Galois-connection Based Proof Assistant
Galculator: Functional Prototype of a Galois-connection Based Proof Assistant
 
On the Design of a Galculator
On the Design of a GalculatorOn the Design of a Galculator
On the Design of a Galculator
 
Machine Assisted Verification Tools for Cryptography
Machine Assisted Verification Tools for CryptographyMachine Assisted Verification Tools for Cryptography
Machine Assisted Verification Tools for Cryptography
 

Recently uploaded

20240605 QFM017 Machine Intelligence Reading List May 2024
20240605 QFM017 Machine Intelligence Reading List May 202420240605 QFM017 Machine Intelligence Reading List May 2024
20240605 QFM017 Machine Intelligence Reading List May 2024
Matthew Sinclair
 
Pushing the limits of ePRTC: 100ns holdover for 100 days
Pushing the limits of ePRTC: 100ns holdover for 100 daysPushing the limits of ePRTC: 100ns holdover for 100 days
Pushing the limits of ePRTC: 100ns holdover for 100 days
Adtran
 
zkStudyClub - Reef: Fast Succinct Non-Interactive Zero-Knowledge Regex Proofs
zkStudyClub - Reef: Fast Succinct Non-Interactive Zero-Knowledge Regex ProofszkStudyClub - Reef: Fast Succinct Non-Interactive Zero-Knowledge Regex Proofs
zkStudyClub - Reef: Fast Succinct Non-Interactive Zero-Knowledge Regex Proofs
Alex Pruden
 
Observability Concepts EVERY Developer Should Know -- DeveloperWeek Europe.pdf
Observability Concepts EVERY Developer Should Know -- DeveloperWeek Europe.pdfObservability Concepts EVERY Developer Should Know -- DeveloperWeek Europe.pdf
Observability Concepts EVERY Developer Should Know -- DeveloperWeek Europe.pdf
Paige Cruz
 
Essentials of Automations: The Art of Triggers and Actions in FME
Essentials of Automations: The Art of Triggers and Actions in FMEEssentials of Automations: The Art of Triggers and Actions in FME
Essentials of Automations: The Art of Triggers and Actions in FME
Safe Software
 
Removing Uninteresting Bytes in Software Fuzzing
Removing Uninteresting Bytes in Software FuzzingRemoving Uninteresting Bytes in Software Fuzzing
Removing Uninteresting Bytes in Software Fuzzing
Aftab Hussain
 
National Security Agency - NSA mobile device best practices
National Security Agency - NSA mobile device best practicesNational Security Agency - NSA mobile device best practices
National Security Agency - NSA mobile device best practices
Quotidiano Piemontese
 
20240607 QFM018 Elixir Reading List May 2024
20240607 QFM018 Elixir Reading List May 202420240607 QFM018 Elixir Reading List May 2024
20240607 QFM018 Elixir Reading List May 2024
Matthew Sinclair
 
GridMate - End to end testing is a critical piece to ensure quality and avoid...
GridMate - End to end testing is a critical piece to ensure quality and avoid...GridMate - End to end testing is a critical piece to ensure quality and avoid...
GridMate - End to end testing is a critical piece to ensure quality and avoid...
ThomasParaiso2
 
Communications Mining Series - Zero to Hero - Session 1
Communications Mining Series - Zero to Hero - Session 1Communications Mining Series - Zero to Hero - Session 1
Communications Mining Series - Zero to Hero - Session 1
DianaGray10
 
GraphSummit Singapore | Neo4j Product Vision & Roadmap - Q2 2024
GraphSummit Singapore | Neo4j Product Vision & Roadmap - Q2 2024GraphSummit Singapore | Neo4j Product Vision & Roadmap - Q2 2024
GraphSummit Singapore | Neo4j Product Vision & Roadmap - Q2 2024
Neo4j
 
Enchancing adoption of Open Source Libraries. A case study on Albumentations.AI
Enchancing adoption of Open Source Libraries. A case study on Albumentations.AIEnchancing adoption of Open Source Libraries. A case study on Albumentations.AI
Enchancing adoption of Open Source Libraries. A case study on Albumentations.AI
Vladimir Iglovikov, Ph.D.
 
RESUME BUILDER APPLICATION Project for students
RESUME BUILDER APPLICATION Project for studentsRESUME BUILDER APPLICATION Project for students
RESUME BUILDER APPLICATION Project for students
KAMESHS29
 
Video Streaming: Then, Now, and in the Future
Video Streaming: Then, Now, and in the FutureVideo Streaming: Then, Now, and in the Future
Video Streaming: Then, Now, and in the Future
Alpen-Adria-Universität
 
FIDO Alliance Osaka Seminar: The WebAuthn API and Discoverable Credentials.pdf
FIDO Alliance Osaka Seminar: The WebAuthn API and Discoverable Credentials.pdfFIDO Alliance Osaka Seminar: The WebAuthn API and Discoverable Credentials.pdf
FIDO Alliance Osaka Seminar: The WebAuthn API and Discoverable Credentials.pdf
FIDO Alliance
 
Microsoft - Power Platform_G.Aspiotis.pdf
Microsoft - Power Platform_G.Aspiotis.pdfMicrosoft - Power Platform_G.Aspiotis.pdf
Microsoft - Power Platform_G.Aspiotis.pdf
Uni Systems S.M.S.A.
 
Introduction to CHERI technology - Cybersecurity
Introduction to CHERI technology - CybersecurityIntroduction to CHERI technology - Cybersecurity
Introduction to CHERI technology - Cybersecurity
mikeeftimakis1
 
UiPath Test Automation using UiPath Test Suite series, part 6
UiPath Test Automation using UiPath Test Suite series, part 6UiPath Test Automation using UiPath Test Suite series, part 6
UiPath Test Automation using UiPath Test Suite series, part 6
DianaGray10
 
LF Energy Webinar: Electrical Grid Modelling and Simulation Through PowSyBl -...
LF Energy Webinar: Electrical Grid Modelling and Simulation Through PowSyBl -...LF Energy Webinar: Electrical Grid Modelling and Simulation Through PowSyBl -...
LF Energy Webinar: Electrical Grid Modelling and Simulation Through PowSyBl -...
DanBrown980551
 
GDG Cloud Southlake #33: Boule & Rebala: Effective AppSec in SDLC using Deplo...
GDG Cloud Southlake #33: Boule & Rebala: Effective AppSec in SDLC using Deplo...GDG Cloud Southlake #33: Boule & Rebala: Effective AppSec in SDLC using Deplo...
GDG Cloud Southlake #33: Boule & Rebala: Effective AppSec in SDLC using Deplo...
James Anderson
 

Recently uploaded (20)

20240605 QFM017 Machine Intelligence Reading List May 2024
20240605 QFM017 Machine Intelligence Reading List May 202420240605 QFM017 Machine Intelligence Reading List May 2024
20240605 QFM017 Machine Intelligence Reading List May 2024
 
Pushing the limits of ePRTC: 100ns holdover for 100 days
Pushing the limits of ePRTC: 100ns holdover for 100 daysPushing the limits of ePRTC: 100ns holdover for 100 days
Pushing the limits of ePRTC: 100ns holdover for 100 days
 
zkStudyClub - Reef: Fast Succinct Non-Interactive Zero-Knowledge Regex Proofs
zkStudyClub - Reef: Fast Succinct Non-Interactive Zero-Knowledge Regex ProofszkStudyClub - Reef: Fast Succinct Non-Interactive Zero-Knowledge Regex Proofs
zkStudyClub - Reef: Fast Succinct Non-Interactive Zero-Knowledge Regex Proofs
 
Observability Concepts EVERY Developer Should Know -- DeveloperWeek Europe.pdf
Observability Concepts EVERY Developer Should Know -- DeveloperWeek Europe.pdfObservability Concepts EVERY Developer Should Know -- DeveloperWeek Europe.pdf
Observability Concepts EVERY Developer Should Know -- DeveloperWeek Europe.pdf
 
Essentials of Automations: The Art of Triggers and Actions in FME
Essentials of Automations: The Art of Triggers and Actions in FMEEssentials of Automations: The Art of Triggers and Actions in FME
Essentials of Automations: The Art of Triggers and Actions in FME
 
Removing Uninteresting Bytes in Software Fuzzing
Removing Uninteresting Bytes in Software FuzzingRemoving Uninteresting Bytes in Software Fuzzing
Removing Uninteresting Bytes in Software Fuzzing
 
National Security Agency - NSA mobile device best practices
National Security Agency - NSA mobile device best practicesNational Security Agency - NSA mobile device best practices
National Security Agency - NSA mobile device best practices
 
20240607 QFM018 Elixir Reading List May 2024
20240607 QFM018 Elixir Reading List May 202420240607 QFM018 Elixir Reading List May 2024
20240607 QFM018 Elixir Reading List May 2024
 
GridMate - End to end testing is a critical piece to ensure quality and avoid...
GridMate - End to end testing is a critical piece to ensure quality and avoid...GridMate - End to end testing is a critical piece to ensure quality and avoid...
GridMate - End to end testing is a critical piece to ensure quality and avoid...
 
Communications Mining Series - Zero to Hero - Session 1
Communications Mining Series - Zero to Hero - Session 1Communications Mining Series - Zero to Hero - Session 1
Communications Mining Series - Zero to Hero - Session 1
 
GraphSummit Singapore | Neo4j Product Vision & Roadmap - Q2 2024
GraphSummit Singapore | Neo4j Product Vision & Roadmap - Q2 2024GraphSummit Singapore | Neo4j Product Vision & Roadmap - Q2 2024
GraphSummit Singapore | Neo4j Product Vision & Roadmap - Q2 2024
 
Enchancing adoption of Open Source Libraries. A case study on Albumentations.AI
Enchancing adoption of Open Source Libraries. A case study on Albumentations.AIEnchancing adoption of Open Source Libraries. A case study on Albumentations.AI
Enchancing adoption of Open Source Libraries. A case study on Albumentations.AI
 
RESUME BUILDER APPLICATION Project for students
RESUME BUILDER APPLICATION Project for studentsRESUME BUILDER APPLICATION Project for students
RESUME BUILDER APPLICATION Project for students
 
Video Streaming: Then, Now, and in the Future
Video Streaming: Then, Now, and in the FutureVideo Streaming: Then, Now, and in the Future
Video Streaming: Then, Now, and in the Future
 
FIDO Alliance Osaka Seminar: The WebAuthn API and Discoverable Credentials.pdf
FIDO Alliance Osaka Seminar: The WebAuthn API and Discoverable Credentials.pdfFIDO Alliance Osaka Seminar: The WebAuthn API and Discoverable Credentials.pdf
FIDO Alliance Osaka Seminar: The WebAuthn API and Discoverable Credentials.pdf
 
Microsoft - Power Platform_G.Aspiotis.pdf
Microsoft - Power Platform_G.Aspiotis.pdfMicrosoft - Power Platform_G.Aspiotis.pdf
Microsoft - Power Platform_G.Aspiotis.pdf
 
Introduction to CHERI technology - Cybersecurity
Introduction to CHERI technology - CybersecurityIntroduction to CHERI technology - Cybersecurity
Introduction to CHERI technology - Cybersecurity
 
UiPath Test Automation using UiPath Test Suite series, part 6
UiPath Test Automation using UiPath Test Suite series, part 6UiPath Test Automation using UiPath Test Suite series, part 6
UiPath Test Automation using UiPath Test Suite series, part 6
 
LF Energy Webinar: Electrical Grid Modelling and Simulation Through PowSyBl -...
LF Energy Webinar: Electrical Grid Modelling and Simulation Through PowSyBl -...LF Energy Webinar: Electrical Grid Modelling and Simulation Through PowSyBl -...
LF Energy Webinar: Electrical Grid Modelling and Simulation Through PowSyBl -...
 
GDG Cloud Southlake #33: Boule & Rebala: Effective AppSec in SDLC using Deplo...
GDG Cloud Southlake #33: Boule & Rebala: Effective AppSec in SDLC using Deplo...GDG Cloud Southlake #33: Boule & Rebala: Effective AppSec in SDLC using Deplo...
GDG Cloud Southlake #33: Boule & Rebala: Effective AppSec in SDLC using Deplo...
 

Dependent Types for Cryptography Implementations

  • 1. Dependent Types For Cryptography Implementations Paulo Silva Manuel Barbosa HASLab, Departamento de Informática Universidade do Minho Portugal June 14, 2011
  • 2. Motivation Cryptographic software demands high-quality implementations The CAO language was developed close to cryptographic standards making the implementation easier and more reliable This language is strongly typed with explicit type sizes Improves safety but makes it less general and usable Proposed solution: dependent types ⇒ CALF language
  • 3. CAO Language Small and simple domain specific language with imperative flavour Geared toward the automatic production of highly efficient target code subject to security-aware optimizations Type system supports cryptography types such as bit strings, matrices and field extensions CAO has a complete formalization of its: Syntax Semantics Type system We have proved that CAO type system is sound, i.e., “well-typed programs do not go wrong” A fully functional CAO interpreter is also available
  • 4. CAO Example AES fragment typedef GF2 := mod[ 2 ]; typedef GF2N := mod[ GF2<X> / X**8 + X**4 + X**3 + X + 1 ]; typedef S := matrix[4,4] of GF2N; def mix : matrix[4,4] of GF2N {[X], [X+1],[1], [1], [1], [X], [X+1],[1], [1], [1], [X], [X+1], [X+1],[1], [1], [X]}; := def MixColumns( s : S ) : S { def r : S; seq i := 0 to 3 { r[0..3,i] := mix * s[0..3,i]; } return r; }
  • 5. Limitations of CAO In CAO all type sizes have to be statically determined In the previous example, the MixColumns function only works with 4 × 4 matrices We would like to allow parametrisation of these sizes. For instance: typedef S<(n : int)> := matrix[n,n] of GF2N; def MixColumns<(n : int)>( s : S<(n)> ) : S<(n)> { def r : S<(n)>; seq i := 0 to n-1 { r[0..n,i] := mix * s[0..n,i]; } return r; }
  • 6. Dependent types A dependent type depends on a value belonging to the realm of program expressions Can be seen as families of types indexed by values In polymorphism, the type depends on another type parameter, e.g., ∀ α ∈ types . Vector of α leading to vectors of integers, vectors of booleans, etc. Using dependent types, the type depends on a value, e.g., Π n : Int . Vector[n] leading to vectors of length 5, vectors of length 13, etc.
  • 7. Dependent types Dependent types allow for specification of program properties in types, reducing verification of correctness to type checking Implementation and specification are kept synchronized However, type checking of programs using full-fledge dependent types is not decidable and cannot be done automatically To overcome this problem, is is necessary to limit their expressive power reducing the amount of verifiable properties Most existing work is theoretical or in the context of functional languages
  • 8. CALF Language CALF is a higher-level extension of the CAO language, additionally providing: Dependent types Higher-order polymorphic operators (map, fold, and zip-with) User-defined parametric data types Explicit constant definitions Module system (allowing module instantiation)
  • 9. CALF Language The CALF compiler translates CALF source code to CAO CALF programs are like templates which can be instantiated with concrete values, leading to multiple CAO programs Dependent types allow for verifying some important properties, without requiring code annotations or deductive tools, directly in the generic CALF code For instance, this allows for detecting many out-of-bounds accesses in vectors, matrices or bit strings The translation guarantees the safety properties
  • 10. Dependent types in CALF CALF has three different kinds of variable-like identifiers: Language variables Constants Index variables All variable-like identifiers have to be explicitly declared with their respective type (type inference may be considered in the future) Index variables allow the introduction of dependent types These are variables which can be used, not only in type declarations, but also in program expressions In the scope of their declaration, they are treated as constants They can be instantiated with any value of their domain type
  • 11. Type Expression Evaluation and Type Equality The implementation of dependent types poses two key questions: How to deal with type expressions which are not known at compile time? How to define equality, since we cannot rely on syntactic equality any more? CALF evaluation mechanism deals with type expressions that either evaluate to a value or to an expression depending solely on index variables Type equality is defined in evaluated type expressions, possibly generating additional constraints
  • 12. Type Equality Decision Two approaches are used to solve generated constraints to decide equality: Syntactic manipulation of the constraint expressions A Satisfiability Modulo Theories (SMT) solver In our approach, two index variables are equal if and only if they have the same symbolic value Some additional restrictions (not discussed here) are imposed in order to guarantee a less complex implementation while maintaining the expressive power In practice, we often need unification and substitution instead of equality
  • 13. Safety conditions Sometimes the constraints cannot be verified although the program is correct Given a set of constraints, we have three possible results: The constraints are satisfied — The code is safe The exists one value for which the constraints are not satisfied — The code is not safe It is not possible to decide if the constraints are satisfied — Unknown case In the last case, the result is set by the user: succeed, issue a warning or fail
  • 14. Translation from CALF to CAO The translation requires two files: CALF source file Definition of data types, constants and function Specification file Concrete instantiations for the global index variables When modules are used, the import declarations have to be checked and processed accordingly
  • 15. Translation from CALF to CAO The process occurs in three phases: 1 2 3 The CALF source file is type checked The specification file is type checked against the information collected during the previous phase. A list of substitutions is returned with the required instantiations. This list of substitutions is used to generate the output CAO source. This requires collecting all dependencies between functions and types Several instances of the same function or data type may be generated
  • 16. CALF Example RSA fragment typedef RSAPub<(m : int)> := struct [ def encExp : int; ]; typedef RSAPrivShort<(m : int)> := struct [ def decExp : int; ]; def RSA<(n : int)>(k : RSAPub<(n)>, m : int ) : int { def c : mod[n]; c := (mod[n]) m; c := c ** k.encExp; return (int) c; } def RSAInvShort<(n : int)> (k : RSAPrivShort<(n)>, c : int) : int { def m : mod[n]; m := (mod[n]) c; return (int) m; } m := m ** k.decExp;
  • 17. CALF Example RSA fragment def const pq : int; def const d : int; def const e : int; def x : int; def y : int; def myPub : RSAPub<(pq)>; def myPriv : RSAPrivShort<(pq)>; def Calc() : void { myPub.encExp := e; y := RSA<(pq)>(myPub,x); }
  • 18. CALF Example Specification file def const pq : int := 35; def const d : int := 11; def const e : int := 11;
  • 19. CALF Example Generated CAO code typedef RSAPub_35 := struct[def encExp_35 : int;]; def RSA_35(k : RSAPub_35, m : int) : int { def c : mod[35]; c := (mod[35]) m; c := c ** k.encExp_35; return (int) c; } def myPub : RSAPub_35; def x : int; def y : int; def Calc() : void { myPub.encExp_35 := 11; y := RSA_35(myPub, x); }
  • 21. Ongoing Work Introducing explicit constraints in index variables (very important for practical usage) Improving the generation and solving of constraints in iterative statements Improving the module system (object oriented?) Publication of results