Buildings.Utilities.Cryptographics.Validation

Validation models for cryptographic functions.

Information

This package contains models for validation of cryptographic functions. The examples plot various outputs, which have been verified against comparative results. These model outputs are stored as reference data to allow continuous validation whenever models in the library change.

Extends from Modelica.Icons.ExamplesPackage (Icon for packages containing runnable examples).

Package Content

Name Description
Buildings.Utilities.Cryptographics.Validation.SHA1 SHA1 Model that verifies the SHA1 encryption C function

Buildings.Utilities.Cryptographics.Validation.SHA1 Buildings.Utilities.Cryptographics.Validation.SHA1

Model that verifies the SHA1 encryption C function

Information

This validation function tests the C implementation of the SHA1 encryption for the following strings:

If the encrypted strings are identical to the expected (known) encryption results, the cmpAll boolean variable will be true.

Extends from Modelica.Icons.Example (Icon for runnable examples).

Parameters

TypeNameDefaultDescription
StringstrIn1"abc"First test string
StringstrIn2""Second test string
StringstrIn3"abcdbcdecdefdefgefghfghighi...Third test string
StringstrIn4"1.23e+4"Fourth test string
StringstrIn5Modelica.Utilities.Strings.r...Fifth test string
StringstrEx1"a9993e364706816aba3e2571785...Encryption result of first string
StringstrEx2"da39a3ee5e6b4b0d3255bfef956...Encryption result of second string
StringstrEx3"84983e441c3bd26ebaae4aa1f95...Encryption result of third string
StringstrEx4"bdd220adb45b392f17915af70ed...Encryption result of fourth string
StringstrEx5"edff7a135c2e06d4c8084e61b45...Encryption result of fifth string

Modelica definition

model SHA1 "Model that verifies the SHA1 encryption C function" extends Modelica.Icons.Example; //Test strings parameter String strIn1 = "abc" "First test string"; parameter String strIn2 = "" "Second test string"; parameter String strIn3 = "abcdbcdecdefdefgefghfghighijhijkijkljklmklmnlmnomnopnopq" "Third test string"; parameter String strIn4 = "1.23e+4" "Fourth test string"; parameter String strIn5 = Modelica.Utilities.Strings.repeat(509, string="a") "Fifth test string"; //Expected outputs parameter String strEx1= "a9993e364706816aba3e25717850c26c9cd0d89d" "Encryption result of first string"; parameter String strEx2= "da39a3ee5e6b4b0d3255bfef95601890afd80709" "Encryption result of second string"; parameter String strEx3= "84983e441c3bd26ebaae4aa1f95129e5e54670f1" "Encryption result of third string"; parameter String strEx4= "bdd220adb45b392f17915af70ed8a006c382b983" "Encryption result of fourth string"; parameter String strEx5= "edff7a135c2e06d4c8084e61b4516c901bd5fcd0" "Encryption result of fifth string"; //Comparison results Boolean cmp1,cmp2,cmp3,cmp4,cmp5,cmpAll; equation cmp1 = Modelica.Utilities.Strings.isEqual(Buildings.Utilities.Cryptographics.sha(strIn1),strEx1,false); cmp2 = Modelica.Utilities.Strings.isEqual(Buildings.Utilities.Cryptographics.sha(strIn2),strEx2,false); cmp3 = Modelica.Utilities.Strings.isEqual(Buildings.Utilities.Cryptographics.sha(strIn3),strEx3,false); cmp4 = Modelica.Utilities.Strings.isEqual(Buildings.Utilities.Cryptographics.sha(strIn4),strEx4,false); cmp5 = Modelica.Utilities.Strings.isEqual(Buildings.Utilities.Cryptographics.sha(strIn5),strEx5,false); cmpAll = cmp1 and cmp2 and cmp3 and cmp4 and cmp5; end SHA1;