From: Ummon Date: Wed, 26 Nov 2014 12:29:44 +0000 (+0100) Subject: Put the API in an seperate library assembly and create an assembly for testing. X-Git-Url: http://git.euphorik.ch/?p=crypto_lab2.git;a=commitdiff_plain;h=beda8d83dc421c479bdcf5ee626ec85ee8555a80 Put the API in an seperate library assembly and create an assembly for testing. --- diff --git a/icr14_lab_02.pdf b/icr14_lab_02.pdf deleted file mode 100644 index 5095cb7..0000000 Binary files a/icr14_lab_02.pdf and /dev/null differ diff --git a/labo2-fsharp/CryptoFile/API.fs b/labo2-fsharp/CryptoFile/API.fs new file mode 100644 index 0000000..2cf2167 --- /dev/null +++ b/labo2-fsharp/CryptoFile/API.fs @@ -0,0 +1,45 @@ +namespace CryptoFile +open System.IO + +type internal Metadata (d : (string * string) list) = + new (stream : Stream, size: int) = + let binaryReader = new BinaryReader (stream) + new Metadata ([]) + member this.WriteTo (stream : Stream) = + let binaryWriter = new BinaryWriter (stream) + List.iter (fun (key : string, value : string) -> binaryWriter.Write key; binaryWriter.Write value) d + +module API = + let internal filename = "filename" + let internal creationTimeKey = "file-creation-time" + + let generatKeysPair : Key * Key = Crypto.generateRSAKeysPair + + let encryptFile (inputFilePath : string) (outputFilePath : string) (signaturePrivKey: Key) (cryptPubKey : Key) = + let keyAES, keyMAC, iv = Crypto.rand 32, Crypto.rand 32, Crypto.rand 16 + let fileInfo = new FileInfo (inputFilePath) + use inputStream = new FileStream (inputFilePath, FileMode.Open, FileAccess.Read) + use outputStream = new FileStream (outputFilePath, FileMode.Create, FileAccess.Write) + let writer = new BinaryWriter (outputStream) + + ignore <| writer.Seek (8 + 32 + 256, SeekOrigin.Current) // Skips file-content-size, mac and signature. They will be written later. + + Crypto.encryptRSA cryptPubKey (Array.append keyAES <| Array.append keyMAC iv) |> writer.Write + + printfn "pos: %A" outputStream.Position + + use cryptoStream = Crypto.encryptAES keyAES iv outputStream + let cryptoWriter = new BinaryWriter (cryptoStream) + + // Write metadata. + let metaData = new Metadata ([filename, fileInfo.Name; creationTimeKey, fileInfo.CreationTimeUtc.Ticks.ToString ()]) + let metaDataStream = new MemoryStream () + metaData.WriteTo metaDataStream + cryptoWriter.Write (int metaDataStream.Length) + printfn "meta size: %A" (int metaDataStream.Length) + metaDataStream.Position <- 0L + metaDataStream.CopyTo cryptoStream + () + + let decryptFile (sourceFilePath : string) (targetDirPath : string) (signaturePubKey: Key) (decryptPrivKey : Key) = + () diff --git a/labo2-fsharp/CryptoFile/AssemblyInfo.fs b/labo2-fsharp/CryptoFile/AssemblyInfo.fs new file mode 100644 index 0000000..c7754e5 --- /dev/null +++ b/labo2-fsharp/CryptoFile/AssemblyInfo.fs @@ -0,0 +1,23 @@ +namespace CryptoFile + +module AssemblyInfo = + open System.Reflection + open System.Runtime.CompilerServices + + [] + [] + [] + [] + [] + [] + [] + + // The assembly version has the format {Major}.{Minor}.{Build}.{Revision} + + [] + + //[] + //[] + + () + diff --git a/labo2-fsharp/CryptoFile/Crypto.fs b/labo2-fsharp/CryptoFile/Crypto.fs new file mode 100644 index 0000000..34d54fa --- /dev/null +++ b/labo2-fsharp/CryptoFile/Crypto.fs @@ -0,0 +1,75 @@ +namespace CryptoFile + +// Some cryptography primitives specific to CryptoFile. +module internal Crypto = + open System.Security.Cryptography + open System.IO + + type Data = byte[] + + let rsaKeySize = 2048 + + /// Returns a cryptographically strong sequence of bytes. + let rand size : byte[] = + let result = Array.zeroCreate size + let generator = new RNGCryptoServiceProvider () + generator.GetBytes result + result + + /// Generate a new RSA key pair: (public * private). + let generateRSAKeysPair : Key * Key = + use rsa = new RSACryptoServiceProvider (rsaKeySize) + try + rsa.ToXmlString false, rsa.ToXmlString true + finally + rsa.PersistKeyInCsp <- false + + let encryptRSA (publicKey : Key) (plaindata : Data) : Data = + use rsa = new RSACryptoServiceProvider (rsaKeySize) + try + rsa.FromXmlString publicKey + rsa.Encrypt (plaindata, false) // Uses PKCS#1 v1.5 padding. + finally + rsa.PersistKeyInCsp <- false + + let decryptRSA (privateKey : Key) (cipherdata : Data) : Data = + use rsa = new RSACryptoServiceProvider (rsaKeySize) + try + rsa.FromXmlString privateKey + rsa.Decrypt (cipherdata, false) // Uses PKCS#1 v1.5 padding. + finally + rsa.PersistKeyInCsp <- false + + /// Produces a signature from a given hash. + let signRSA (privKey : Key) (sha256 : Data) : Data = + use rsa = new RSACryptoServiceProvider (rsaKeySize) + try + rsa.FromXmlString privKey + rsa.SignHash (sha256, CryptoConfig.MapNameToOID "SHA256") + finally + rsa.PersistKeyInCsp <- false + + /// Verify a signature against a given hash. + let verifySignRSA (pubKey : Key) (sha256 : Data) (signature : Data) : bool = + use rsa = new RSACryptoServiceProvider (rsaKeySize) + try + rsa.FromXmlString pubKey + rsa.VerifyHash (sha256, CryptoConfig.MapNameToOID "SHA256", signature) + finally + rsa.PersistKeyInCsp <- false + + /// Returns an encrypted output stream. + let encryptAES (key : byte[]) (iv : byte[]) (outputStream : Stream) : Stream = + assert (key.Length = 32 && iv.Length = 16) + use aes = new AesManaged () + aes.KeySize <- 256 + let encryptor = aes.CreateEncryptor (key, iv) + new CryptoStream (outputStream, encryptor, CryptoStreamMode.Write) :> Stream + + /// Returns a decrypted input stream. + let decryptAES (key : byte[]) (iv : byte[]) (inputStream : Stream) : Stream = + assert (key.Length = 32 && iv.Length = 16) + use aes = new AesManaged () + aes.KeySize <- 256 + let decryptor = aes.CreateDecryptor (key, iv) + new CryptoStream (inputStream, decryptor, CryptoStreamMode.Read) :> Stream diff --git a/labo2-fsharp/CryptoFile/CryptoFile.fsproj b/labo2-fsharp/CryptoFile/CryptoFile.fsproj new file mode 100644 index 0000000..0e0ea35 --- /dev/null +++ b/labo2-fsharp/CryptoFile/CryptoFile.fsproj @@ -0,0 +1,57 @@ + + + + Debug + x86 + {CDB168EA-04F9-4A8B-A3B4-27D9A6390269} + Library + CryptoFile + CryptoFile + v4.5 + + + true + full + bin\Debug + DEBUG + prompt + x86 + true + false + false + + + + + + tests + + + true + pdbonly + true + bin\Release + prompt + x86 + true + true + + + + + + + + + + + + + + + + + + + + \ No newline at end of file diff --git a/labo2-fsharp/CryptoFile/Tests.fs b/labo2-fsharp/CryptoFile/Tests.fs new file mode 100644 index 0000000..e1f933b --- /dev/null +++ b/labo2-fsharp/CryptoFile/Tests.fs @@ -0,0 +1,31 @@ +namespace CryptoFile + +module Tests = + open System.Text + open System.Security.Cryptography + open Crypto + + let testRSA () = + let kpub, kpriv = generateRSAKeysPair + let plaintext = "Hello, World!" + printfn "plaintext: %A" plaintext + let cipherdata = encryptRSA kpub (Encoding.UTF8.GetBytes plaintext) + printfn "cipherdata: (size: %A) %A" cipherdata.Length cipherdata + let decryptedData = decryptRSA kpriv cipherdata + let decryptedText = Encoding.UTF8.GetString decryptedData + printfn "decryptedtext: %A" decryptedText + assert (plaintext = decryptedText) + printfn "testRSA OK" + + let testRSASignature () = + let kpub, kpriv = generateRSAKeysPair + let plaintext = "Hello, World!" + let sha256 = new SHA256Managed () + let signature = signRSA kpriv (sha256.ComputeHash (Encoding.UTF8.GetBytes plaintext)) + assert verifySignRSA kpub (sha256.ComputeHash (Encoding.UTF8.GetBytes plaintext)) signature + assert not (verifySignRSA kpub (sha256.ComputeHash (Encoding.UTF8.GetBytes "Hello!")) signature) + printfn "testRSASignature OK" + + let runAllTests () = + testRSA () + testRSASignature () \ No newline at end of file diff --git a/labo2-fsharp/CryptoFile/Types.fs b/labo2-fsharp/CryptoFile/Types.fs new file mode 100644 index 0000000..67ccbc3 --- /dev/null +++ b/labo2-fsharp/CryptoFile/Types.fs @@ -0,0 +1,8 @@ +namespace CryptoFile + +type Key = string + +exception FileNotFound +exception IOError +exception SignatureMismatch +exception IntegrityError diff --git a/labo2-fsharp/CryptoFileTests/AssemblyInfo.fs b/labo2-fsharp/CryptoFileTests/AssemblyInfo.fs new file mode 100644 index 0000000..c54451e --- /dev/null +++ b/labo2-fsharp/CryptoFileTests/AssemblyInfo.fs @@ -0,0 +1,21 @@ +module CryptoFileTests.AssemblyInfo +open System.Reflection +open System.Runtime.CompilerServices + +[] +[] +[] +[] +[] +[] +[] + +// The assembly version has the format {Major}.{Minor}.{Build}.{Revision} + +[] + +//[] +//[] + +() + diff --git a/labo2-fsharp/CryptoFileTests/CryptoFileTests.fsproj b/labo2-fsharp/CryptoFileTests/CryptoFileTests.fsproj new file mode 100644 index 0000000..2f24211 --- /dev/null +++ b/labo2-fsharp/CryptoFileTests/CryptoFileTests.fsproj @@ -0,0 +1,52 @@ + + + + Debug + x86 + {FA5B9C91-036B-455C-892B-05A7FC398158} + Exe + CryptoFileTests + CryptoFileTests + v4.5 + + + true + full + false + bin\Debug + DEBUG + prompt + true + false + x86 + tests + + + false + none + true + bin\Release + prompt + x86 + true + true + + + + + + + + + + + + + + + + {CDB168EA-04F9-4A8B-A3B4-27D9A6390269} + CryptoFile + + + \ No newline at end of file diff --git a/labo2-fsharp/CryptoFileTests/Program.fs b/labo2-fsharp/CryptoFileTests/Program.fs new file mode 100644 index 0000000..cc70f97 --- /dev/null +++ b/labo2-fsharp/CryptoFileTests/Program.fs @@ -0,0 +1,24 @@ +module Labo2.Main + +open System +open CryptoFile + +let printUsage () = + printfn "%s [ tests | encrypt | decrypt ]\n\ + \ttests: Run some tests to valid the 'CryptoFile' assembly\n\ + \tencrypt: Encrypt a file to \n\ + \tdecrypt: Decrypt a file to " System.AppDomain.CurrentDomain.FriendlyName + +[] +let main args = + printfn "Labo n°2" + + let keySigPub, keySigPriv = API.generatKeysPair + let keyCryptPub, keyCryptPriv = API.generatKeysPair + + match args with + | [| "tests" |] -> Tests.runAllTests () + | [| "encrypt"; input; output |] -> API.encryptFile input output keySigPriv keyCryptPub + | [| "decrypt"; input; outputDir |] -> API.decryptFile input outputDir keySigPub keyCryptPriv + | _ -> printUsage () + 0 diff --git a/labo2-fsharp/CryptoFileTests/test.out b/labo2-fsharp/CryptoFileTests/test.out new file mode 100644 index 0000000..8f31261 Binary files /dev/null and b/labo2-fsharp/CryptoFileTests/test.out differ diff --git a/labo2-fsharp/CryptoFileTests/test.txt b/labo2-fsharp/CryptoFileTests/test.txt new file mode 100644 index 0000000..8318c86 --- /dev/null +++ b/labo2-fsharp/CryptoFileTests/test.txt @@ -0,0 +1 @@ +Test \ No newline at end of file diff --git a/labo2-fsharp/labo2-fsharp.sln b/labo2-fsharp/labo2-fsharp.sln index c1285dd..67206b5 100644 --- a/labo2-fsharp/labo2-fsharp.sln +++ b/labo2-fsharp/labo2-fsharp.sln @@ -1,7 +1,9 @@  Microsoft Visual Studio Solution File, Format Version 12.00 # Visual Studio 2012 -Project("{4925A630-B079-445d-BCD4-3A9C94FE9307}") = "labo2-fsharp", "labo2-fsharp\labo2-fsharp.fsproj", "{CDB168EA-04F9-4A8B-A3B4-27D9A6390269}" +Project("{f2a71f9b-5d33-465a-a702-920d77279786}") = "CryptoFileTests", "CryptoFileTests\CryptoFileTests.fsproj", "{FA5B9C91-036B-455C-892B-05A7FC398158}" +EndProject +Project("{f2a71f9b-5d33-465a-a702-920d77279786}") = "CryptoFile", "CryptoFile\CryptoFile.fsproj", "{CDB168EA-04F9-4A8B-A3B4-27D9A6390269}" EndProject Global GlobalSection(SolutionConfigurationPlatforms) = preSolution @@ -13,8 +15,12 @@ Global {CDB168EA-04F9-4A8B-A3B4-27D9A6390269}.Debug|x86.Build.0 = Debug|x86 {CDB168EA-04F9-4A8B-A3B4-27D9A6390269}.Release|x86.ActiveCfg = Release|x86 {CDB168EA-04F9-4A8B-A3B4-27D9A6390269}.Release|x86.Build.0 = Release|x86 + {FA5B9C91-036B-455C-892B-05A7FC398158}.Debug|x86.ActiveCfg = Debug|x86 + {FA5B9C91-036B-455C-892B-05A7FC398158}.Debug|x86.Build.0 = Debug|x86 + {FA5B9C91-036B-455C-892B-05A7FC398158}.Release|x86.ActiveCfg = Release|x86 + {FA5B9C91-036B-455C-892B-05A7FC398158}.Release|x86.Build.0 = Release|x86 EndGlobalSection GlobalSection(MonoDevelopProperties) = preSolution - StartupItem = labo2-fsharp\labo2-fsharp.fsproj + StartupItem = CryptoFileTests\CryptoFileTests.fsproj EndGlobalSection EndGlobal diff --git a/labo2-fsharp/labo2-fsharp.userprefs b/labo2-fsharp/labo2-fsharp.userprefs index f0b4897..8598d4a 100644 --- a/labo2-fsharp/labo2-fsharp.userprefs +++ b/labo2-fsharp/labo2-fsharp.userprefs @@ -1,10 +1,19 @@  - + - - + + + + + + + + + + + diff --git a/labo2-fsharp/labo2-fsharp/AssemblyInfo.fs b/labo2-fsharp/labo2-fsharp/AssemblyInfo.fs deleted file mode 100644 index 43c5dfa..0000000 --- a/labo2-fsharp/labo2-fsharp/AssemblyInfo.fs +++ /dev/null @@ -1,22 +0,0 @@ -module Labo2.AssemblyInfo -open System.Reflection -open System.Runtime.CompilerServices - - -[] -[] -[] -[] -[] -[] -[] - -// The assembly version has the format {Major}.{Minor}.{Build}.{Revision} - -[] - -//[] -//[] - -() - diff --git a/labo2-fsharp/labo2-fsharp/Crypto.fs b/labo2-fsharp/labo2-fsharp/Crypto.fs deleted file mode 100644 index d8377d1..0000000 --- a/labo2-fsharp/labo2-fsharp/Crypto.fs +++ /dev/null @@ -1,82 +0,0 @@ -module Labo2.Crypto - -open System.Security.Cryptography -open System.IO - -type Key = string -type Data = byte[] - -let rsaKeySize = 2048 - -let generate256Key : Key = - null - -/// Generate a new RSA key pair: (public * private). -let generateRSAKeysPair : Key * Key = - use rsa = new RSACryptoServiceProvider (rsaKeySize) - try - rsa.ToXmlString false, rsa.ToXmlString true - finally - rsa.PersistKeyInCsp <- false - -let encryptRSA (publicKey : Key) (plaindata : Data) : Data = - use rsa = new RSACryptoServiceProvider (rsaKeySize) - try - rsa.FromXmlString publicKey - rsa.Encrypt (plaindata, false) // Uses PKCS#1 v1.5 padding. - finally - rsa.PersistKeyInCsp <- false - -let decryptRSA (privateKey : Key) (cipherdata : Data) : Data = - use rsa = new RSACryptoServiceProvider (rsaKeySize) - try - rsa.FromXmlString privateKey - rsa.Decrypt (cipherdata, false) // Uses PKCS#1 v1.5 padding. - finally - rsa.PersistKeyInCsp <- false - -/// Produces a signature from a given hash. -let signRSA (privKey : Key) (sha256 : Data) : Data = - use rsa = new RSACryptoServiceProvider (rsaKeySize) - try - rsa.FromXmlString privKey - rsa.SignHash (sha256, CryptoConfig.MapNameToOID "SHA256") - finally - rsa.PersistKeyInCsp <- false - -/// Verify a signature against a given hash. -let verifySignRSA (pubKey : Key) (sha256 : Data) (signature : Data) : bool = - use rsa = new RSACryptoServiceProvider (rsaKeySize) - try - rsa.FromXmlString pubKey - rsa.VerifyHash (sha256, CryptoConfig.MapNameToOID "SHA256", signature) - finally - rsa.PersistKeyInCsp <- false - -let decryptAES (key : Key) (inputStream : Stream) (outputStream : Stream) = - () - -open System.Text - -let testRSA = lazy ( - let kpub, kpriv = generateRSAKeysPair - let plaintext = "Hello, World!" - printfn "plaintext: %A" plaintext - let cipherdata = encryptRSA kpub (Encoding.UTF8.GetBytes plaintext) - printfn "cipherdata: (size: %A) %A" cipherdata.Length cipherdata - let decryptedData = decryptRSA kpriv cipherdata - let decryptedText = Encoding.UTF8.GetString decryptedData - printfn "decryptedtext: %A" decryptedText - assert (plaintext = decryptedText) - printfn "testRSA OK" - ) - -let testRSASignature = lazy ( - let kpub, kpriv = generateRSAKeysPair - let plaintext = "Hello, World!" - let sha256 = new SHA256Managed () - let signature = signRSA kpriv (sha256.ComputeHash (Encoding.UTF8.GetBytes plaintext)) - assert verifySignRSA kpub (sha256.ComputeHash (Encoding.UTF8.GetBytes plaintext)) signature - assert not (verifySignRSA kpub (sha256.ComputeHash (Encoding.UTF8.GetBytes "Hello!")) signature) - printfn "testRSASignature OK" - ) \ No newline at end of file diff --git a/labo2-fsharp/labo2-fsharp/Program.fs b/labo2-fsharp/labo2-fsharp/Program.fs deleted file mode 100644 index a3d2e56..0000000 --- a/labo2-fsharp/labo2-fsharp/Program.fs +++ /dev/null @@ -1,17 +0,0 @@ -(* -Crypto - Labo n°2. -*) - -module Labo2.Main - -open System -open Crypto - -[] -let main args = - printfn "Labo n°2" - - if Array.exists ((=) "tests") args then - testRSA.Force () - testRSASignature.Force () - 0 diff --git a/labo2-fsharp/labo2-fsharp/labo2-fsharp.fsproj b/labo2-fsharp/labo2-fsharp/labo2-fsharp.fsproj deleted file mode 100644 index 4ee07a3..0000000 --- a/labo2-fsharp/labo2-fsharp/labo2-fsharp.fsproj +++ /dev/null @@ -1,55 +0,0 @@ - - - - Debug - x86 - {CDB168EA-04F9-4A8B-A3B4-27D9A6390269} - Exe - labo2fsharp - labo2-fsharp - v4.5 - - - true - full - bin\Debug - DEBUG - prompt - x86 - true - false - false - - - - - - tests - - - true - pdbonly - true - bin\Release - prompt - x86 - true - true - - - - - - - - - - - - - - - - - - \ No newline at end of file diff --git a/notes.txt b/notes.txt index c577848..31f7e2b 100644 --- a/notes.txt +++ b/notes.txt @@ -50,11 +50,12 @@ inputs: * Génération d'une clef 256 bits pour AES -> kc * Génération d'une clef 256 bits pour MAC -> ka +* Génération d'un IV pour le mode CBC -> iv * Construction du plaintext, voir format ci dessous -* Chiffrement du plaintext avec AES-CBC256 et kc -> ciphertext +* Chiffrement du plaintext avec AES-CBC256 et kc et iv -> ciphertext * Calcul de MAC de ciphertext -> mac * Signature de mac -> sig -* Chiffrement de kc + ka avec kpub (RSA) -> keys +* Chiffrement de kc + ka + iv avec kpub (RSA) -> keys * Renvoie mac + sig + keys + ciphertext diff --git a/rapport/main.pdf b/rapport/main.pdf index e787e0b..5ed8b24 100644 Binary files a/rapport/main.pdf and b/rapport/main.pdf differ diff --git a/rapport/main.tex b/rapport/main.tex index 97745a2..22e7f92 100644 --- a/rapport/main.tex +++ b/rapport/main.tex @@ -45,15 +45,80 @@ mutable, if, then, else, cloud, async, static, use, abstract, interface, inherit %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% \section{Introduction} +\section{Choix des algorithmes et des paramètres} + +\begin{itemize} + \item \emph{RSA-2048} pour la signature ainsi que pour le chiffrage des clefs \emph{AES} et \emph{HMAC}. Le padding \emph{PKCS\#1 v1.5} est utilisé ; + \item \emph{HMAC-SHA256} pour la vérification de l'intégrité ; + \item \emph{AES-CBC256} pour le chiffrement symétrique du contenu du fichier et des méta-données. +\end{itemize} + + +%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% +\section{format du container} + +Le format est définit comme suit en \emph{EBNF}. Les valeurs entre crochets correspondent soit à une taille en bits soit à un type. + +\begin{lstlisting}[frame=single, breaklines, basicstyle=\ttfamily\footnotesize] +container = header, ciphertext ; +header = file-content-size[int64], mac[256], signature[2048], keys[2048] ; +ciphertext = AES(plaintext) ; +plaintext = meta-data, file-content ; +meta-data = meta-data-size[int32], { key-value-pair } ; +key-value-pair = key[string], value[string] ; +string = size[8], content-utf8 ; +\end{lstlisting} + +\texttt{meta-data-size} permet de connaître la taille des méta-données afin de les déchiffrer au préalable du contenu du fichier. + +\texttt{keys} correspond aux clefs $k_c$ et $k_a$ ainsi qu'a l'\emph{IV} le tout chiffré avec \emph{RSA-2048}. La taille des données chiffrées est égale à $k_c + k_a + iv = 256 + 256 + 128 = 640\,bits$. + +Les méta-données (\texttt{meta-data}) peuvent contenir, par exemple, le nom du fichier, sa date de création, ses droits, ou tout autres données associées. + + %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% \section{processus} \subsection{chiffrement} +Entrées : + +\begin{itemize} + \item $f$ : contenu du fichier + \item $metas$ : métas données associées au fichier + \item $k_{pub}$ : clef publique RSA + \item $k_{signpriv}$ : clef privé de signature DSA +\end{itemize} + + +Processus : + +\begin{enumerate} + \item Génération d'une clef 256 bits pour \emph{AES} $\rightarrow k_c$. + \item Génération d'une clef 256 bits pour \emph{MAC} $\rightarrow k_a$. + \item Génération d'un \emph{IV} 128 bits pour le mode \emph{CBC} $\rightarrow iv$. + \item Construction du $plaintext$, voir format ci dessus. + \item Chiffrement du $plaintext$ avec \emph{AES-CBC256}, $k_c$ et $iv \rightarrow ciphertext$. + \item Calcul de MAC de $ciphertext$ $\rightarrow mac$. + \item Signature de $mac$ avec $k_{signpriv}$ $\rightarrow sig$. + \item Chiffrement de $k_c + k_a + iv$ avec $k_pub \rightarrow keys$. + \item Renvoie $mac + sig + keys + ciphertext$. +\end{enumerate} + +Où $+$ dénote la concaténation. + + + \subsection{déchiffrement} + %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% -\section{format du container} +\section{Implémentation} + +\subsection{Utilisation} + +\subsection{Organisation du code} + %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% \section{Niveaux de sécurité} @@ -63,7 +128,7 @@ mutable, if, then, else, cloud, async, static, use, abstract, interface, inherit \begin{itemize} \item Confidentialité : les données chiffrées ne doivent pas pouvoir être décryptées par un attaquant. \item Authentification : un attaquant ne doit pas pouvoir forger un container, une signature est réalisée à l'aide d'une paire de clef publique-privée. - \item Intégrité : il ne faut pas que les données chiffrée aient pu être altérées par un attaquant. + \item Intégrité : il ne faut pas que les données chiffrées aient pu être altérées par un attaquant. \end{itemize} @@ -82,7 +147,27 @@ L'empreinte des données est signée à l'aide d'une clef privée donnée en par Cela est réalisé avec un \emph{MAC}, dans notre nous utilisons \emph{HMAC-SHA256} sur les données chiffrées (\emph{Encrypt-then-MAC}). -\subsection{} +\subsection{Quels sont les clefs cryptographiques requises qu'il est nécessaire de gérer ?} + +\subsubsection{Clefs externes} + +Concerne les clefs externes à l'\emph{API}. + +\begin{itemize} + \item Une paire de clefs \emph{RSA-2048} pour la signature. + \item Une paire de clefs \emph{RSA-2048} pour le chiffrement des clefs \emph{AES}. +\end{itemize} + + + +\subsubsection{Clefs internes} + +Concerne les clefs gérer à l'intérieur du container. + +\begin{itemize} + \item Une clef de 256 bits pour \emph{AES}. + \item Une clef de 256 bits pour \emph{HMAC}. +\end{itemize} %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%