RegressionTests__CryptTests.st
author Claus Gittinger <cg@exept.de>
Tue, 26 Mar 2019 18:29:17 +0100
changeset 2175 c2e359dfc0fc
parent 2142 8c3f70ccb842
child 2179 9d14571951e7
permissions -rw-r--r--
#OTHER by cg class: TestCase category of: #setUp #tearDown
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
2053
e1a74171ea8b #REFACTORING by cg
Claus Gittinger <cg@exept.de>
parents: 2045
diff changeset
     1
"{ Encoding: utf8 }"
e1a74171ea8b #REFACTORING by cg
Claus Gittinger <cg@exept.de>
parents: 2045
diff changeset
     2
1447
2351db93aa5b package changes
Claus Gittinger <cg@exept.de>
parents: 1403
diff changeset
     3
"{ Package: 'stx:goodies/regression' }"
805
93f37c5c8c6b *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
     4
93f37c5c8c6b *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
     5
"{ NameSpace: RegressionTests }"
93f37c5c8c6b *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
     6
93f37c5c8c6b *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
     7
TestCase subclass:#CryptTests
1036
c42c54df984e class: RegressionTests::CryptTests
Claus Gittinger <cg@exept.de>
parents: 1035
diff changeset
     8
	instanceVariableNames:''
1100
1991bf9454ab Load exept:libcrypt if not already loaded.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 1038
diff changeset
     9
	classVariableNames:'LibCryptLoaded'
1036
c42c54df984e class: RegressionTests::CryptTests
Claus Gittinger <cg@exept.de>
parents: 1035
diff changeset
    10
	poolDictionaries:''
2045
4495922b72e8 #OTHER by cg
Claus Gittinger <cg@exept.de>
parents: 1690
diff changeset
    11
	category:'tests-Regression-Files and Encodings'
805
93f37c5c8c6b *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    12
!
93f37c5c8c6b *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    13
93f37c5c8c6b *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    14
!CryptTests class methodsFor:'documentation'!
93f37c5c8c6b *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    15
93f37c5c8c6b *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    16
documentation
93f37c5c8c6b *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    17
"
93f37c5c8c6b *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    18
    documentation to be added.
93f37c5c8c6b *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    19
93f37c5c8c6b *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    20
    [author:]
1447
2351db93aa5b package changes
Claus Gittinger <cg@exept.de>
parents: 1403
diff changeset
    21
	exept
805
93f37c5c8c6b *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    22
93f37c5c8c6b *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    23
    [instance variables:]
93f37c5c8c6b *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    24
93f37c5c8c6b *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    25
    [class variables:]
93f37c5c8c6b *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    26
93f37c5c8c6b *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    27
    [see also:]
93f37c5c8c6b *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    28
93f37c5c8c6b *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    29
"
93f37c5c8c6b *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    30
! !
93f37c5c8c6b *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    31
1100
1991bf9454ab Load exept:libcrypt if not already loaded.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 1038
diff changeset
    32
!CryptTests class methodsFor:'initialization'!
1991bf9454ab Load exept:libcrypt if not already loaded.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 1038
diff changeset
    33
1991bf9454ab Load exept:libcrypt if not already loaded.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 1038
diff changeset
    34
initialize
1991bf9454ab Load exept:libcrypt if not already loaded.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 1038
diff changeset
    35
    "Invoked at system start or when the class is dynamically loaded."
1991bf9454ab Load exept:libcrypt if not already loaded.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 1038
diff changeset
    36
1991bf9454ab Load exept:libcrypt if not already loaded.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 1038
diff changeset
    37
    LibCryptLoaded := false.
1991bf9454ab Load exept:libcrypt if not already loaded.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 1038
diff changeset
    38
1991bf9454ab Load exept:libcrypt if not already loaded.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 1038
diff changeset
    39
    "Modified: / 03-03-2014 / 12:05:37 / Jan Vrany <jan.vrany@fit.cvut.cz>"
2053
e1a74171ea8b #REFACTORING by cg
Claus Gittinger <cg@exept.de>
parents: 2045
diff changeset
    40
    "Modified (comment): / 06-11-2018 / 10:33:59 / Claus Gittinger"
1100
1991bf9454ab Load exept:libcrypt if not already loaded.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 1038
diff changeset
    41
! !
1991bf9454ab Load exept:libcrypt if not already loaded.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 1038
diff changeset
    42
1991bf9454ab Load exept:libcrypt if not already loaded.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 1038
diff changeset
    43
!CryptTests class methodsFor:'utilities'!
1991bf9454ab Load exept:libcrypt if not already loaded.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 1038
diff changeset
    44
1991bf9454ab Load exept:libcrypt if not already loaded.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 1038
diff changeset
    45
loadLibcryptIfAvailable
1991bf9454ab Load exept:libcrypt if not already loaded.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 1038
diff changeset
    46
    "raise an error: this method should be implemented (TODO)"
1991bf9454ab Load exept:libcrypt if not already loaded.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 1038
diff changeset
    47
1447
2351db93aa5b package changes
Claus Gittinger <cg@exept.de>
parents: 1403
diff changeset
    48
    LibCryptLoaded ifFalse:[
2053
e1a74171ea8b #REFACTORING by cg
Claus Gittinger <cg@exept.de>
parents: 2045
diff changeset
    49
        (Smalltalk at: #'exept_libcrypt') isNil ifTrue:[
e1a74171ea8b #REFACTORING by cg
Claus Gittinger <cg@exept.de>
parents: 2045
diff changeset
    50
            [
e1a74171ea8b #REFACTORING by cg
Claus Gittinger <cg@exept.de>
parents: 2045
diff changeset
    51
                Smalltalk loadPackage: #'exept:libcrypt'.
e1a74171ea8b #REFACTORING by cg
Claus Gittinger <cg@exept.de>
parents: 2045
diff changeset
    52
            ] on: PackageLoadError do:[:ex |
e1a74171ea8b #REFACTORING by cg
Claus Gittinger <cg@exept.de>
parents: 2045
diff changeset
    53
                "/ Libcrypt not not available.
e1a74171ea8b #REFACTORING by cg
Claus Gittinger <cg@exept.de>
parents: 2045
diff changeset
    54
            ].
e1a74171ea8b #REFACTORING by cg
Claus Gittinger <cg@exept.de>
parents: 2045
diff changeset
    55
        ].
e1a74171ea8b #REFACTORING by cg
Claus Gittinger <cg@exept.de>
parents: 2045
diff changeset
    56
        LibCryptLoaded := (Smalltalk at: #'exept_libcrypt') notNil.
1100
1991bf9454ab Load exept:libcrypt if not already loaded.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 1038
diff changeset
    57
    ].
1991bf9454ab Load exept:libcrypt if not already loaded.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 1038
diff changeset
    58
1991bf9454ab Load exept:libcrypt if not already loaded.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 1038
diff changeset
    59
    "Created: / 03-03-2014 / 12:03:54 / Jan Vrany <jan.vrany@fit.cvut.cz>"
2053
e1a74171ea8b #REFACTORING by cg
Claus Gittinger <cg@exept.de>
parents: 2045
diff changeset
    60
    "Modified: / 06-11-2018 / 10:33:48 / Claus Gittinger"
1100
1991bf9454ab Load exept:libcrypt if not already loaded.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 1038
diff changeset
    61
! !
1991bf9454ab Load exept:libcrypt if not already loaded.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 1038
diff changeset
    62
805
93f37c5c8c6b *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    63
!CryptTests methodsFor:'initialize / release'!
93f37c5c8c6b *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    64
93f37c5c8c6b *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    65
setUp
93f37c5c8c6b *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    66
    "common setup - invoked before testing."
93f37c5c8c6b *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    67
1100
1991bf9454ab Load exept:libcrypt if not already loaded.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 1038
diff changeset
    68
    self class loadLibcryptIfAvailable.
1991bf9454ab Load exept:libcrypt if not already loaded.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 1038
diff changeset
    69
1991bf9454ab Load exept:libcrypt if not already loaded.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 1038
diff changeset
    70
    "Modified: / 03-03-2014 / 12:03:50 / Jan Vrany <jan.vrany@fit.cvut.cz>"
805
93f37c5c8c6b *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    71
!
93f37c5c8c6b *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    72
93f37c5c8c6b *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    73
tearDown
93f37c5c8c6b *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    74
    "common cleanup - invoked after testing."
93f37c5c8c6b *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    75
93f37c5c8c6b *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    76
    super tearDown
93f37c5c8c6b *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    77
! !
93f37c5c8c6b *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    78
93f37c5c8c6b *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    79
!CryptTests methodsFor:'tests'!
93f37c5c8c6b *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    80
93f37c5c8c6b *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    81
test01_crc32
93f37c5c8c6b *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    82
    |h|
93f37c5c8c6b *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    83
93f37c5c8c6b *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    84
    h := CRC32Stream hashValueOf:''.
93f37c5c8c6b *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    85
    self assert:(h = 0).
93f37c5c8c6b *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    86
93f37c5c8c6b *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    87
    h := CRC32Stream hashValueOf:'The quick brown fox jumps over the lazy dog'.
93f37c5c8c6b *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    88
    self assert:(h = 16r414fa339).
93f37c5c8c6b *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    89
93f37c5c8c6b *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    90
    h := CRC32Stream hashValueOf:'resume'.
93f37c5c8c6b *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    91
    self assert:(h = 16r60C1D0A0).
93f37c5c8c6b *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    92
93f37c5c8c6b *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    93
    h := (CRC32Stream new
1447
2351db93aa5b package changes
Claus Gittinger <cg@exept.de>
parents: 1403
diff changeset
    94
		    nextPut:$r;
2351db93aa5b package changes
Claus Gittinger <cg@exept.de>
parents: 1403
diff changeset
    95
		    nextPut:$e;
2351db93aa5b package changes
Claus Gittinger <cg@exept.de>
parents: 1403
diff changeset
    96
		    nextPut:$s;
2351db93aa5b package changes
Claus Gittinger <cg@exept.de>
parents: 1403
diff changeset
    97
		    nextPut:$u;
2351db93aa5b package changes
Claus Gittinger <cg@exept.de>
parents: 1403
diff changeset
    98
		    nextPut:$m;
2351db93aa5b package changes
Claus Gittinger <cg@exept.de>
parents: 1403
diff changeset
    99
		    nextPut:$e;
2351db93aa5b package changes
Claus Gittinger <cg@exept.de>
parents: 1403
diff changeset
   100
		    hashValue).
805
93f37c5c8c6b *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   101
    self assert:(h = 16r60C1D0A0).
93f37c5c8c6b *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   102
93f37c5c8c6b *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   103
    h := (CRC32Stream hashValueOf:#[1 2 3 4 5 6 7]).
93f37c5c8c6b *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   104
    self assert:(h = 16r70E46888).
93f37c5c8c6b *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   105
1447
2351db93aa5b package changes
Claus Gittinger <cg@exept.de>
parents: 1403
diff changeset
   106
    h := (CRC32Stream hashValueOf:#[16rFF 16rFF 16rFF 16rFF 16rFF 16rFF 16rFF 16rFF 16rFF 16rFF
2351db93aa5b package changes
Claus Gittinger <cg@exept.de>
parents: 1403
diff changeset
   107
	     16rFF 16rFF 16rFF 16rFF 16rFF 16rFF 16rFF 16rFF 16rFF 16rFF
2351db93aa5b package changes
Claus Gittinger <cg@exept.de>
parents: 1403
diff changeset
   108
	     16rFF 16rFF 16rFF 16rFF 16rFF 16rFF 16rFF 16rFF 16rFF 16rFF
2351db93aa5b package changes
Claus Gittinger <cg@exept.de>
parents: 1403
diff changeset
   109
	     16rFF 16rFF 16rFF 16rFF 16rFF 16rFF 16rFF 16rFF 16rFF 16rFF]).
805
93f37c5c8c6b *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   110
    self assert:(h = 16r8CD04C73).
93f37c5c8c6b *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   111
93f37c5c8c6b *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   112
    h := (CRC32Stream new
1447
2351db93aa5b package changes
Claus Gittinger <cg@exept.de>
parents: 1403
diff changeset
   113
		    next:100000 putAll:'12345678901234567890123456789012345678901234567890';
2351db93aa5b package changes
Claus Gittinger <cg@exept.de>
parents: 1403
diff changeset
   114
		    hashValue).
805
93f37c5c8c6b *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   115
    self assert:(h = 16r86D7D79A).
93f37c5c8c6b *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   116
93f37c5c8c6b *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   117
    "
93f37c5c8c6b *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   118
     self run:#test01_crc32
93f37c5c8c6b *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   119
     self new test01_crc32
93f37c5c8c6b *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   120
    "
93f37c5c8c6b *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   121
!
93f37c5c8c6b *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   122
93f37c5c8c6b *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   123
test02_md5
2138
373c662a4638 #QUALITY by cg
Claus Gittinger <cg@exept.de>
parents: 2135
diff changeset
   124
    |h s|
805
93f37c5c8c6b *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   125
93f37c5c8c6b *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   126
    h := MD5Stream hashValueOf:''.
93f37c5c8c6b *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   127
    self assert:(h = (ByteArray fromHexString:'d41d8cd98f00b204e9800998ecf8427e')).
93f37c5c8c6b *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   128
93f37c5c8c6b *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   129
    h := MD5Stream hashValueOf:'The quick brown fox jumps over the lazy dog'.
93f37c5c8c6b *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   130
    self assert:(h = (ByteArray fromHexString:'9e107d9d372bb6826bd81d3542a419d6')).
93f37c5c8c6b *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   131
93f37c5c8c6b *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   132
    h := MD5Stream hashValueOf:'abc'.
1447
2351db93aa5b package changes
Claus Gittinger <cg@exept.de>
parents: 1403
diff changeset
   133
    self assert:(h = #[16r90 16r01 16r50 16r98 16r3C 16rD2 16r4F 16rB0
2138
373c662a4638 #QUALITY by cg
Claus Gittinger <cg@exept.de>
parents: 2135
diff changeset
   134
                       16rD6 16r96 16r3F 16r7D 16r28 16rE1 16r7F 16r72]).
373c662a4638 #QUALITY by cg
Claus Gittinger <cg@exept.de>
parents: 2135
diff changeset
   135
373c662a4638 #QUALITY by cg
Claus Gittinger <cg@exept.de>
parents: 2135
diff changeset
   136
    s := MD5Stream new.
373c662a4638 #QUALITY by cg
Claus Gittinger <cg@exept.de>
parents: 2135
diff changeset
   137
    s nextPutByte:$a codePoint.
373c662a4638 #QUALITY by cg
Claus Gittinger <cg@exept.de>
parents: 2135
diff changeset
   138
    s nextPutByte:$b codePoint.
373c662a4638 #QUALITY by cg
Claus Gittinger <cg@exept.de>
parents: 2135
diff changeset
   139
    s nextPutByte:$c codePoint.
373c662a4638 #QUALITY by cg
Claus Gittinger <cg@exept.de>
parents: 2135
diff changeset
   140
    self assert:(s hashValue = #[16r90 16r01 16r50 16r98 16r3C 16rD2 16r4F 16rB0
373c662a4638 #QUALITY by cg
Claus Gittinger <cg@exept.de>
parents: 2135
diff changeset
   141
                       16rD6 16r96 16r3F 16r7D 16r28 16rE1 16r7F 16r72]).
373c662a4638 #QUALITY by cg
Claus Gittinger <cg@exept.de>
parents: 2135
diff changeset
   142
373c662a4638 #QUALITY by cg
Claus Gittinger <cg@exept.de>
parents: 2135
diff changeset
   143
    s := MD5Stream new.
373c662a4638 #QUALITY by cg
Claus Gittinger <cg@exept.de>
parents: 2135
diff changeset
   144
    s nextPut:$a.
373c662a4638 #QUALITY by cg
Claus Gittinger <cg@exept.de>
parents: 2135
diff changeset
   145
    s nextPut:$b.
373c662a4638 #QUALITY by cg
Claus Gittinger <cg@exept.de>
parents: 2135
diff changeset
   146
    s nextPut:$c.
373c662a4638 #QUALITY by cg
Claus Gittinger <cg@exept.de>
parents: 2135
diff changeset
   147
    self assert:(s hashValue = #[16r90 16r01 16r50 16r98 16r3C 16rD2 16r4F 16rB0
373c662a4638 #QUALITY by cg
Claus Gittinger <cg@exept.de>
parents: 2135
diff changeset
   148
                       16rD6 16r96 16r3F 16r7D 16r28 16rE1 16r7F 16r72]).
373c662a4638 #QUALITY by cg
Claus Gittinger <cg@exept.de>
parents: 2135
diff changeset
   149
373c662a4638 #QUALITY by cg
Claus Gittinger <cg@exept.de>
parents: 2135
diff changeset
   150
    s := MD5Stream new.
373c662a4638 #QUALITY by cg
Claus Gittinger <cg@exept.de>
parents: 2135
diff changeset
   151
    s nextPutAll:'abc'.
373c662a4638 #QUALITY by cg
Claus Gittinger <cg@exept.de>
parents: 2135
diff changeset
   152
    self assert:(s hashValue = #[16r90 16r01 16r50 16r98 16r3C 16rD2 16r4F 16rB0
373c662a4638 #QUALITY by cg
Claus Gittinger <cg@exept.de>
parents: 2135
diff changeset
   153
                       16rD6 16r96 16r3F 16r7D 16r28 16rE1 16r7F 16r72]).
373c662a4638 #QUALITY by cg
Claus Gittinger <cg@exept.de>
parents: 2135
diff changeset
   154
373c662a4638 #QUALITY by cg
Claus Gittinger <cg@exept.de>
parents: 2135
diff changeset
   155
    s := MD5Stream new.
373c662a4638 #QUALITY by cg
Claus Gittinger <cg@exept.de>
parents: 2135
diff changeset
   156
    s nextPutAll:'abc' asByteArray.
373c662a4638 #QUALITY by cg
Claus Gittinger <cg@exept.de>
parents: 2135
diff changeset
   157
    self assert:(s hashValue = #[16r90 16r01 16r50 16r98 16r3C 16rD2 16r4F 16rB0
373c662a4638 #QUALITY by cg
Claus Gittinger <cg@exept.de>
parents: 2135
diff changeset
   158
                       16rD6 16r96 16r3F 16r7D 16r28 16rE1 16r7F 16r72]).
805
93f37c5c8c6b *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   159
93f37c5c8c6b *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   160
    h := MD5Stream hashValueOf:'abcdbcdecdefdefgefghfghighijhijkijkljklmklmnlmnomnopnopq'.
1447
2351db93aa5b package changes
Claus Gittinger <cg@exept.de>
parents: 1403
diff changeset
   161
    self assert:(h = #[16r82 16r15 16rEF 16r07 16r96 16rA2 16r0B 16rCA
2138
373c662a4638 #QUALITY by cg
Claus Gittinger <cg@exept.de>
parents: 2135
diff changeset
   162
                       16rAA 16rE1 16r16 16rD3 16r87 16r6C 16r66 16r4A]).
805
93f37c5c8c6b *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   163
93f37c5c8c6b *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   164
    h := (MD5Stream new
2138
373c662a4638 #QUALITY by cg
Claus Gittinger <cg@exept.de>
parents: 2135
diff changeset
   165
                next:1000000 put:$a;
373c662a4638 #QUALITY by cg
Claus Gittinger <cg@exept.de>
parents: 2135
diff changeset
   166
                hashValue).
1447
2351db93aa5b package changes
Claus Gittinger <cg@exept.de>
parents: 1403
diff changeset
   167
    self assert:(h = #[16r77 16r07 16rD6 16rAE 16r4E 16r02 16r7C 16r70
2138
373c662a4638 #QUALITY by cg
Claus Gittinger <cg@exept.de>
parents: 2135
diff changeset
   168
                       16rEE 16rA2 16rA9 16r35 16rC2 16r29 16r6F 16r21]).
805
93f37c5c8c6b *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   169
93f37c5c8c6b *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   170
    "
93f37c5c8c6b *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   171
     self run:#test02_md5
93f37c5c8c6b *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   172
     self new test02_md5
93f37c5c8c6b *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   173
    "
2138
373c662a4638 #QUALITY by cg
Claus Gittinger <cg@exept.de>
parents: 2135
diff changeset
   174
373c662a4638 #QUALITY by cg
Claus Gittinger <cg@exept.de>
parents: 2135
diff changeset
   175
    "Modified: / 23-03-2019 / 15:23:42 / Claus Gittinger"
805
93f37c5c8c6b *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   176
!
93f37c5c8c6b *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   177
93f37c5c8c6b *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   178
test03_sha1
2138
373c662a4638 #QUALITY by cg
Claus Gittinger <cg@exept.de>
parents: 2135
diff changeset
   179
    |h s|
805
93f37c5c8c6b *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   180
2122
a9c72db987e7 #QUALITY by cg
Claus Gittinger <cg@exept.de>
parents: 2053
diff changeset
   181
    "/ test vectors from https://www.di-mgt.com.au/sha_testvectors.html
a9c72db987e7 #QUALITY by cg
Claus Gittinger <cg@exept.de>
parents: 2053
diff changeset
   182
    "/ and others
a9c72db987e7 #QUALITY by cg
Claus Gittinger <cg@exept.de>
parents: 2053
diff changeset
   183
    
805
93f37c5c8c6b *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   184
    h := SHA1Stream hashValueOf:''.
93f37c5c8c6b *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   185
    self assert:(h = (ByteArray fromHexString:'da39a3ee5e6b4b0d3255bfef95601890afd80709')).
93f37c5c8c6b *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   186
2122
a9c72db987e7 #QUALITY by cg
Claus Gittinger <cg@exept.de>
parents: 2053
diff changeset
   187
    h := SHA1Stream hashValueOf:'abc'.
a9c72db987e7 #QUALITY by cg
Claus Gittinger <cg@exept.de>
parents: 2053
diff changeset
   188
    self assert:(h = (ByteArray fromHexStringWithSeparators:'a9993e36 4706816a ba3e2571 7850c26c 9cd0d89d')).
a9c72db987e7 #QUALITY by cg
Claus Gittinger <cg@exept.de>
parents: 2053
diff changeset
   189
2138
373c662a4638 #QUALITY by cg
Claus Gittinger <cg@exept.de>
parents: 2135
diff changeset
   190
    s := SHA1Stream new.
373c662a4638 #QUALITY by cg
Claus Gittinger <cg@exept.de>
parents: 2135
diff changeset
   191
    s nextPutByte:$a codePoint.
373c662a4638 #QUALITY by cg
Claus Gittinger <cg@exept.de>
parents: 2135
diff changeset
   192
    s nextPutByte:$b codePoint.
373c662a4638 #QUALITY by cg
Claus Gittinger <cg@exept.de>
parents: 2135
diff changeset
   193
    s nextPutByte:$c codePoint.
373c662a4638 #QUALITY by cg
Claus Gittinger <cg@exept.de>
parents: 2135
diff changeset
   194
    self assert:(s hashValue = (ByteArray fromHexStringWithSeparators:'a9993e36 4706816a ba3e2571 7850c26c 9cd0d89d')).
373c662a4638 #QUALITY by cg
Claus Gittinger <cg@exept.de>
parents: 2135
diff changeset
   195
    
373c662a4638 #QUALITY by cg
Claus Gittinger <cg@exept.de>
parents: 2135
diff changeset
   196
    s := SHA1Stream new.
373c662a4638 #QUALITY by cg
Claus Gittinger <cg@exept.de>
parents: 2135
diff changeset
   197
    s nextPut:$a.
373c662a4638 #QUALITY by cg
Claus Gittinger <cg@exept.de>
parents: 2135
diff changeset
   198
    s nextPut:$b.
373c662a4638 #QUALITY by cg
Claus Gittinger <cg@exept.de>
parents: 2135
diff changeset
   199
    s nextPut:$c.
373c662a4638 #QUALITY by cg
Claus Gittinger <cg@exept.de>
parents: 2135
diff changeset
   200
    self assert:(s hashValue = (ByteArray fromHexStringWithSeparators:'a9993e36 4706816a ba3e2571 7850c26c 9cd0d89d')).
373c662a4638 #QUALITY by cg
Claus Gittinger <cg@exept.de>
parents: 2135
diff changeset
   201
373c662a4638 #QUALITY by cg
Claus Gittinger <cg@exept.de>
parents: 2135
diff changeset
   202
    s := SHA1Stream new.
373c662a4638 #QUALITY by cg
Claus Gittinger <cg@exept.de>
parents: 2135
diff changeset
   203
    s nextPutAll:'abc'.
373c662a4638 #QUALITY by cg
Claus Gittinger <cg@exept.de>
parents: 2135
diff changeset
   204
    self assert:(s hashValue = (ByteArray fromHexStringWithSeparators:'a9993e36 4706816a ba3e2571 7850c26c 9cd0d89d')).
373c662a4638 #QUALITY by cg
Claus Gittinger <cg@exept.de>
parents: 2135
diff changeset
   205
373c662a4638 #QUALITY by cg
Claus Gittinger <cg@exept.de>
parents: 2135
diff changeset
   206
    s := SHA1Stream new.
373c662a4638 #QUALITY by cg
Claus Gittinger <cg@exept.de>
parents: 2135
diff changeset
   207
    s nextPutAll:'abc' asByteArray.
373c662a4638 #QUALITY by cg
Claus Gittinger <cg@exept.de>
parents: 2135
diff changeset
   208
    self assert:(s hashValue = (ByteArray fromHexStringWithSeparators:'a9993e36 4706816a ba3e2571 7850c26c 9cd0d89d')).
373c662a4638 #QUALITY by cg
Claus Gittinger <cg@exept.de>
parents: 2135
diff changeset
   209
2122
a9c72db987e7 #QUALITY by cg
Claus Gittinger <cg@exept.de>
parents: 2053
diff changeset
   210
    h := SHA1Stream hashValueOf:'abcdbcdecdefdefgefghfghighijhijkijkljklmklmnlmnomnopnopq'.
a9c72db987e7 #QUALITY by cg
Claus Gittinger <cg@exept.de>
parents: 2053
diff changeset
   211
    self assert:(h = (ByteArray fromHexStringWithSeparators:'84983e44 1c3bd26e baae4aa1 f95129e5 e54670f1')).
a9c72db987e7 #QUALITY by cg
Claus Gittinger <cg@exept.de>
parents: 2053
diff changeset
   212
a9c72db987e7 #QUALITY by cg
Claus Gittinger <cg@exept.de>
parents: 2053
diff changeset
   213
    h := SHA1Stream hashValueOf:'abcdefghbcdefghicdefghijdefghijkefghijklfghijklmghijklmnhijklmnoijklmnopjklmnopqklmnopqrlmnopqrsmnopqrstnopqrstu'.
a9c72db987e7 #QUALITY by cg
Claus Gittinger <cg@exept.de>
parents: 2053
diff changeset
   214
    self assert:(h = (ByteArray fromHexStringWithSeparators:'a49b2446 a02c645b f419f995 b6709125 3a04a259')).
a9c72db987e7 #QUALITY by cg
Claus Gittinger <cg@exept.de>
parents: 2053
diff changeset
   215
805
93f37c5c8c6b *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   216
    h := SHA1Stream hashValueOf:'The quick brown fox jumps over the lazy dog'.
93f37c5c8c6b *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   217
    self assert:(h = (ByteArray fromHexString:'2fd4e1c67a2d28fced849ee1bb76e7391b93eb12')).
93f37c5c8c6b *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   218
1022
abdf6a161bc3 class: RegressionTests::CryptTests
Claus Gittinger <cg@exept.de>
parents: 1020
diff changeset
   219
    h := SHA1Stream hashValueOf:#[16r00 16r01 16r02 16r40 16r08 16r10 16r20 16r40 16r80
2122
a9c72db987e7 #QUALITY by cg
Claus Gittinger <cg@exept.de>
parents: 2053
diff changeset
   220
                                  16rFF 16rFE 16rFC 16rF8 16rF0 16rE0 16rC0 16r80].
1022
abdf6a161bc3 class: RegressionTests::CryptTests
Claus Gittinger <cg@exept.de>
parents: 1020
diff changeset
   221
    self assert:(h = #[146 31 26 53 78 167 121 73 144 117 145 88 50 42 25 52 53 37 177 73]).
abdf6a161bc3 class: RegressionTests::CryptTests
Claus Gittinger <cg@exept.de>
parents: 1020
diff changeset
   222
2122
a9c72db987e7 #QUALITY by cg
Claus Gittinger <cg@exept.de>
parents: 2053
diff changeset
   223
    h := SHA1Stream hashValueOf:(String new:1000000 withAll:$a).
a9c72db987e7 #QUALITY by cg
Claus Gittinger <cg@exept.de>
parents: 2053
diff changeset
   224
    self assert:(h = (ByteArray fromHexStringWithSeparators:'34aa973c d4c4daa4 f61eeb2b dbad2731 6534016f')).
a9c72db987e7 #QUALITY by cg
Claus Gittinger <cg@exept.de>
parents: 2053
diff changeset
   225
2138
373c662a4638 #QUALITY by cg
Claus Gittinger <cg@exept.de>
parents: 2135
diff changeset
   226
    h := SHA1Stream hashValueOf:#[48 130 2 149 160 3 2 1 2 2 1 6 48 13 6 9 42 134 72 134 247 13 1 1 5 5 0 48 111 49 25 48 23 6 3 85 4 3 19 16 69 120 101 112 116 32 76 101 118 101 108 32 50 32 67 65 49 11 48 9 6 3 85 4 6 19 2 68 69 49 26 48 24 6 3 85 4 10 19 17 69 120 101 112 116 32 83 111 102 116 119 97 114 101 32 65 71 49 11 48 9 6 3 85 4 11 19 2 67 65 49 28 48 26 6 9 42 134 72 134 247 13 1 9 1 22 13 99 101 114 116 64 101 120 101 112 116 46 100 101 48 30 23 13 48 56 48 52 50 50 50 48 48 48 48 48 90 23 13 49 54 48 54 48 49 49 57 53 57 53 57 90 48 72 49 11 48 9 6 3 85 4 6 19 2 68 69 49 26 48 24 6 3 85 4 10 19 17 69 120 101 112 116 32 83 111 102 116 119 97 114 101 32 65 71 49 29 48 27 6 3 85 4 3 19 20 101 120 112 101 99 99 111 32 99 111 100 101 32 115 105 103 110 105 110 103 48 129 159 48 13 6 9 42 134 72 134 247 13 1 1 1 5 0 3 129 141 0 48 129 137 2 129 129 0 199 150 115 153 147 36 175 136 129 9 92 77 196 254 201 72 55 141 131 27 57 64 226 5 191 35 239 72 236 142 151 98 19 209 37 164 153 24 185 170 82 62 223 250 229 224 59 238 40 73 29 84 83 109 2 188 117 254 37 86 32 136 145 32 255 118 90 26 62 76 137 45 196 88 220 234 231 81 63 165 29 158 212 132 117 227 250 68 249 54 42 54 69 145 185 217 234 66 192 205 240 247 173 215 243 64 30 52 116 19 113 47 189 90 216 64 241 30 193 187 185 219 5 35 231 222 30 183 2 3 1 0 1 163 129 254 48 129 251 48 9 6 3 85 29 19 4 2 48 0 48 29 6 3 85 29 14 4 22 4 20 142 53 132 147 2 27 121 108 9 10 151 194 20 232 134 227 84 160 251 55 48 129 153 6 3 85 29 35 4 129 145 48 129 142 128 20 36 157 29 207 97 136 114 233 22 165 218 37 28 117 161 157 224 230 74 178 161 115 164 113 48 111 49 25 48 23 6 3 85 4 3 19 16 69 120 101 112 116 32 76 101 118 101 108 32 49 32 67 65 49 11 48 9 6 3 85 4 6 19 2 68 69 49 26 48 24 6 3 85 4 10 19 17 69 120 101 112 116 32 83 111 102 116 119 97 114 101 32 65 71 49 11 48 9 6 3 85 4 11 19 2 67 65 49 28 48 26 6 9 42 134 72 134 247 13 1 9 1 22 13 99 101 114 116 64 101 120 101 112 116 46 100 101 130 1 2 48 11 6 3 85 29 15 4 4 3 2 7 128 48 19 6 3 85 29 37 4 12 48 10 6 8 43 6 1 5 5 7 3 3 48 17 6 9 96 134 72 1 134 248 66 1 1 4 4 3 2 4 16].
373c662a4638 #QUALITY by cg
Claus Gittinger <cg@exept.de>
parents: 2135
diff changeset
   227
    self assert:(h = #[152 185 22 239 129 56 192 23 215 67 254 147 139 91 251 28 96 142 185 186]).
373c662a4638 #QUALITY by cg
Claus Gittinger <cg@exept.de>
parents: 2135
diff changeset
   228
805
93f37c5c8c6b *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   229
    "
93f37c5c8c6b *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   230
     self run:#test03_sha1
93f37c5c8c6b *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   231
     self new test03_sha1
93f37c5c8c6b *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   232
    "
1022
abdf6a161bc3 class: RegressionTests::CryptTests
Claus Gittinger <cg@exept.de>
parents: 1020
diff changeset
   233
abdf6a161bc3 class: RegressionTests::CryptTests
Claus Gittinger <cg@exept.de>
parents: 1020
diff changeset
   234
    "Modified: / 25-11-2013 / 11:42:46 / cg"
2138
373c662a4638 #QUALITY by cg
Claus Gittinger <cg@exept.de>
parents: 2135
diff changeset
   235
    "Modified: / 23-03-2019 / 15:22:29 / Claus Gittinger"
1038
5443ea4b780e class: RegressionTests::CryptTests
Claus Gittinger <cg@exept.de>
parents: 1036
diff changeset
   236
!
5443ea4b780e class: RegressionTests::CryptTests
Claus Gittinger <cg@exept.de>
parents: 1036
diff changeset
   237
805
93f37c5c8c6b *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   238
test04_md2
93f37c5c8c6b *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   239
    |h|
93f37c5c8c6b *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   240
1447
2351db93aa5b package changes
Claus Gittinger <cg@exept.de>
parents: 1403
diff changeset
   241
    self
2351db93aa5b package changes
Claus Gittinger <cg@exept.de>
parents: 1403
diff changeset
   242
	skipIf:(MD2Stream isBehavior not or:[MD2Stream isLoaded not])
2351db93aa5b package changes
Claus Gittinger <cg@exept.de>
parents: 1403
diff changeset
   243
	description:'MD2Stream/libcrypt is not loaded'.
951
d9fe0a97fc74 class: RegressionTests::CryptTests
Stefan Vogel <sv@exept.de>
parents: 936
diff changeset
   244
805
93f37c5c8c6b *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   245
    h := MD2Stream hashValueOf:''.
93f37c5c8c6b *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   246
    self assert:(h = (ByteArray fromHexString:'8350e5a3e24c153df2275c9f80692773')).
93f37c5c8c6b *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   247
93f37c5c8c6b *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   248
    h := MD2Stream hashValueOf:'The quick brown fox jumps over the lazy dog'.
93f37c5c8c6b *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   249
    self assert:(h = (ByteArray fromHexString:'03d85a0d629d2c442e987525319fc471')).
93f37c5c8c6b *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   250
93f37c5c8c6b *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   251
    "
93f37c5c8c6b *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   252
     self run:#test04_md2
93f37c5c8c6b *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   253
     self new test04_md2
93f37c5c8c6b *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   254
    "
93f37c5c8c6b *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   255
!
93f37c5c8c6b *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   256
93f37c5c8c6b *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   257
test05_md4
93f37c5c8c6b *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   258
    |h|
93f37c5c8c6b *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   259
1447
2351db93aa5b package changes
Claus Gittinger <cg@exept.de>
parents: 1403
diff changeset
   260
    self
2351db93aa5b package changes
Claus Gittinger <cg@exept.de>
parents: 1403
diff changeset
   261
	skipIf:(MD4Stream isBehavior not or:[MD4Stream isLoaded not])
2351db93aa5b package changes
Claus Gittinger <cg@exept.de>
parents: 1403
diff changeset
   262
	description:'MD4Stream/libcrypt is not loaded'.
951
d9fe0a97fc74 class: RegressionTests::CryptTests
Stefan Vogel <sv@exept.de>
parents: 936
diff changeset
   263
805
93f37c5c8c6b *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   264
    h := MD4Stream hashValueOf:''.
93f37c5c8c6b *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   265
    self assert:(h = (ByteArray fromHexString:'31d6cfe0d16ae931b73c59d7e0c089c0')).
93f37c5c8c6b *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   266
93f37c5c8c6b *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   267
    h := MD4Stream hashValueOf:'The quick brown fox jumps over the lazy dog'.
93f37c5c8c6b *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   268
    self assert:(h = (ByteArray fromHexString:'1bee69a46ba811185c194762abaeae90')).
93f37c5c8c6b *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   269
93f37c5c8c6b *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   270
    "
93f37c5c8c6b *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   271
     self run:#test05_md4
93f37c5c8c6b *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   272
     self new test05_md4
93f37c5c8c6b *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   273
    "
93f37c5c8c6b *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   274
!
93f37c5c8c6b *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   275
93f37c5c8c6b *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   276
test06_sha256
93f37c5c8c6b *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   277
    |h|
93f37c5c8c6b *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   278
2122
a9c72db987e7 #QUALITY by cg
Claus Gittinger <cg@exept.de>
parents: 2053
diff changeset
   279
    "/ test vectors from https://www.di-mgt.com.au/sha_testvectors.html
a9c72db987e7 #QUALITY by cg
Claus Gittinger <cg@exept.de>
parents: 2053
diff changeset
   280
    "/ and others
a9c72db987e7 #QUALITY by cg
Claus Gittinger <cg@exept.de>
parents: 2053
diff changeset
   281
1447
2351db93aa5b package changes
Claus Gittinger <cg@exept.de>
parents: 1403
diff changeset
   282
    self
2122
a9c72db987e7 #QUALITY by cg
Claus Gittinger <cg@exept.de>
parents: 2053
diff changeset
   283
        skipIf:(SHA256Stream isBehavior not or:[SHA256Stream isLoaded not])
a9c72db987e7 #QUALITY by cg
Claus Gittinger <cg@exept.de>
parents: 2053
diff changeset
   284
        description:'SHA256Stream/libcrypt is not loaded'.
951
d9fe0a97fc74 class: RegressionTests::CryptTests
Stefan Vogel <sv@exept.de>
parents: 936
diff changeset
   285
805
93f37c5c8c6b *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   286
    h := SHA256Stream hashValueOf:''.
93f37c5c8c6b *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   287
    self assert:(h = (ByteArray fromHexString:'e3b0c44298fc1c149afbf4c8996fb92427ae41e4649b934ca495991b7852b855')).
93f37c5c8c6b *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   288
93f37c5c8c6b *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   289
    h := SHA256Stream hashValueOf:'The quick brown fox jumps over the lazy dog'.
93f37c5c8c6b *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   290
    self assert:(h = (ByteArray fromHexString:'d7a8fbb307d7809469ca9abcb0082e4f8d5651e46d3cdb762d02d0bf37c9e592')).
93f37c5c8c6b *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   291
2122
a9c72db987e7 #QUALITY by cg
Claus Gittinger <cg@exept.de>
parents: 2053
diff changeset
   292
    h := SHA256Stream hashValueOf:'abc'.
a9c72db987e7 #QUALITY by cg
Claus Gittinger <cg@exept.de>
parents: 2053
diff changeset
   293
    self assert:(h = (ByteArray fromHexStringWithSeparators:'ba7816bf 8f01cfea 414140de 5dae2223 b00361a3 96177a9c b410ff61 f20015ad')).
a9c72db987e7 #QUALITY by cg
Claus Gittinger <cg@exept.de>
parents: 2053
diff changeset
   294
a9c72db987e7 #QUALITY by cg
Claus Gittinger <cg@exept.de>
parents: 2053
diff changeset
   295
    h := SHA256Stream hashValueOf:'abcdbcdecdefdefgefghfghighijhijkijkljklmklmnlmnomnopnopq'.
a9c72db987e7 #QUALITY by cg
Claus Gittinger <cg@exept.de>
parents: 2053
diff changeset
   296
    self assert:(h = (ByteArray fromHexStringWithSeparators:'248d6a61 d20638b8 e5c02693 0c3e6039 a33ce459 64ff2167 f6ecedd4 19db06c1')).
a9c72db987e7 #QUALITY by cg
Claus Gittinger <cg@exept.de>
parents: 2053
diff changeset
   297
a9c72db987e7 #QUALITY by cg
Claus Gittinger <cg@exept.de>
parents: 2053
diff changeset
   298
    h := SHA256Stream hashValueOf:'abcdefghbcdefghicdefghijdefghijkefghijklfghijklmghijklmnhijklmnoijklmnopjklmnopqklmnopqrlmnopqrsmnopqrstnopqrstu'.
a9c72db987e7 #QUALITY by cg
Claus Gittinger <cg@exept.de>
parents: 2053
diff changeset
   299
    self assert:(h = (ByteArray fromHexStringWithSeparators:'cf5b16a7 78af8380 036ce59e 7b049237 0b249b11 e8f07a51 afac4503 7afee9d1')).
a9c72db987e7 #QUALITY by cg
Claus Gittinger <cg@exept.de>
parents: 2053
diff changeset
   300
a9c72db987e7 #QUALITY by cg
Claus Gittinger <cg@exept.de>
parents: 2053
diff changeset
   301
    h := SHA256Stream hashValueOf:(String new:1000000 withAll:$a).
a9c72db987e7 #QUALITY by cg
Claus Gittinger <cg@exept.de>
parents: 2053
diff changeset
   302
    self assert:(h = (ByteArray fromHexStringWithSeparators:'cdc76e5c 9914fb92 81a1c7e2 84d73e67 f1809a48 a497200e 046d39cc c7112cd0')).
805
93f37c5c8c6b *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   303
    "
93f37c5c8c6b *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   304
     self run:#test06_sha256
93f37c5c8c6b *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   305
     self new test06_sha256
93f37c5c8c6b *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   306
    "
2122
a9c72db987e7 #QUALITY by cg
Claus Gittinger <cg@exept.de>
parents: 2053
diff changeset
   307
a9c72db987e7 #QUALITY by cg
Claus Gittinger <cg@exept.de>
parents: 2053
diff changeset
   308
    "Modified: / 22-03-2019 / 12:35:28 / Claus Gittinger"
805
93f37c5c8c6b *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   309
!
93f37c5c8c6b *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   310
93f37c5c8c6b *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   311
test07_sha224
93f37c5c8c6b *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   312
    |h|
93f37c5c8c6b *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   313
2142
8c3f70ccb842 #DOCUMENTATION by cg
Claus Gittinger <cg@exept.de>
parents: 2141
diff changeset
   314
    "/ test vectors from 
8c3f70ccb842 #DOCUMENTATION by cg
Claus Gittinger <cg@exept.de>
parents: 2141
diff changeset
   315
    "/     https://www.di-mgt.com.au/sha_testvectors.html
8c3f70ccb842 #DOCUMENTATION by cg
Claus Gittinger <cg@exept.de>
parents: 2141
diff changeset
   316
    "/     ftp://ftp.rfc-editor.org/in-notes/rfc3874.txt 
2122
a9c72db987e7 #QUALITY by cg
Claus Gittinger <cg@exept.de>
parents: 2053
diff changeset
   317
    "/ and others
a9c72db987e7 #QUALITY by cg
Claus Gittinger <cg@exept.de>
parents: 2053
diff changeset
   318
1447
2351db93aa5b package changes
Claus Gittinger <cg@exept.de>
parents: 1403
diff changeset
   319
    self
2122
a9c72db987e7 #QUALITY by cg
Claus Gittinger <cg@exept.de>
parents: 2053
diff changeset
   320
        skipIf:(SHA224Stream isBehavior not or:[SHA224Stream isLoaded not])
a9c72db987e7 #QUALITY by cg
Claus Gittinger <cg@exept.de>
parents: 2053
diff changeset
   321
        description:'SHA224Stream/libcrypt is not loaded'.
951
d9fe0a97fc74 class: RegressionTests::CryptTests
Stefan Vogel <sv@exept.de>
parents: 936
diff changeset
   322
805
93f37c5c8c6b *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   323
    h := SHA224Stream hashValueOf:''.
93f37c5c8c6b *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   324
    self assert:(h = (ByteArray fromHexString:'d14a028c2a3a2bc9476102bb288234c415a2b01f828ea62ac5b3e42f')).
93f37c5c8c6b *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   325
93f37c5c8c6b *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   326
    h := SHA224Stream hashValueOf:'The quick brown fox jumps over the lazy dog'.
93f37c5c8c6b *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   327
    self assert:(h = (ByteArray fromHexString:'730e109bd7a8a32b1cb9d9a09aa2325d2430587ddbc0c38bad911525')).
93f37c5c8c6b *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   328
2122
a9c72db987e7 #QUALITY by cg
Claus Gittinger <cg@exept.de>
parents: 2053
diff changeset
   329
    h := SHA224Stream hashValueOf:'abc'.
a9c72db987e7 #QUALITY by cg
Claus Gittinger <cg@exept.de>
parents: 2053
diff changeset
   330
    self assert:(h = (ByteArray fromHexStringWithSeparators:'23097d22 3405d822 8642a477 bda255b3 2aadbce4 bda0b3f7 e36c9da7')).
a9c72db987e7 #QUALITY by cg
Claus Gittinger <cg@exept.de>
parents: 2053
diff changeset
   331
a9c72db987e7 #QUALITY by cg
Claus Gittinger <cg@exept.de>
parents: 2053
diff changeset
   332
    h := SHA224Stream hashValueOf:'abcdbcdecdefdefgefghfghighijhijkijkljklmklmnlmnomnopnopq'.
a9c72db987e7 #QUALITY by cg
Claus Gittinger <cg@exept.de>
parents: 2053
diff changeset
   333
    self assert:(h = (ByteArray fromHexStringWithSeparators:'75388b16 512776cc 5dba5da1 fd890150 b0c6455c b4f58b19 52522525')).
a9c72db987e7 #QUALITY by cg
Claus Gittinger <cg@exept.de>
parents: 2053
diff changeset
   334
a9c72db987e7 #QUALITY by cg
Claus Gittinger <cg@exept.de>
parents: 2053
diff changeset
   335
    h := SHA224Stream hashValueOf:'abcdefghbcdefghicdefghijdefghijkefghijklfghijklmghijklmnhijklmnoijklmnopjklmnopqklmnopqrlmnopqrsmnopqrstnopqrstu'.
a9c72db987e7 #QUALITY by cg
Claus Gittinger <cg@exept.de>
parents: 2053
diff changeset
   336
    self assert:(h = (ByteArray fromHexStringWithSeparators:'c97ca9a5 59850ce9 7a04a96d ef6d99a9 e0e0e2ab 14e6b8df 265fc0b3')).
a9c72db987e7 #QUALITY by cg
Claus Gittinger <cg@exept.de>
parents: 2053
diff changeset
   337
a9c72db987e7 #QUALITY by cg
Claus Gittinger <cg@exept.de>
parents: 2053
diff changeset
   338
    h := SHA224Stream hashValueOf:(String new:1000000 withAll:$a).
a9c72db987e7 #QUALITY by cg
Claus Gittinger <cg@exept.de>
parents: 2053
diff changeset
   339
    self assert:(h = (ByteArray fromHexStringWithSeparators:'20794655 980c91d8 bbb4c1ea 97618a4b f03f4258 1948b2ee 4ee7ad67')).
a9c72db987e7 #QUALITY by cg
Claus Gittinger <cg@exept.de>
parents: 2053
diff changeset
   340
805
93f37c5c8c6b *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   341
    "
93f37c5c8c6b *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   342
     self run:#test07_sha224
93f37c5c8c6b *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   343
     self new test07_sha224
93f37c5c8c6b *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   344
    "
2122
a9c72db987e7 #QUALITY by cg
Claus Gittinger <cg@exept.de>
parents: 2053
diff changeset
   345
2142
8c3f70ccb842 #DOCUMENTATION by cg
Claus Gittinger <cg@exept.de>
parents: 2141
diff changeset
   346
    "Modified (format): / 24-03-2019 / 10:10:39 / Claus Gittinger"
805
93f37c5c8c6b *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   347
!
93f37c5c8c6b *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   348
93f37c5c8c6b *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   349
test08_sha384
93f37c5c8c6b *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   350
    |h|
93f37c5c8c6b *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   351
2122
a9c72db987e7 #QUALITY by cg
Claus Gittinger <cg@exept.de>
parents: 2053
diff changeset
   352
    "/ test vectors from https://www.di-mgt.com.au/sha_testvectors.html
a9c72db987e7 #QUALITY by cg
Claus Gittinger <cg@exept.de>
parents: 2053
diff changeset
   353
    "/ and others
a9c72db987e7 #QUALITY by cg
Claus Gittinger <cg@exept.de>
parents: 2053
diff changeset
   354
1447
2351db93aa5b package changes
Claus Gittinger <cg@exept.de>
parents: 1403
diff changeset
   355
    self
2122
a9c72db987e7 #QUALITY by cg
Claus Gittinger <cg@exept.de>
parents: 2053
diff changeset
   356
        skipIf:(SHA384Stream isBehavior not or:[SHA384Stream isLoaded not])
a9c72db987e7 #QUALITY by cg
Claus Gittinger <cg@exept.de>
parents: 2053
diff changeset
   357
        description:'SHA384Stream/libcrypt is not loaded'.
951
d9fe0a97fc74 class: RegressionTests::CryptTests
Stefan Vogel <sv@exept.de>
parents: 936
diff changeset
   358
805
93f37c5c8c6b *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   359
    h := SHA384Stream hashValueOf:''.
93f37c5c8c6b *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   360
    self assert:(h = (ByteArray fromHexString:'38b060a751ac96384cd9327eb1b1e36a21fdb71114be07434c0cc7bf63f6e1da274edebfe76f65fbd51ad2f14898b95b')).
93f37c5c8c6b *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   361
93f37c5c8c6b *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   362
    h := SHA384Stream hashValueOf:'The quick brown fox jumps over the lazy dog'.
93f37c5c8c6b *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   363
    self assert:(h = (ByteArray fromHexString:'ca737f1014a48f4c0b6dd43cb177b0afd9e5169367544c494011e3317dbf9a509cb1e5dc1e85a941bbee3d7f2afbc9b1')).
93f37c5c8c6b *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   364
2122
a9c72db987e7 #QUALITY by cg
Claus Gittinger <cg@exept.de>
parents: 2053
diff changeset
   365
    h := SHA384Stream hashValueOf:'abc'.
a9c72db987e7 #QUALITY by cg
Claus Gittinger <cg@exept.de>
parents: 2053
diff changeset
   366
    self assert:(h = (ByteArray fromHexStringWithSeparators:'cb00753f45a35e8b b5a03d699ac65007 272c32ab0eded163 1a8b605a43ff5bed 8086072ba1e7cc23 58baeca134c825a7')).
a9c72db987e7 #QUALITY by cg
Claus Gittinger <cg@exept.de>
parents: 2053
diff changeset
   367
a9c72db987e7 #QUALITY by cg
Claus Gittinger <cg@exept.de>
parents: 2053
diff changeset
   368
    h := SHA384Stream hashValueOf:'abcdbcdecdefdefgefghfghighijhijkijkljklmklmnlmnomnopnopq'.
a9c72db987e7 #QUALITY by cg
Claus Gittinger <cg@exept.de>
parents: 2053
diff changeset
   369
    self assert:(h = (ByteArray fromHexStringWithSeparators:'3391fdddfc8dc739 3707a65b1b470939 7cf8b1d162af05ab fe8f450de5f36bc6 b0455a8520bc4e6f 5fe95b1fe3c8452b')).
a9c72db987e7 #QUALITY by cg
Claus Gittinger <cg@exept.de>
parents: 2053
diff changeset
   370
a9c72db987e7 #QUALITY by cg
Claus Gittinger <cg@exept.de>
parents: 2053
diff changeset
   371
    h := SHA384Stream hashValueOf:'abcdefghbcdefghicdefghijdefghijkefghijklfghijklmghijklmnhijklmnoijklmnopjklmnopqklmnopqrlmnopqrsmnopqrstnopqrstu'.
a9c72db987e7 #QUALITY by cg
Claus Gittinger <cg@exept.de>
parents: 2053
diff changeset
   372
    self assert:(h = (ByteArray fromHexStringWithSeparators:'09330c33f71147e8 3d192fc782cd1b47 53111b173b3b05d2 2fa08086e3b0f712 fcc7c71a557e2db9 66c3e9fa91746039')).
a9c72db987e7 #QUALITY by cg
Claus Gittinger <cg@exept.de>
parents: 2053
diff changeset
   373
a9c72db987e7 #QUALITY by cg
Claus Gittinger <cg@exept.de>
parents: 2053
diff changeset
   374
    h := SHA384Stream hashValueOf:(String new:1000000 withAll:$a).
a9c72db987e7 #QUALITY by cg
Claus Gittinger <cg@exept.de>
parents: 2053
diff changeset
   375
    self assert:(h = (ByteArray fromHexStringWithSeparators:'9d0e1809716474cb 086e834e310a4a1c ed149e9c00f24852 7972cec5704c2a5b 07b8b3dc38ecc4eb ae97ddd87f3d8985')).
a9c72db987e7 #QUALITY by cg
Claus Gittinger <cg@exept.de>
parents: 2053
diff changeset
   376
805
93f37c5c8c6b *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   377
    "
93f37c5c8c6b *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   378
     self run:#test08_sha384
93f37c5c8c6b *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   379
     self new test08_sha384
93f37c5c8c6b *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   380
    "
2122
a9c72db987e7 #QUALITY by cg
Claus Gittinger <cg@exept.de>
parents: 2053
diff changeset
   381
a9c72db987e7 #QUALITY by cg
Claus Gittinger <cg@exept.de>
parents: 2053
diff changeset
   382
    "Modified (format): / 22-03-2019 / 12:33:59 / Claus Gittinger"
805
93f37c5c8c6b *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   383
!
93f37c5c8c6b *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   384
93f37c5c8c6b *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   385
test09_sha512
93f37c5c8c6b *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   386
    |h|
93f37c5c8c6b *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   387
2122
a9c72db987e7 #QUALITY by cg
Claus Gittinger <cg@exept.de>
parents: 2053
diff changeset
   388
    "/ test vectors from https://www.di-mgt.com.au/sha_testvectors.html
a9c72db987e7 #QUALITY by cg
Claus Gittinger <cg@exept.de>
parents: 2053
diff changeset
   389
    "/ and others
a9c72db987e7 #QUALITY by cg
Claus Gittinger <cg@exept.de>
parents: 2053
diff changeset
   390
1447
2351db93aa5b package changes
Claus Gittinger <cg@exept.de>
parents: 1403
diff changeset
   391
    self
2122
a9c72db987e7 #QUALITY by cg
Claus Gittinger <cg@exept.de>
parents: 2053
diff changeset
   392
        skipIf:(SHA512Stream isBehavior not or:[SHA512Stream isLoaded not])
a9c72db987e7 #QUALITY by cg
Claus Gittinger <cg@exept.de>
parents: 2053
diff changeset
   393
        description:'SHA512Stream/libcrypt is not loaded'.
951
d9fe0a97fc74 class: RegressionTests::CryptTests
Stefan Vogel <sv@exept.de>
parents: 936
diff changeset
   394
805
93f37c5c8c6b *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   395
    h := SHA512Stream hashValueOf:''.
93f37c5c8c6b *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   396
    self assert:(h = (ByteArray fromHexString:'cf83e1357eefb8bdf1542850d66d8007d620e4050b5715dc83f4a921d36ce9ce47d0d13c5d85f2b0ff8318d2877eec2f63b931bd47417a81a538327af927da3e')).
93f37c5c8c6b *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   397
93f37c5c8c6b *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   398
    h := SHA512Stream hashValueOf:'The quick brown fox jumps over the lazy dog'.
93f37c5c8c6b *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   399
    self assert:(h = (ByteArray fromHexString:'07e547d9586f6a73f73fbac0435ed76951218fb7d0c8d788a309d785436bbb642e93a252a954f23912547d1e8a3b5ed6e1bfd7097821233fa0538f3db854fee6')).
93f37c5c8c6b *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   400
2122
a9c72db987e7 #QUALITY by cg
Claus Gittinger <cg@exept.de>
parents: 2053
diff changeset
   401
    h := SHA512Stream hashValueOf:'abc'.
a9c72db987e7 #QUALITY by cg
Claus Gittinger <cg@exept.de>
parents: 2053
diff changeset
   402
    self assert:(h = (ByteArray fromHexStringWithSeparators:'ddaf35a193617aba cc417349ae204131 12e6fa4e89a97ea2 0a9eeee64b55d39a 2192992a274fc1a8 36ba3c23a3feebbd 454d4423643ce80e 2a9ac94fa54ca49f')).
a9c72db987e7 #QUALITY by cg
Claus Gittinger <cg@exept.de>
parents: 2053
diff changeset
   403
a9c72db987e7 #QUALITY by cg
Claus Gittinger <cg@exept.de>
parents: 2053
diff changeset
   404
    h := SHA512Stream hashValueOf:'abcdbcdecdefdefgefghfghighijhijkijkljklmklmnlmnomnopnopq'.
a9c72db987e7 #QUALITY by cg
Claus Gittinger <cg@exept.de>
parents: 2053
diff changeset
   405
    self assert:(h = (ByteArray fromHexStringWithSeparators:'204a8fc6dda82f0a 0ced7beb8e08a416 57c16ef468b228a8 279be331a703c335 96fd15c13b1b07f9 aa1d3bea57789ca0 31ad85c7a71dd703 54ec631238ca3445')).
a9c72db987e7 #QUALITY by cg
Claus Gittinger <cg@exept.de>
parents: 2053
diff changeset
   406
a9c72db987e7 #QUALITY by cg
Claus Gittinger <cg@exept.de>
parents: 2053
diff changeset
   407
    h := SHA512Stream hashValueOf:'abcdefghbcdefghicdefghijdefghijkefghijklfghijklmghijklmnhijklmnoijklmnopjklmnopqklmnopqrlmnopqrsmnopqrstnopqrstu'.
a9c72db987e7 #QUALITY by cg
Claus Gittinger <cg@exept.de>
parents: 2053
diff changeset
   408
    self assert:(h = (ByteArray fromHexStringWithSeparators:'8e959b75dae313da 8cf4f72814fc143f 8f7779c6eb9f7fa1 7299aeadb6889018 501d289e4900f7e4 331b99dec4b5433a c7d329eeb6dd2654 5e96e55b874be909')).
a9c72db987e7 #QUALITY by cg
Claus Gittinger <cg@exept.de>
parents: 2053
diff changeset
   409
a9c72db987e7 #QUALITY by cg
Claus Gittinger <cg@exept.de>
parents: 2053
diff changeset
   410
    h := SHA512Stream hashValueOf:(String new:1000000 withAll:$a).
a9c72db987e7 #QUALITY by cg
Claus Gittinger <cg@exept.de>
parents: 2053
diff changeset
   411
    self assert:(h = (ByteArray fromHexStringWithSeparators:'e718483d0ce76964 4e2e42c7bc15b463 8e1f98b13b204428 5632a803afa973eb de0ff244877ea60a 4cb0432ce577c31b eb009c5c2c49aa2e 4eadb217ad8cc09b')).
a9c72db987e7 #QUALITY by cg
Claus Gittinger <cg@exept.de>
parents: 2053
diff changeset
   412
805
93f37c5c8c6b *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   413
    "
93f37c5c8c6b *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   414
     self run:#test09_sha512
93f37c5c8c6b *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   415
     self new test09_sha512
93f37c5c8c6b *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   416
    "
2122
a9c72db987e7 #QUALITY by cg
Claus Gittinger <cg@exept.de>
parents: 2053
diff changeset
   417
a9c72db987e7 #QUALITY by cg
Claus Gittinger <cg@exept.de>
parents: 2053
diff changeset
   418
    "Modified: / 22-03-2019 / 12:36:56 / Claus Gittinger"
1020
a1a9948420e1 class: RegressionTests::CryptTests
Claus Gittinger <cg@exept.de>
parents: 951
diff changeset
   419
!
a1a9948420e1 class: RegressionTests::CryptTests
Claus Gittinger <cg@exept.de>
parents: 951
diff changeset
   420
a1a9948420e1 class: RegressionTests::CryptTests
Claus Gittinger <cg@exept.de>
parents: 951
diff changeset
   421
test10_des
1447
2351db93aa5b package changes
Claus Gittinger <cg@exept.de>
parents: 1403
diff changeset
   422
    |des crypt s s2|
1020
a1a9948420e1 class: RegressionTests::CryptTests
Claus Gittinger <cg@exept.de>
parents: 951
diff changeset
   423
a1a9948420e1 class: RegressionTests::CryptTests
Claus Gittinger <cg@exept.de>
parents: 951
diff changeset
   424
    des := DesCipher new key:#[12 34 56 78 90 12 34 56].
a1a9948420e1 class: RegressionTests::CryptTests
Claus Gittinger <cg@exept.de>
parents: 951
diff changeset
   425
    crypt := des encrypt:'12345678'.
a1a9948420e1 class: RegressionTests::CryptTests
Claus Gittinger <cg@exept.de>
parents: 951
diff changeset
   426
    self assert:(crypt = #[85 205 168 117 136 155 222 239]).
a1a9948420e1 class: RegressionTests::CryptTests
Claus Gittinger <cg@exept.de>
parents: 951
diff changeset
   427
a1a9948420e1 class: RegressionTests::CryptTests
Claus Gittinger <cg@exept.de>
parents: 951
diff changeset
   428
    "/ ------------------------------------------------
a1a9948420e1 class: RegressionTests::CryptTests
Claus Gittinger <cg@exept.de>
parents: 951
diff changeset
   429
a1a9948420e1 class: RegressionTests::CryptTests
Claus Gittinger <cg@exept.de>
parents: 951
diff changeset
   430
    des := DesCipher new key:#[12 34 56 78 90 12 34 56].
a1a9948420e1 class: RegressionTests::CryptTests
Claus Gittinger <cg@exept.de>
parents: 951
diff changeset
   431
    s := '12345678'.
a1a9948420e1 class: RegressionTests::CryptTests
Claus Gittinger <cg@exept.de>
parents: 951
diff changeset
   432
    10 timesRepeat:[
1447
2351db93aa5b package changes
Claus Gittinger <cg@exept.de>
parents: 1403
diff changeset
   433
	s2 := ByteArray new:s size.
2351db93aa5b package changes
Claus Gittinger <cg@exept.de>
parents: 1403
diff changeset
   434
	des cryptBlock:s from:1 "to:nil" into:s2 startingAt:1 encrypt:true.
2351db93aa5b package changes
Claus Gittinger <cg@exept.de>
parents: 1403
diff changeset
   435
	s := s2.
1020
a1a9948420e1 class: RegressionTests::CryptTests
Claus Gittinger <cg@exept.de>
parents: 951
diff changeset
   436
    ].
a1a9948420e1 class: RegressionTests::CryptTests
Claus Gittinger <cg@exept.de>
parents: 951
diff changeset
   437
    self assert:(s = #[212 114 83 160 109 1 37 83]).
a1a9948420e1 class: RegressionTests::CryptTests
Claus Gittinger <cg@exept.de>
parents: 951
diff changeset
   438
1023
ddc17abfb668 class: RegressionTests::CryptTests
Claus Gittinger <cg@exept.de>
parents: 1022
diff changeset
   439
    "/ ------------------------------------------------
ddc17abfb668 class: RegressionTests::CryptTests
Claus Gittinger <cg@exept.de>
parents: 1022
diff changeset
   440
ddc17abfb668 class: RegressionTests::CryptTests
Claus Gittinger <cg@exept.de>
parents: 1022
diff changeset
   441
    des := DesCipher new key:#[16rFF 16r80 56 78 90 12 34 56].
ddc17abfb668 class: RegressionTests::CryptTests
Claus Gittinger <cg@exept.de>
parents: 1022
diff changeset
   442
    crypt := des encrypt:'12345678'.
ddc17abfb668 class: RegressionTests::CryptTests
Claus Gittinger <cg@exept.de>
parents: 1022
diff changeset
   443
    self assert:(crypt = #[54 60 159 218 32 8 70 60]).
ddc17abfb668 class: RegressionTests::CryptTests
Claus Gittinger <cg@exept.de>
parents: 1022
diff changeset
   444
ddc17abfb668 class: RegressionTests::CryptTests
Claus Gittinger <cg@exept.de>
parents: 1022
diff changeset
   445
1020
a1a9948420e1 class: RegressionTests::CryptTests
Claus Gittinger <cg@exept.de>
parents: 951
diff changeset
   446
    "
a1a9948420e1 class: RegressionTests::CryptTests
Claus Gittinger <cg@exept.de>
parents: 951
diff changeset
   447
     self run:#test10_des
a1a9948420e1 class: RegressionTests::CryptTests
Claus Gittinger <cg@exept.de>
parents: 951
diff changeset
   448
     self new test10_des
a1a9948420e1 class: RegressionTests::CryptTests
Claus Gittinger <cg@exept.de>
parents: 951
diff changeset
   449
    "
1023
ddc17abfb668 class: RegressionTests::CryptTests
Claus Gittinger <cg@exept.de>
parents: 1022
diff changeset
   450
ddc17abfb668 class: RegressionTests::CryptTests
Claus Gittinger <cg@exept.de>
parents: 1022
diff changeset
   451
    "Modified: / 25-11-2013 / 11:45:34 / cg"
1035
2be1f5b478ca class: RegressionTests::CryptTests
Claus Gittinger <cg@exept.de>
parents: 1023
diff changeset
   452
!
2be1f5b478ca class: RegressionTests::CryptTests
Claus Gittinger <cg@exept.de>
parents: 1023
diff changeset
   453
2be1f5b478ca class: RegressionTests::CryptTests
Claus Gittinger <cg@exept.de>
parents: 1023
diff changeset
   454
test11_rsaKey
2be1f5b478ca class: RegressionTests::CryptTests
Claus Gittinger <cg@exept.de>
parents: 1023
diff changeset
   455
    |dir fn key ks plain cipher|
2be1f5b478ca class: RegressionTests::CryptTests
Claus Gittinger <cg@exept.de>
parents: 1023
diff changeset
   456
2be1f5b478ca class: RegressionTests::CryptTests
Claus Gittinger <cg@exept.de>
parents: 1023
diff changeset
   457
    dir := Smalltalk packageDirectoryForPackageId:'exept:expecco'.
2be1f5b478ca class: RegressionTests::CryptTests
Claus Gittinger <cg@exept.de>
parents: 1023
diff changeset
   458
    self skipIf:dir isNil description:'directory with test key is not present'.
2be1f5b478ca class: RegressionTests::CryptTests
Claus Gittinger <cg@exept.de>
parents: 1023
diff changeset
   459
    fn := dir asFilename construct:'license/expeccoKey.pem'.
2be1f5b478ca class: RegressionTests::CryptTests
Claus Gittinger <cg@exept.de>
parents: 1023
diff changeset
   460
    self skipIf:fn exists not description:'test key is not present'.
2be1f5b478ca class: RegressionTests::CryptTests
Claus Gittinger <cg@exept.de>
parents: 1023
diff changeset
   461
2be1f5b478ca class: RegressionTests::CryptTests
Claus Gittinger <cg@exept.de>
parents: 1023
diff changeset
   462
    key := RSASecretCryptKey fromPemStream:fn readStream.
2be1f5b478ca class: RegressionTests::CryptTests
Claus Gittinger <cg@exept.de>
parents: 1023
diff changeset
   463
2be1f5b478ca class: RegressionTests::CryptTests
Claus Gittinger <cg@exept.de>
parents: 1023
diff changeset
   464
    ks := RSACryptStream new.
2be1f5b478ca class: RegressionTests::CryptTests
Claus Gittinger <cg@exept.de>
parents: 1023
diff changeset
   465
    ks encryptWithSecretKey:true.
2be1f5b478ca class: RegressionTests::CryptTests
Claus Gittinger <cg@exept.de>
parents: 1023
diff changeset
   466
    ks key:key.
2be1f5b478ca class: RegressionTests::CryptTests
Claus Gittinger <cg@exept.de>
parents: 1023
diff changeset
   467
    ks stream:#[] writeStream.
2be1f5b478ca class: RegressionTests::CryptTests
Claus Gittinger <cg@exept.de>
parents: 1023
diff changeset
   468
2be1f5b478ca class: RegressionTests::CryptTests
Claus Gittinger <cg@exept.de>
parents: 1023
diff changeset
   469
    plain := '12345678901234567890'.
2be1f5b478ca class: RegressionTests::CryptTests
Claus Gittinger <cg@exept.de>
parents: 1023
diff changeset
   470
    ks encrypt:plain.
2be1f5b478ca class: RegressionTests::CryptTests
Claus Gittinger <cg@exept.de>
parents: 1023
diff changeset
   471
    cipher := ks stream contents.
2be1f5b478ca class: RegressionTests::CryptTests
Claus Gittinger <cg@exept.de>
parents: 1023
diff changeset
   472
2be1f5b478ca class: RegressionTests::CryptTests
Claus Gittinger <cg@exept.de>
parents: 1023
diff changeset
   473
    ks := RSACryptStream new.
2be1f5b478ca class: RegressionTests::CryptTests
Claus Gittinger <cg@exept.de>
parents: 1023
diff changeset
   474
    ks encryptWithSecretKey:true.
2be1f5b478ca class: RegressionTests::CryptTests
Claus Gittinger <cg@exept.de>
parents: 1023
diff changeset
   475
    ks key:key.
2be1f5b478ca class: RegressionTests::CryptTests
Claus Gittinger <cg@exept.de>
parents: 1023
diff changeset
   476
    ks stream:#[] writeStream.
2be1f5b478ca class: RegressionTests::CryptTests
Claus Gittinger <cg@exept.de>
parents: 1023
diff changeset
   477
2be1f5b478ca class: RegressionTests::CryptTests
Claus Gittinger <cg@exept.de>
parents: 1023
diff changeset
   478
    ks decrypt:cipher.
2be1f5b478ca class: RegressionTests::CryptTests
Claus Gittinger <cg@exept.de>
parents: 1023
diff changeset
   479
2be1f5b478ca class: RegressionTests::CryptTests
Claus Gittinger <cg@exept.de>
parents: 1023
diff changeset
   480
    self assert:(ks stream contents asString = plain).
2be1f5b478ca class: RegressionTests::CryptTests
Claus Gittinger <cg@exept.de>
parents: 1023
diff changeset
   481
1036
c42c54df984e class: RegressionTests::CryptTests
Claus Gittinger <cg@exept.de>
parents: 1035
diff changeset
   482
    "/ -------------------------------------------
c42c54df984e class: RegressionTests::CryptTests
Claus Gittinger <cg@exept.de>
parents: 1035
diff changeset
   483
c42c54df984e class: RegressionTests::CryptTests
Claus Gittinger <cg@exept.de>
parents: 1035
diff changeset
   484
    ks := RSACryptStream new.
c42c54df984e class: RegressionTests::CryptTests
Claus Gittinger <cg@exept.de>
parents: 1035
diff changeset
   485
    ks encryptWithSecretKey:true.
c42c54df984e class: RegressionTests::CryptTests
Claus Gittinger <cg@exept.de>
parents: 1035
diff changeset
   486
    ks key:key.
c42c54df984e class: RegressionTests::CryptTests
Claus Gittinger <cg@exept.de>
parents: 1035
diff changeset
   487
    ks stream:#[] writeStream.
c42c54df984e class: RegressionTests::CryptTests
Claus Gittinger <cg@exept.de>
parents: 1035
diff changeset
   488
c42c54df984e class: RegressionTests::CryptTests
Claus Gittinger <cg@exept.de>
parents: 1035
diff changeset
   489
    plain := #[16rFF 16r80 16r00].
c42c54df984e class: RegressionTests::CryptTests
Claus Gittinger <cg@exept.de>
parents: 1035
diff changeset
   490
    ks encrypt:plain.
c42c54df984e class: RegressionTests::CryptTests
Claus Gittinger <cg@exept.de>
parents: 1035
diff changeset
   491
    cipher := ks stream contents.
c42c54df984e class: RegressionTests::CryptTests
Claus Gittinger <cg@exept.de>
parents: 1035
diff changeset
   492
c42c54df984e class: RegressionTests::CryptTests
Claus Gittinger <cg@exept.de>
parents: 1035
diff changeset
   493
    ks := RSACryptStream new.
c42c54df984e class: RegressionTests::CryptTests
Claus Gittinger <cg@exept.de>
parents: 1035
diff changeset
   494
    ks encryptWithSecretKey:true.
c42c54df984e class: RegressionTests::CryptTests
Claus Gittinger <cg@exept.de>
parents: 1035
diff changeset
   495
    ks key:key.
c42c54df984e class: RegressionTests::CryptTests
Claus Gittinger <cg@exept.de>
parents: 1035
diff changeset
   496
    ks stream:#[] writeStream.
c42c54df984e class: RegressionTests::CryptTests
Claus Gittinger <cg@exept.de>
parents: 1035
diff changeset
   497
c42c54df984e class: RegressionTests::CryptTests
Claus Gittinger <cg@exept.de>
parents: 1035
diff changeset
   498
    ks decrypt:cipher.
c42c54df984e class: RegressionTests::CryptTests
Claus Gittinger <cg@exept.de>
parents: 1035
diff changeset
   499
c42c54df984e class: RegressionTests::CryptTests
Claus Gittinger <cg@exept.de>
parents: 1035
diff changeset
   500
    self assert:(ks stream contents = plain).
c42c54df984e class: RegressionTests::CryptTests
Claus Gittinger <cg@exept.de>
parents: 1035
diff changeset
   501
1035
2be1f5b478ca class: RegressionTests::CryptTests
Claus Gittinger <cg@exept.de>
parents: 1023
diff changeset
   502
    "
2be1f5b478ca class: RegressionTests::CryptTests
Claus Gittinger <cg@exept.de>
parents: 1023
diff changeset
   503
     self run:#test11_rsaKey
2be1f5b478ca class: RegressionTests::CryptTests
Claus Gittinger <cg@exept.de>
parents: 1023
diff changeset
   504
     self new test11_rsaKey
2be1f5b478ca class: RegressionTests::CryptTests
Claus Gittinger <cg@exept.de>
parents: 1023
diff changeset
   505
    "
2be1f5b478ca class: RegressionTests::CryptTests
Claus Gittinger <cg@exept.de>
parents: 1023
diff changeset
   506
2be1f5b478ca class: RegressionTests::CryptTests
Claus Gittinger <cg@exept.de>
parents: 1023
diff changeset
   507
    "Created: / 02-12-2013 / 12:58:19 / cg"
1511
1376ae5d577f #QUALITY by cg
Claus Gittinger <cg@exept.de>
parents: 1447
diff changeset
   508
!
1376ae5d577f #QUALITY by cg
Claus Gittinger <cg@exept.de>
parents: 1447
diff changeset
   509
1376ae5d577f #QUALITY by cg
Claus Gittinger <cg@exept.de>
parents: 1447
diff changeset
   510
test12_whirlpool
1376ae5d577f #QUALITY by cg
Claus Gittinger <cg@exept.de>
parents: 1447
diff changeset
   511
    |h|
1376ae5d577f #QUALITY by cg
Claus Gittinger <cg@exept.de>
parents: 1447
diff changeset
   512
1376ae5d577f #QUALITY by cg
Claus Gittinger <cg@exept.de>
parents: 1447
diff changeset
   513
    self
1376ae5d577f #QUALITY by cg
Claus Gittinger <cg@exept.de>
parents: 1447
diff changeset
   514
        skipIf:(WhirlpoolStream isBehavior not or:[WhirlpoolStream isLoaded not])
1376ae5d577f #QUALITY by cg
Claus Gittinger <cg@exept.de>
parents: 1447
diff changeset
   515
        description:'WhirlpoolStream/libcrypt is not loaded'.
1376ae5d577f #QUALITY by cg
Claus Gittinger <cg@exept.de>
parents: 1447
diff changeset
   516
1376ae5d577f #QUALITY by cg
Claus Gittinger <cg@exept.de>
parents: 1447
diff changeset
   517
    "/ hashes taken from wikipedia-page on whirlpool
1376ae5d577f #QUALITY by cg
Claus Gittinger <cg@exept.de>
parents: 1447
diff changeset
   518
    
1376ae5d577f #QUALITY by cg
Claus Gittinger <cg@exept.de>
parents: 1447
diff changeset
   519
    h := WhirlpoolStream hashValueOf:''.
1376ae5d577f #QUALITY by cg
Claus Gittinger <cg@exept.de>
parents: 1447
diff changeset
   520
    self assert:(h = (ByteArray fromHexString:'19FA61D75522A4669B44E39C1D2E1726C530232130D407F89AFEE0964997F7A73E83BE698B288FEBCF88E3E03C4F0757EA8964E59B63D93708B138CC42A66EB3')).
1376ae5d577f #QUALITY by cg
Claus Gittinger <cg@exept.de>
parents: 1447
diff changeset
   521
1376ae5d577f #QUALITY by cg
Claus Gittinger <cg@exept.de>
parents: 1447
diff changeset
   522
    h := WhirlpoolStream hashValueOf:'The quick brown fox jumps over the lazy dog'.
1376ae5d577f #QUALITY by cg
Claus Gittinger <cg@exept.de>
parents: 1447
diff changeset
   523
    self assert:(h = (ByteArray fromHexString:'B97DE512E91E3828B40D2B0FDCE9CEB3C4A71F9BEA8D88E75C4FA854DF36725FD2B52EB6544EDCACD6F8BEDDFEA403CB55AE31F03AD62A5EF54E42EE82C3FB35')).
1376ae5d577f #QUALITY by cg
Claus Gittinger <cg@exept.de>
parents: 1447
diff changeset
   524
1512
4ce2945272dd #QUALITY by cg
Claus Gittinger <cg@exept.de>
parents: 1511
diff changeset
   525
    h := WhirlpoolStream hashValueOf:'The quick brown fox jumps over the lazy eog'.
4ce2945272dd #QUALITY by cg
Claus Gittinger <cg@exept.de>
parents: 1511
diff changeset
   526
    self assert:(h = (ByteArray fromHexString:'C27BA124205F72E6847F3E19834F925CC666D0974167AF915BB462420ED40CC50900D85A1F923219D832357750492D5C143011A76988344C2635E69D06F2D38C')).
4ce2945272dd #QUALITY by cg
Claus Gittinger <cg@exept.de>
parents: 1511
diff changeset
   527
1511
1376ae5d577f #QUALITY by cg
Claus Gittinger <cg@exept.de>
parents: 1447
diff changeset
   528
    "
1376ae5d577f #QUALITY by cg
Claus Gittinger <cg@exept.de>
parents: 1447
diff changeset
   529
     self run:#test12_whirlpool
1376ae5d577f #QUALITY by cg
Claus Gittinger <cg@exept.de>
parents: 1447
diff changeset
   530
     self new test12_whirlpool
1376ae5d577f #QUALITY by cg
Claus Gittinger <cg@exept.de>
parents: 1447
diff changeset
   531
    "
1649
f195a2d879cd #QUALITY by cg
Claus Gittinger <cg@exept.de>
parents: 1512
diff changeset
   532
!
f195a2d879cd #QUALITY by cg
Claus Gittinger <cg@exept.de>
parents: 1512
diff changeset
   533
f195a2d879cd #QUALITY by cg
Claus Gittinger <cg@exept.de>
parents: 1512
diff changeset
   534
test13_sha3
f195a2d879cd #QUALITY by cg
Claus Gittinger <cg@exept.de>
parents: 1512
diff changeset
   535
    |h|
f195a2d879cd #QUALITY by cg
Claus Gittinger <cg@exept.de>
parents: 1512
diff changeset
   536
f195a2d879cd #QUALITY by cg
Claus Gittinger <cg@exept.de>
parents: 1512
diff changeset
   537
    self
f195a2d879cd #QUALITY by cg
Claus Gittinger <cg@exept.de>
parents: 1512
diff changeset
   538
        skipIf:(SHA3_256Stream isBehavior not or:[SHA3_256Stream isLoaded not])
f195a2d879cd #QUALITY by cg
Claus Gittinger <cg@exept.de>
parents: 1512
diff changeset
   539
        description:'SHA3Stream/libcrypt is not loaded'.
f195a2d879cd #QUALITY by cg
Claus Gittinger <cg@exept.de>
parents: 1512
diff changeset
   540
f195a2d879cd #QUALITY by cg
Claus Gittinger <cg@exept.de>
parents: 1512
diff changeset
   541
    "/ hashes taken from wikipedia-page on SHA3
2139
021eb1d8dd65 #BUGFIX by cg
Claus Gittinger <cg@exept.de>
parents: 2138
diff changeset
   542
    false ifTrue:[
021eb1d8dd65 #BUGFIX by cg
Claus Gittinger <cg@exept.de>
parents: 2138
diff changeset
   543
        h := SHA3_224Stream hashValueOf:''.
021eb1d8dd65 #BUGFIX by cg
Claus Gittinger <cg@exept.de>
parents: 2138
diff changeset
   544
        self assert:(h = (ByteArray fromHexString:'6b4e03423667dbb73b6e15454f0eb1abd4597f9a1b078e3f5b5a6bc7')).
021eb1d8dd65 #BUGFIX by cg
Claus Gittinger <cg@exept.de>
parents: 2138
diff changeset
   545
    ].
1649
f195a2d879cd #QUALITY by cg
Claus Gittinger <cg@exept.de>
parents: 1512
diff changeset
   546
f195a2d879cd #QUALITY by cg
Claus Gittinger <cg@exept.de>
parents: 1512
diff changeset
   547
    h := SHA3_256Stream hashValueOf:''.
f195a2d879cd #QUALITY by cg
Claus Gittinger <cg@exept.de>
parents: 1512
diff changeset
   548
    self assert:(h = (ByteArray fromHexString:'a7ffc6f8bf1ed76651c14756a061d662f580ff4de43b49fa82d80a4b80f8434a')).
f195a2d879cd #QUALITY by cg
Claus Gittinger <cg@exept.de>
parents: 1512
diff changeset
   549
f195a2d879cd #QUALITY by cg
Claus Gittinger <cg@exept.de>
parents: 1512
diff changeset
   550
    h := SHA3_384Stream hashValueOf:''.
f195a2d879cd #QUALITY by cg
Claus Gittinger <cg@exept.de>
parents: 1512
diff changeset
   551
    self assert:(h = (ByteArray fromHexString:'0c63a75b845e4f7d01107d852e4c2485c51a50aaaa94fc61995e71bbee983a2ac3713831264adb47fb6bd1e058d5f004')).
f195a2d879cd #QUALITY by cg
Claus Gittinger <cg@exept.de>
parents: 1512
diff changeset
   552
f195a2d879cd #QUALITY by cg
Claus Gittinger <cg@exept.de>
parents: 1512
diff changeset
   553
    h := SHA3_512Stream hashValueOf:''.
f195a2d879cd #QUALITY by cg
Claus Gittinger <cg@exept.de>
parents: 1512
diff changeset
   554
    self assert:(h = (ByteArray fromHexString:'a69f73cca23a9ac5c8b567dc185a756e97c982164fe25859e0d1dcc1475c80a615b2123af1f5f94c11e3e9402c3ac558f500199d95b6d3e301758586281dcd26')).
f195a2d879cd #QUALITY by cg
Claus Gittinger <cg@exept.de>
parents: 1512
diff changeset
   555
f195a2d879cd #QUALITY by cg
Claus Gittinger <cg@exept.de>
parents: 1512
diff changeset
   556
2139
021eb1d8dd65 #BUGFIX by cg
Claus Gittinger <cg@exept.de>
parents: 2138
diff changeset
   557
    false ifTrue:[
021eb1d8dd65 #BUGFIX by cg
Claus Gittinger <cg@exept.de>
parents: 2138
diff changeset
   558
        h := SHA3_Shake128_256Stream hashValueOf:''.
021eb1d8dd65 #BUGFIX by cg
Claus Gittinger <cg@exept.de>
parents: 2138
diff changeset
   559
        self assert:(h = (ByteArray fromHexString:'7f9c2ba4e88f827d616045507605853ed73b8093f6efbc88eb1a6eacfa66ef26')).
1649
f195a2d879cd #QUALITY by cg
Claus Gittinger <cg@exept.de>
parents: 1512
diff changeset
   560
2139
021eb1d8dd65 #BUGFIX by cg
Claus Gittinger <cg@exept.de>
parents: 2138
diff changeset
   561
        h := SHA3_Shake256_512Stream hashValueOf:''.
021eb1d8dd65 #BUGFIX by cg
Claus Gittinger <cg@exept.de>
parents: 2138
diff changeset
   562
        self assert:(h = (ByteArray fromHexString:'46b9dd2b0ba88d13233b3feb743eeb243fcd52ea62b81b82b50c27646ed5762fd75dc4ddd8c0f200cb05019d67b592f6fc821c49479ab48640292eacb3b7c4be')).
1649
f195a2d879cd #QUALITY by cg
Claus Gittinger <cg@exept.de>
parents: 1512
diff changeset
   563
2139
021eb1d8dd65 #BUGFIX by cg
Claus Gittinger <cg@exept.de>
parents: 2138
diff changeset
   564
        h := SHA3_Shake128_256Stream hashValueOf:'The quick brown fox jumps over the lazy dog'.
021eb1d8dd65 #BUGFIX by cg
Claus Gittinger <cg@exept.de>
parents: 2138
diff changeset
   565
        self assert:(h = (ByteArray fromHexString:'f4202e3c5852f9182a0430fd8144f0a74b95e7417ecae17db0f8cfeed0e3e66e')).
1649
f195a2d879cd #QUALITY by cg
Claus Gittinger <cg@exept.de>
parents: 1512
diff changeset
   566
2139
021eb1d8dd65 #BUGFIX by cg
Claus Gittinger <cg@exept.de>
parents: 2138
diff changeset
   567
        h := SHA3_Shake128_256Stream hashValueOf:'The quick brown fox jumps over the lazy dof'.
021eb1d8dd65 #BUGFIX by cg
Claus Gittinger <cg@exept.de>
parents: 2138
diff changeset
   568
        self assert:(h = (ByteArray fromHexString:'853f4538be0db9621a6cea659a06c1107b1f83f02b13d18297bd39d7411cf10c')).
021eb1d8dd65 #BUGFIX by cg
Claus Gittinger <cg@exept.de>
parents: 2138
diff changeset
   569
    ].
021eb1d8dd65 #BUGFIX by cg
Claus Gittinger <cg@exept.de>
parents: 2138
diff changeset
   570
    
1649
f195a2d879cd #QUALITY by cg
Claus Gittinger <cg@exept.de>
parents: 1512
diff changeset
   571
    "
f195a2d879cd #QUALITY by cg
Claus Gittinger <cg@exept.de>
parents: 1512
diff changeset
   572
     self run:#test13_sha3
f195a2d879cd #QUALITY by cg
Claus Gittinger <cg@exept.de>
parents: 1512
diff changeset
   573
     self new test13_sha3
f195a2d879cd #QUALITY by cg
Claus Gittinger <cg@exept.de>
parents: 1512
diff changeset
   574
    "
f195a2d879cd #QUALITY by cg
Claus Gittinger <cg@exept.de>
parents: 1512
diff changeset
   575
f195a2d879cd #QUALITY by cg
Claus Gittinger <cg@exept.de>
parents: 1512
diff changeset
   576
    "Created: / 27-07-2017 / 13:40:51 / cg"
2139
021eb1d8dd65 #BUGFIX by cg
Claus Gittinger <cg@exept.de>
parents: 2138
diff changeset
   577
    "Modified: / 23-03-2019 / 22:41:19 / Claus Gittinger"
1690
899889bd8404 #UI_ENHANCEMENT by cg
Claus Gittinger <cg@exept.de>
parents: 1649
diff changeset
   578
!
899889bd8404 #UI_ENHANCEMENT by cg
Claus Gittinger <cg@exept.de>
parents: 1649
diff changeset
   579
899889bd8404 #UI_ENHANCEMENT by cg
Claus Gittinger <cg@exept.de>
parents: 1649
diff changeset
   580
test14_aesRijndael
899889bd8404 #UI_ENHANCEMENT by cg
Claus Gittinger <cg@exept.de>
parents: 1649
diff changeset
   581
    |plaintext key crypted hx ecb cbc ofb ctr iv|
899889bd8404 #UI_ENHANCEMENT by cg
Claus Gittinger <cg@exept.de>
parents: 1649
diff changeset
   582
899889bd8404 #UI_ENHANCEMENT by cg
Claus Gittinger <cg@exept.de>
parents: 1649
diff changeset
   583
    "/ ECB-AES-256
899889bd8404 #UI_ENHANCEMENT by cg
Claus Gittinger <cg@exept.de>
parents: 1649
diff changeset
   584
899889bd8404 #UI_ENHANCEMENT by cg
Claus Gittinger <cg@exept.de>
parents: 1649
diff changeset
   585
    plaintext := #[ 0 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15
899889bd8404 #UI_ENHANCEMENT by cg
Claus Gittinger <cg@exept.de>
parents: 1649
diff changeset
   586
                    16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 ].
899889bd8404 #UI_ENHANCEMENT by cg
Claus Gittinger <cg@exept.de>
parents: 1649
diff changeset
   587
    key := #[ 1 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
899889bd8404 #UI_ENHANCEMENT by cg
Claus Gittinger <cg@exept.de>
parents: 1649
diff changeset
   588
              0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 ].
899889bd8404 #UI_ENHANCEMENT by cg
Claus Gittinger <cg@exept.de>
parents: 1649
diff changeset
   589
    ecb := RijndaelCipher new key:key mode:#ECB.
899889bd8404 #UI_ENHANCEMENT by cg
Claus Gittinger <cg@exept.de>
parents: 1649
diff changeset
   590
    crypted := ecb encrypt:plaintext.
899889bd8404 #UI_ENHANCEMENT by cg
Claus Gittinger <cg@exept.de>
parents: 1649
diff changeset
   591
    hx := crypted hexPrintString asLowercase.
899889bd8404 #UI_ENHANCEMENT by cg
Claus Gittinger <cg@exept.de>
parents: 1649
diff changeset
   592
    self assert:(hx = 'f2258e225d794572393a6484cfced7cf925d1aa18366bcd93c33d104294c8a6f').
899889bd8404 #UI_ENHANCEMENT by cg
Claus Gittinger <cg@exept.de>
parents: 1649
diff changeset
   593
899889bd8404 #UI_ENHANCEMENT by cg
Claus Gittinger <cg@exept.de>
parents: 1649
diff changeset
   594
    ecb := RijndaelCipher new key:key mode:#ECB.
899889bd8404 #UI_ENHANCEMENT by cg
Claus Gittinger <cg@exept.de>
parents: 1649
diff changeset
   595
    self assert:(ecb decrypt:crypted) = plaintext.
899889bd8404 #UI_ENHANCEMENT by cg
Claus Gittinger <cg@exept.de>
parents: 1649
diff changeset
   596
    plaintext := #[ 0 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15
899889bd8404 #UI_ENHANCEMENT by cg
Claus Gittinger <cg@exept.de>
parents: 1649
diff changeset
   597
                    16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 ].
899889bd8404 #UI_ENHANCEMENT by cg
Claus Gittinger <cg@exept.de>
parents: 1649
diff changeset
   598
    key := #[ 1 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
899889bd8404 #UI_ENHANCEMENT by cg
Claus Gittinger <cg@exept.de>
parents: 1649
diff changeset
   599
              0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 ].
899889bd8404 #UI_ENHANCEMENT by cg
Claus Gittinger <cg@exept.de>
parents: 1649
diff changeset
   600
    cbc := RijndaelCipher new key:key mode:#CBC.
899889bd8404 #UI_ENHANCEMENT by cg
Claus Gittinger <cg@exept.de>
parents: 1649
diff changeset
   601
    crypted := cbc encrypt:plaintext.
899889bd8404 #UI_ENHANCEMENT by cg
Claus Gittinger <cg@exept.de>
parents: 1649
diff changeset
   602
    hx := crypted hexPrintString asLowercase.
899889bd8404 #UI_ENHANCEMENT by cg
Claus Gittinger <cg@exept.de>
parents: 1649
diff changeset
   603
    self assert:(hx = 'f2258e225d794572393a6484cfced7cfb487a41f6b6286c00c9c8d80cb3ee9f8').
899889bd8404 #UI_ENHANCEMENT by cg
Claus Gittinger <cg@exept.de>
parents: 1649
diff changeset
   604
    cbc := RijndaelCipher new key:key mode:#CBC.
899889bd8404 #UI_ENHANCEMENT by cg
Claus Gittinger <cg@exept.de>
parents: 1649
diff changeset
   605
    self assert:(cbc decrypt:crypted) = plaintext.
899889bd8404 #UI_ENHANCEMENT by cg
Claus Gittinger <cg@exept.de>
parents: 1649
diff changeset
   606
     
899889bd8404 #UI_ENHANCEMENT by cg
Claus Gittinger <cg@exept.de>
parents: 1649
diff changeset
   607
    "/ ECB-AES-256
899889bd8404 #UI_ENHANCEMENT by cg
Claus Gittinger <cg@exept.de>
parents: 1649
diff changeset
   608
    
899889bd8404 #UI_ENHANCEMENT by cg
Claus Gittinger <cg@exept.de>
parents: 1649
diff changeset
   609
    plaintext := #[ 0 17 34 51 68 85 102 119
899889bd8404 #UI_ENHANCEMENT by cg
Claus Gittinger <cg@exept.de>
parents: 1649
diff changeset
   610
                    136 153 170 187 204 221 238 255 ] asString.
899889bd8404 #UI_ENHANCEMENT by cg
Claus Gittinger <cg@exept.de>
parents: 1649
diff changeset
   611
    key := #[ 0 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15
899889bd8404 #UI_ENHANCEMENT by cg
Claus Gittinger <cg@exept.de>
parents: 1649
diff changeset
   612
              16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 ] asString.
899889bd8404 #UI_ENHANCEMENT by cg
Claus Gittinger <cg@exept.de>
parents: 1649
diff changeset
   613
    ecb := RijndaelCipher new key:key mode:#ECB.
899889bd8404 #UI_ENHANCEMENT by cg
Claus Gittinger <cg@exept.de>
parents: 1649
diff changeset
   614
    crypted := ecb encrypt:plaintext.
899889bd8404 #UI_ENHANCEMENT by cg
Claus Gittinger <cg@exept.de>
parents: 1649
diff changeset
   615
    hx := crypted hexPrintString asLowercase.
899889bd8404 #UI_ENHANCEMENT by cg
Claus Gittinger <cg@exept.de>
parents: 1649
diff changeset
   616
    self assert:(hx = '8ea2b7ca516745bfeafc49904b496089').
899889bd8404 #UI_ENHANCEMENT by cg
Claus Gittinger <cg@exept.de>
parents: 1649
diff changeset
   617
    ecb := RijndaelCipher new key:key mode:#ECB.
899889bd8404 #UI_ENHANCEMENT by cg
Claus Gittinger <cg@exept.de>
parents: 1649
diff changeset
   618
    self assert:(ecb decrypt:crypted) asString = plaintext.
899889bd8404 #UI_ENHANCEMENT by cg
Claus Gittinger <cg@exept.de>
parents: 1649
diff changeset
   619
     
899889bd8404 #UI_ENHANCEMENT by cg
Claus Gittinger <cg@exept.de>
parents: 1649
diff changeset
   620
    "/ ECB-AES-192
899889bd8404 #UI_ENHANCEMENT by cg
Claus Gittinger <cg@exept.de>
parents: 1649
diff changeset
   621
    
899889bd8404 #UI_ENHANCEMENT by cg
Claus Gittinger <cg@exept.de>
parents: 1649
diff changeset
   622
    plaintext := #[ 0 17 34 51 68 85 102 119
899889bd8404 #UI_ENHANCEMENT by cg
Claus Gittinger <cg@exept.de>
parents: 1649
diff changeset
   623
                    136 153 170 187 204 221 238 255 ] asString.
899889bd8404 #UI_ENHANCEMENT by cg
Claus Gittinger <cg@exept.de>
parents: 1649
diff changeset
   624
    key := #[ 0 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15
899889bd8404 #UI_ENHANCEMENT by cg
Claus Gittinger <cg@exept.de>
parents: 1649
diff changeset
   625
              16 17 18 19 20 21 22 23 ] asString.
899889bd8404 #UI_ENHANCEMENT by cg
Claus Gittinger <cg@exept.de>
parents: 1649
diff changeset
   626
    ecb := RijndaelCipher new key:key mode:#ECB.
899889bd8404 #UI_ENHANCEMENT by cg
Claus Gittinger <cg@exept.de>
parents: 1649
diff changeset
   627
    crypted := ecb encrypt:plaintext.
899889bd8404 #UI_ENHANCEMENT by cg
Claus Gittinger <cg@exept.de>
parents: 1649
diff changeset
   628
    hx := crypted hexPrintString asLowercase.
899889bd8404 #UI_ENHANCEMENT by cg
Claus Gittinger <cg@exept.de>
parents: 1649
diff changeset
   629
    self assert:(hx = 'dda97ca4864cdfe06eaf70a0ec0d7191').
899889bd8404 #UI_ENHANCEMENT by cg
Claus Gittinger <cg@exept.de>
parents: 1649
diff changeset
   630
    ecb := RijndaelCipher new key:key mode:#ECB.
899889bd8404 #UI_ENHANCEMENT by cg
Claus Gittinger <cg@exept.de>
parents: 1649
diff changeset
   631
    self assert:(ecb decrypt:crypted) asString = plaintext.
899889bd8404 #UI_ENHANCEMENT by cg
Claus Gittinger <cg@exept.de>
parents: 1649
diff changeset
   632
     
899889bd8404 #UI_ENHANCEMENT by cg
Claus Gittinger <cg@exept.de>
parents: 1649
diff changeset
   633
    "/ ECB-AES-128
899889bd8404 #UI_ENHANCEMENT by cg
Claus Gittinger <cg@exept.de>
parents: 1649
diff changeset
   634
    
899889bd8404 #UI_ENHANCEMENT by cg
Claus Gittinger <cg@exept.de>
parents: 1649
diff changeset
   635
    plaintext := #[ 0 17 34 51 68 85 102 119
899889bd8404 #UI_ENHANCEMENT by cg
Claus Gittinger <cg@exept.de>
parents: 1649
diff changeset
   636
                    136 153 170 187 204 221 238 255 ] asString.
899889bd8404 #UI_ENHANCEMENT by cg
Claus Gittinger <cg@exept.de>
parents: 1649
diff changeset
   637
    key := #[ 0 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 ] asString.
899889bd8404 #UI_ENHANCEMENT by cg
Claus Gittinger <cg@exept.de>
parents: 1649
diff changeset
   638
    ecb := RijndaelCipher new key:key mode:#ECB.
899889bd8404 #UI_ENHANCEMENT by cg
Claus Gittinger <cg@exept.de>
parents: 1649
diff changeset
   639
    crypted := ecb encrypt:plaintext.
899889bd8404 #UI_ENHANCEMENT by cg
Claus Gittinger <cg@exept.de>
parents: 1649
diff changeset
   640
    hx := crypted hexPrintString asLowercase.
899889bd8404 #UI_ENHANCEMENT by cg
Claus Gittinger <cg@exept.de>
parents: 1649
diff changeset
   641
    self assert:(hx = '69c4e0d86a7b0430d8cdb78070b4c55a').
899889bd8404 #UI_ENHANCEMENT by cg
Claus Gittinger <cg@exept.de>
parents: 1649
diff changeset
   642
    ecb := RijndaelCipher new key:key mode:#ECB.
899889bd8404 #UI_ENHANCEMENT by cg
Claus Gittinger <cg@exept.de>
parents: 1649
diff changeset
   643
    self assert:(ecb decrypt:crypted) asString = plaintext.
899889bd8404 #UI_ENHANCEMENT by cg
Claus Gittinger <cg@exept.de>
parents: 1649
diff changeset
   644
     
899889bd8404 #UI_ENHANCEMENT by cg
Claus Gittinger <cg@exept.de>
parents: 1649
diff changeset
   645
    "/ Modes of operation -- NIST paper tests
899889bd8404 #UI_ENHANCEMENT by cg
Claus Gittinger <cg@exept.de>
parents: 1649
diff changeset
   646
    "/ ECB-AES-128
899889bd8404 #UI_ENHANCEMENT by cg
Claus Gittinger <cg@exept.de>
parents: 1649
diff changeset
   647
    
899889bd8404 #UI_ENHANCEMENT by cg
Claus Gittinger <cg@exept.de>
parents: 1649
diff changeset
   648
    key := #[ 43 126 21 22 40 174 210 166 171 247 21 136 9 207 79 60 ].
899889bd8404 #UI_ENHANCEMENT by cg
Claus Gittinger <cg@exept.de>
parents: 1649
diff changeset
   649
    plaintext := #[ 107 193 190 226 46 64 159 150 233 61 126 17 115 147 23 42 174 45 138 87 30 3 172 156 158 183 111 172 69 175 142 81 48 200 28 70 163 92 228 17 229 251 193 25 26 10 82 239 246 159 36 69 223 79 155 23 173 43 65 123 230 108 55 16 ].
899889bd8404 #UI_ENHANCEMENT by cg
Claus Gittinger <cg@exept.de>
parents: 1649
diff changeset
   650
    ecb := RijndaelCipher new key:key mode:#ECB.
899889bd8404 #UI_ENHANCEMENT by cg
Claus Gittinger <cg@exept.de>
parents: 1649
diff changeset
   651
    crypted := ecb encrypt:plaintext.
899889bd8404 #UI_ENHANCEMENT by cg
Claus Gittinger <cg@exept.de>
parents: 1649
diff changeset
   652
    hx := crypted hexPrintString asLowercase.
899889bd8404 #UI_ENHANCEMENT by cg
Claus Gittinger <cg@exept.de>
parents: 1649
diff changeset
   653
    self assert:(hx 
899889bd8404 #UI_ENHANCEMENT by cg
Claus Gittinger <cg@exept.de>
parents: 1649
diff changeset
   654
                = '3ad77bb40d7a3660a89ecaf32466ef97f5d3d58503b9699de785895a96fdbaaf43b1cd7f598ece23881b00e3ed0306887b0c785e27e8ad3f8223207104725dd4').
899889bd8404 #UI_ENHANCEMENT by cg
Claus Gittinger <cg@exept.de>
parents: 1649
diff changeset
   655
    ecb := RijndaelCipher new key:key mode:#ECB.
899889bd8404 #UI_ENHANCEMENT by cg
Claus Gittinger <cg@exept.de>
parents: 1649
diff changeset
   656
    self assert:(ecb decrypt:crypted) = plaintext.
899889bd8404 #UI_ENHANCEMENT by cg
Claus Gittinger <cg@exept.de>
parents: 1649
diff changeset
   657
     
899889bd8404 #UI_ENHANCEMENT by cg
Claus Gittinger <cg@exept.de>
parents: 1649
diff changeset
   658
    "/ ECB-AES-192
899889bd8404 #UI_ENHANCEMENT by cg
Claus Gittinger <cg@exept.de>
parents: 1649
diff changeset
   659
    
899889bd8404 #UI_ENHANCEMENT by cg
Claus Gittinger <cg@exept.de>
parents: 1649
diff changeset
   660
    key := #[ 142 115 176 247 218 14 100 82 200 16 243 43 128 144 121 229 98 248 234 210 82 44 107 123 ].
899889bd8404 #UI_ENHANCEMENT by cg
Claus Gittinger <cg@exept.de>
parents: 1649
diff changeset
   661
    plaintext := #[ 107 193 190 226 46 64 159 150 233 61 126 17 115 147 23 42 174 45 138 87 30 3 172 156 158 183 111 172 69 175 142 81 48 200 28 70 163 92 228 17 229 251 193 25 26 10 82 239 246 159 36 69 223 79 155 23 173 43 65 123 230 108 55 16 ].
899889bd8404 #UI_ENHANCEMENT by cg
Claus Gittinger <cg@exept.de>
parents: 1649
diff changeset
   662
    ecb := RijndaelCipher new key:key mode:#ECB.
899889bd8404 #UI_ENHANCEMENT by cg
Claus Gittinger <cg@exept.de>
parents: 1649
diff changeset
   663
    crypted := ecb encrypt:plaintext.
899889bd8404 #UI_ENHANCEMENT by cg
Claus Gittinger <cg@exept.de>
parents: 1649
diff changeset
   664
    hx := crypted hexPrintString asLowercase.
899889bd8404 #UI_ENHANCEMENT by cg
Claus Gittinger <cg@exept.de>
parents: 1649
diff changeset
   665
    self assert:(hx 
899889bd8404 #UI_ENHANCEMENT by cg
Claus Gittinger <cg@exept.de>
parents: 1649
diff changeset
   666
                = 'bd334f1d6e45f25ff712a214571fa5cc974104846d0ad3ad7734ecb3ecee4eefef7afd2270e2e60adce0ba2face6444e9a4b41ba738d6c72fb16691603c18e0e').
899889bd8404 #UI_ENHANCEMENT by cg
Claus Gittinger <cg@exept.de>
parents: 1649
diff changeset
   667
    ecb := RijndaelCipher new key:key mode:#ECB.
899889bd8404 #UI_ENHANCEMENT by cg
Claus Gittinger <cg@exept.de>
parents: 1649
diff changeset
   668
    self assert:(ecb decrypt:crypted) = plaintext.
899889bd8404 #UI_ENHANCEMENT by cg
Claus Gittinger <cg@exept.de>
parents: 1649
diff changeset
   669
     
899889bd8404 #UI_ENHANCEMENT by cg
Claus Gittinger <cg@exept.de>
parents: 1649
diff changeset
   670
    "/ ECB-AES-256
899889bd8404 #UI_ENHANCEMENT by cg
Claus Gittinger <cg@exept.de>
parents: 1649
diff changeset
   671
    
899889bd8404 #UI_ENHANCEMENT by cg
Claus Gittinger <cg@exept.de>
parents: 1649
diff changeset
   672
    key := ('603deb1015ca71be2b73aef0857d77811f352c073b6108d72d9810a30914dff4' 
899889bd8404 #UI_ENHANCEMENT by cg
Claus Gittinger <cg@exept.de>
parents: 1649
diff changeset
   673
            pairWiseCollect:[:b1 :b2 | 
899889bd8404 #UI_ENHANCEMENT by cg
Claus Gittinger <cg@exept.de>
parents: 1649
diff changeset
   674
                Character value:(Integer readFrom:(b1 asString , b2) radix:16).
899889bd8404 #UI_ENHANCEMENT by cg
Claus Gittinger <cg@exept.de>
parents: 1649
diff changeset
   675
            ]) 
899889bd8404 #UI_ENHANCEMENT by cg
Claus Gittinger <cg@exept.de>
parents: 1649
diff changeset
   676
                asByteArray.
899889bd8404 #UI_ENHANCEMENT by cg
Claus Gittinger <cg@exept.de>
parents: 1649
diff changeset
   677
    plaintext := ('6bc1bee22e409f96e93d7e117393172aae2d8a571e03ac9c9eb76fac45af8e5130c81c46a35ce411e5fbc1191a0a52eff69f2445df4f9b17ad2b417be66c3710' 
899889bd8404 #UI_ENHANCEMENT by cg
Claus Gittinger <cg@exept.de>
parents: 1649
diff changeset
   678
            pairWiseCollect:[:b1 :b2 | 
899889bd8404 #UI_ENHANCEMENT by cg
Claus Gittinger <cg@exept.de>
parents: 1649
diff changeset
   679
                Character value:(Integer readFrom:(b1 asString , b2) radix:16).
899889bd8404 #UI_ENHANCEMENT by cg
Claus Gittinger <cg@exept.de>
parents: 1649
diff changeset
   680
            ]) 
899889bd8404 #UI_ENHANCEMENT by cg
Claus Gittinger <cg@exept.de>
parents: 1649
diff changeset
   681
                asByteArray.
899889bd8404 #UI_ENHANCEMENT by cg
Claus Gittinger <cg@exept.de>
parents: 1649
diff changeset
   682
    ecb := RijndaelCipher new key:key mode:#ECB.
899889bd8404 #UI_ENHANCEMENT by cg
Claus Gittinger <cg@exept.de>
parents: 1649
diff changeset
   683
    crypted := ecb encrypt:plaintext.
899889bd8404 #UI_ENHANCEMENT by cg
Claus Gittinger <cg@exept.de>
parents: 1649
diff changeset
   684
    hx := crypted hexPrintString asLowercase.
899889bd8404 #UI_ENHANCEMENT by cg
Claus Gittinger <cg@exept.de>
parents: 1649
diff changeset
   685
    self assert:(hx 
899889bd8404 #UI_ENHANCEMENT by cg
Claus Gittinger <cg@exept.de>
parents: 1649
diff changeset
   686
                = 'f3eed1bdb5d2a03c064b5a7e3db181f8591ccb10d410ed26dc5ba74a31362870b6ed21b99ca6f4f9f153e7b1beafed1d23304b7a39f9f3ff067d8d8f9e24ecc7').
899889bd8404 #UI_ENHANCEMENT by cg
Claus Gittinger <cg@exept.de>
parents: 1649
diff changeset
   687
    ecb := RijndaelCipher new key:key mode:#ECB.
899889bd8404 #UI_ENHANCEMENT by cg
Claus Gittinger <cg@exept.de>
parents: 1649
diff changeset
   688
    self assert:(ecb decrypt:crypted) = plaintext.
899889bd8404 #UI_ENHANCEMENT by cg
Claus Gittinger <cg@exept.de>
parents: 1649
diff changeset
   689
     
899889bd8404 #UI_ENHANCEMENT by cg
Claus Gittinger <cg@exept.de>
parents: 1649
diff changeset
   690
    "/ CBC-AES-128
899889bd8404 #UI_ENHANCEMENT by cg
Claus Gittinger <cg@exept.de>
parents: 1649
diff changeset
   691
    
899889bd8404 #UI_ENHANCEMENT by cg
Claus Gittinger <cg@exept.de>
parents: 1649
diff changeset
   692
    key := ('2b7e151628aed2a6abf7158809cf4f3c' 
899889bd8404 #UI_ENHANCEMENT by cg
Claus Gittinger <cg@exept.de>
parents: 1649
diff changeset
   693
            pairWiseCollect:[:b1 :b2 | 
899889bd8404 #UI_ENHANCEMENT by cg
Claus Gittinger <cg@exept.de>
parents: 1649
diff changeset
   694
                Character value:(Integer readFrom:(b1 asString , b2) radix:16).
899889bd8404 #UI_ENHANCEMENT by cg
Claus Gittinger <cg@exept.de>
parents: 1649
diff changeset
   695
            ]) 
899889bd8404 #UI_ENHANCEMENT by cg
Claus Gittinger <cg@exept.de>
parents: 1649
diff changeset
   696
                asByteArray.
899889bd8404 #UI_ENHANCEMENT by cg
Claus Gittinger <cg@exept.de>
parents: 1649
diff changeset
   697
    plaintext := ('6bc1bee22e409f96e93d7e117393172aae2d8a571e03ac9c9eb76fac45af8e5130c81c46a35ce411e5fbc1191a0a52eff69f2445df4f9b17ad2b417be66c3710' 
899889bd8404 #UI_ENHANCEMENT by cg
Claus Gittinger <cg@exept.de>
parents: 1649
diff changeset
   698
            pairWiseCollect:[:b1 :b2 | 
899889bd8404 #UI_ENHANCEMENT by cg
Claus Gittinger <cg@exept.de>
parents: 1649
diff changeset
   699
                Character value:(Integer readFrom:(b1 asString , b2) radix:16).
899889bd8404 #UI_ENHANCEMENT by cg
Claus Gittinger <cg@exept.de>
parents: 1649
diff changeset
   700
            ]) 
899889bd8404 #UI_ENHANCEMENT by cg
Claus Gittinger <cg@exept.de>
parents: 1649
diff changeset
   701
                asByteArray.
899889bd8404 #UI_ENHANCEMENT by cg
Claus Gittinger <cg@exept.de>
parents: 1649
diff changeset
   702
    iv := ('000102030405060708090a0b0c0d0e0f' 
899889bd8404 #UI_ENHANCEMENT by cg
Claus Gittinger <cg@exept.de>
parents: 1649
diff changeset
   703
            pairWiseCollect:[:b1 :b2 | 
899889bd8404 #UI_ENHANCEMENT by cg
Claus Gittinger <cg@exept.de>
parents: 1649
diff changeset
   704
                Character value:(Integer readFrom:(b1 asString , b2) radix:16).
899889bd8404 #UI_ENHANCEMENT by cg
Claus Gittinger <cg@exept.de>
parents: 1649
diff changeset
   705
            ]) 
899889bd8404 #UI_ENHANCEMENT by cg
Claus Gittinger <cg@exept.de>
parents: 1649
diff changeset
   706
                asByteArray.
899889bd8404 #UI_ENHANCEMENT by cg
Claus Gittinger <cg@exept.de>
parents: 1649
diff changeset
   707
    cbc := RijndaelCipher new key:key mode:#CBC.
899889bd8404 #UI_ENHANCEMENT by cg
Claus Gittinger <cg@exept.de>
parents: 1649
diff changeset
   708
    cbc initializationVector:iv.
899889bd8404 #UI_ENHANCEMENT by cg
Claus Gittinger <cg@exept.de>
parents: 1649
diff changeset
   709
    crypted := cbc encrypt:plaintext.
899889bd8404 #UI_ENHANCEMENT by cg
Claus Gittinger <cg@exept.de>
parents: 1649
diff changeset
   710
    hx := crypted hexPrintString asLowercase.
899889bd8404 #UI_ENHANCEMENT by cg
Claus Gittinger <cg@exept.de>
parents: 1649
diff changeset
   711
    self assert:(hx 
899889bd8404 #UI_ENHANCEMENT by cg
Claus Gittinger <cg@exept.de>
parents: 1649
diff changeset
   712
                = '7649abac8119b246cee98e9b12e9197d5086cb9b507219ee95db113a917678b273bed6b8e3c1743b7116e69e222295163ff1caa1681fac09120eca307586e1a7').
899889bd8404 #UI_ENHANCEMENT by cg
Claus Gittinger <cg@exept.de>
parents: 1649
diff changeset
   713
    cbc initializationVector:iv.
899889bd8404 #UI_ENHANCEMENT by cg
Claus Gittinger <cg@exept.de>
parents: 1649
diff changeset
   714
    self assert:(cbc decrypt:crypted) = plaintext.
899889bd8404 #UI_ENHANCEMENT by cg
Claus Gittinger <cg@exept.de>
parents: 1649
diff changeset
   715
     
899889bd8404 #UI_ENHANCEMENT by cg
Claus Gittinger <cg@exept.de>
parents: 1649
diff changeset
   716
    "/ CBC-AES-192
899889bd8404 #UI_ENHANCEMENT by cg
Claus Gittinger <cg@exept.de>
parents: 1649
diff changeset
   717
    
899889bd8404 #UI_ENHANCEMENT by cg
Claus Gittinger <cg@exept.de>
parents: 1649
diff changeset
   718
    key := ('8e73b0f7da0e6452c810f32b809079e562f8ead2522c6b7b' 
899889bd8404 #UI_ENHANCEMENT by cg
Claus Gittinger <cg@exept.de>
parents: 1649
diff changeset
   719
            pairWiseCollect:[:b1 :b2 | 
899889bd8404 #UI_ENHANCEMENT by cg
Claus Gittinger <cg@exept.de>
parents: 1649
diff changeset
   720
                Character value:(Integer readFrom:(b1 asString , b2) radix:16).
899889bd8404 #UI_ENHANCEMENT by cg
Claus Gittinger <cg@exept.de>
parents: 1649
diff changeset
   721
            ]) 
899889bd8404 #UI_ENHANCEMENT by cg
Claus Gittinger <cg@exept.de>
parents: 1649
diff changeset
   722
                asByteArray.
899889bd8404 #UI_ENHANCEMENT by cg
Claus Gittinger <cg@exept.de>
parents: 1649
diff changeset
   723
    plaintext := ('6bc1bee22e409f96e93d7e117393172aae2d8a571e03ac9c9eb76fac45af8e5130c81c46a35ce411e5fbc1191a0a52eff69f2445df4f9b17ad2b417be66c3710' 
899889bd8404 #UI_ENHANCEMENT by cg
Claus Gittinger <cg@exept.de>
parents: 1649
diff changeset
   724
            pairWiseCollect:[:b1 :b2 | 
899889bd8404 #UI_ENHANCEMENT by cg
Claus Gittinger <cg@exept.de>
parents: 1649
diff changeset
   725
                Character value:(Integer readFrom:(b1 asString , b2) radix:16).
899889bd8404 #UI_ENHANCEMENT by cg
Claus Gittinger <cg@exept.de>
parents: 1649
diff changeset
   726
            ]) 
899889bd8404 #UI_ENHANCEMENT by cg
Claus Gittinger <cg@exept.de>
parents: 1649
diff changeset
   727
                asByteArray.
899889bd8404 #UI_ENHANCEMENT by cg
Claus Gittinger <cg@exept.de>
parents: 1649
diff changeset
   728
    iv := ('000102030405060708090a0b0c0d0e0f' 
899889bd8404 #UI_ENHANCEMENT by cg
Claus Gittinger <cg@exept.de>
parents: 1649
diff changeset
   729
            pairWiseCollect:[:b1 :b2 | 
899889bd8404 #UI_ENHANCEMENT by cg
Claus Gittinger <cg@exept.de>
parents: 1649
diff changeset
   730
                Character value:(Integer readFrom:(b1 asString , b2) radix:16).
899889bd8404 #UI_ENHANCEMENT by cg
Claus Gittinger <cg@exept.de>
parents: 1649
diff changeset
   731
            ]) 
899889bd8404 #UI_ENHANCEMENT by cg
Claus Gittinger <cg@exept.de>
parents: 1649
diff changeset
   732
                asByteArray.
899889bd8404 #UI_ENHANCEMENT by cg
Claus Gittinger <cg@exept.de>
parents: 1649
diff changeset
   733
    cbc := RijndaelCipher new key:key mode:#CBC.
899889bd8404 #UI_ENHANCEMENT by cg
Claus Gittinger <cg@exept.de>
parents: 1649
diff changeset
   734
    cbc initializationVector:iv.
899889bd8404 #UI_ENHANCEMENT by cg
Claus Gittinger <cg@exept.de>
parents: 1649
diff changeset
   735
    crypted := cbc encrypt:plaintext.
899889bd8404 #UI_ENHANCEMENT by cg
Claus Gittinger <cg@exept.de>
parents: 1649
diff changeset
   736
    hx := crypted hexPrintString asLowercase.
899889bd8404 #UI_ENHANCEMENT by cg
Claus Gittinger <cg@exept.de>
parents: 1649
diff changeset
   737
    self assert:(hx 
899889bd8404 #UI_ENHANCEMENT by cg
Claus Gittinger <cg@exept.de>
parents: 1649
diff changeset
   738
                = '4f021db243bc633d7178183a9fa071e8b4d9ada9ad7dedf4e5e738763f69145a571b242012fb7ae07fa9baac3df102e008b0e27988598881d920a9e64f5615cd').
899889bd8404 #UI_ENHANCEMENT by cg
Claus Gittinger <cg@exept.de>
parents: 1649
diff changeset
   739
    cbc initializationVector:iv.
899889bd8404 #UI_ENHANCEMENT by cg
Claus Gittinger <cg@exept.de>
parents: 1649
diff changeset
   740
    self assert:(cbc decrypt:crypted) = plaintext.
899889bd8404 #UI_ENHANCEMENT by cg
Claus Gittinger <cg@exept.de>
parents: 1649
diff changeset
   741
     
899889bd8404 #UI_ENHANCEMENT by cg
Claus Gittinger <cg@exept.de>
parents: 1649
diff changeset
   742
    "/ CBC-AES-256
899889bd8404 #UI_ENHANCEMENT by cg
Claus Gittinger <cg@exept.de>
parents: 1649
diff changeset
   743
    
899889bd8404 #UI_ENHANCEMENT by cg
Claus Gittinger <cg@exept.de>
parents: 1649
diff changeset
   744
    key := ('603deb1015ca71be2b73aef0857d77811f352c073b6108d72d9810a30914dff4' 
899889bd8404 #UI_ENHANCEMENT by cg
Claus Gittinger <cg@exept.de>
parents: 1649
diff changeset
   745
            pairWiseCollect:[:b1 :b2 | 
899889bd8404 #UI_ENHANCEMENT by cg
Claus Gittinger <cg@exept.de>
parents: 1649
diff changeset
   746
                Character value:(Integer readFrom:(b1 asString , b2) radix:16).
899889bd8404 #UI_ENHANCEMENT by cg
Claus Gittinger <cg@exept.de>
parents: 1649
diff changeset
   747
            ]) 
899889bd8404 #UI_ENHANCEMENT by cg
Claus Gittinger <cg@exept.de>
parents: 1649
diff changeset
   748
                asByteArray.
899889bd8404 #UI_ENHANCEMENT by cg
Claus Gittinger <cg@exept.de>
parents: 1649
diff changeset
   749
    plaintext := ('6bc1bee22e409f96e93d7e117393172aae2d8a571e03ac9c9eb76fac45af8e5130c81c46a35ce411e5fbc1191a0a52eff69f2445df4f9b17ad2b417be66c3710' 
899889bd8404 #UI_ENHANCEMENT by cg
Claus Gittinger <cg@exept.de>
parents: 1649
diff changeset
   750
            pairWiseCollect:[:b1 :b2 | 
899889bd8404 #UI_ENHANCEMENT by cg
Claus Gittinger <cg@exept.de>
parents: 1649
diff changeset
   751
                Character value:(Integer readFrom:(b1 asString , b2) radix:16).
899889bd8404 #UI_ENHANCEMENT by cg
Claus Gittinger <cg@exept.de>
parents: 1649
diff changeset
   752
            ]) 
899889bd8404 #UI_ENHANCEMENT by cg
Claus Gittinger <cg@exept.de>
parents: 1649
diff changeset
   753
                asByteArray.
899889bd8404 #UI_ENHANCEMENT by cg
Claus Gittinger <cg@exept.de>
parents: 1649
diff changeset
   754
    iv := ('000102030405060708090a0b0c0d0e0f' 
899889bd8404 #UI_ENHANCEMENT by cg
Claus Gittinger <cg@exept.de>
parents: 1649
diff changeset
   755
            pairWiseCollect:[:b1 :b2 | 
899889bd8404 #UI_ENHANCEMENT by cg
Claus Gittinger <cg@exept.de>
parents: 1649
diff changeset
   756
                Character value:(Integer readFrom:(b1 asString , b2) radix:16).
899889bd8404 #UI_ENHANCEMENT by cg
Claus Gittinger <cg@exept.de>
parents: 1649
diff changeset
   757
            ]) 
899889bd8404 #UI_ENHANCEMENT by cg
Claus Gittinger <cg@exept.de>
parents: 1649
diff changeset
   758
                asByteArray.
899889bd8404 #UI_ENHANCEMENT by cg
Claus Gittinger <cg@exept.de>
parents: 1649
diff changeset
   759
    cbc := RijndaelCipher new key:key mode:#CBC.
899889bd8404 #UI_ENHANCEMENT by cg
Claus Gittinger <cg@exept.de>
parents: 1649
diff changeset
   760
    cbc initializationVector:iv.
899889bd8404 #UI_ENHANCEMENT by cg
Claus Gittinger <cg@exept.de>
parents: 1649
diff changeset
   761
    crypted := cbc encrypt:plaintext.
899889bd8404 #UI_ENHANCEMENT by cg
Claus Gittinger <cg@exept.de>
parents: 1649
diff changeset
   762
    hx := crypted hexPrintString asLowercase.
899889bd8404 #UI_ENHANCEMENT by cg
Claus Gittinger <cg@exept.de>
parents: 1649
diff changeset
   763
    self assert:(hx 
899889bd8404 #UI_ENHANCEMENT by cg
Claus Gittinger <cg@exept.de>
parents: 1649
diff changeset
   764
                = 'f58c4c04d6e5f1ba779eabfb5f7bfbd69cfc4e967edb808d679f777bc6702c7d39f23369a9d9bacfa530e26304231461b2eb05e2c39be9fcda6c19078c6a9d1b').
899889bd8404 #UI_ENHANCEMENT by cg
Claus Gittinger <cg@exept.de>
parents: 1649
diff changeset
   765
    cbc initializationVector:iv.
899889bd8404 #UI_ENHANCEMENT by cg
Claus Gittinger <cg@exept.de>
parents: 1649
diff changeset
   766
    self assert:(cbc decrypt:crypted) = plaintext.
899889bd8404 #UI_ENHANCEMENT by cg
Claus Gittinger <cg@exept.de>
parents: 1649
diff changeset
   767
     
899889bd8404 #UI_ENHANCEMENT by cg
Claus Gittinger <cg@exept.de>
parents: 1649
diff changeset
   768
    "/ CFB128-AES-128
899889bd8404 #UI_ENHANCEMENT by cg
Claus Gittinger <cg@exept.de>
parents: 1649
diff changeset
   769
    
899889bd8404 #UI_ENHANCEMENT by cg
Claus Gittinger <cg@exept.de>
parents: 1649
diff changeset
   770
    key := ('2b7e151628aed2a6abf7158809cf4f3c' 
899889bd8404 #UI_ENHANCEMENT by cg
Claus Gittinger <cg@exept.de>
parents: 1649
diff changeset
   771
            pairWiseCollect:[:b1 :b2 | 
899889bd8404 #UI_ENHANCEMENT by cg
Claus Gittinger <cg@exept.de>
parents: 1649
diff changeset
   772
                Character value:(Integer readFrom:(b1 asString , b2) radix:16).
899889bd8404 #UI_ENHANCEMENT by cg
Claus Gittinger <cg@exept.de>
parents: 1649
diff changeset
   773
            ]) 
899889bd8404 #UI_ENHANCEMENT by cg
Claus Gittinger <cg@exept.de>
parents: 1649
diff changeset
   774
                asByteArray.
899889bd8404 #UI_ENHANCEMENT by cg
Claus Gittinger <cg@exept.de>
parents: 1649
diff changeset
   775
    plaintext := ('6bc1bee22e409f96e93d7e117393172aae2d8a571e03ac9c9eb76fac45af8e5130c81c46a35ce411e5fbc1191a0a52eff69f2445df4f9b17ad2b417be66c3710' 
899889bd8404 #UI_ENHANCEMENT by cg
Claus Gittinger <cg@exept.de>
parents: 1649
diff changeset
   776
            pairWiseCollect:[:b1 :b2 | 
899889bd8404 #UI_ENHANCEMENT by cg
Claus Gittinger <cg@exept.de>
parents: 1649
diff changeset
   777
                Character value:(Integer readFrom:(b1 asString , b2) radix:16).
899889bd8404 #UI_ENHANCEMENT by cg
Claus Gittinger <cg@exept.de>
parents: 1649
diff changeset
   778
            ]) 
899889bd8404 #UI_ENHANCEMENT by cg
Claus Gittinger <cg@exept.de>
parents: 1649
diff changeset
   779
                asByteArray.
899889bd8404 #UI_ENHANCEMENT by cg
Claus Gittinger <cg@exept.de>
parents: 1649
diff changeset
   780
    iv := ('000102030405060708090a0b0c0d0e0f' 
899889bd8404 #UI_ENHANCEMENT by cg
Claus Gittinger <cg@exept.de>
parents: 1649
diff changeset
   781
            pairWiseCollect:[:b1 :b2 | 
899889bd8404 #UI_ENHANCEMENT by cg
Claus Gittinger <cg@exept.de>
parents: 1649
diff changeset
   782
                Character value:(Integer readFrom:(b1 asString , b2) radix:16).
899889bd8404 #UI_ENHANCEMENT by cg
Claus Gittinger <cg@exept.de>
parents: 1649
diff changeset
   783
            ]) 
899889bd8404 #UI_ENHANCEMENT by cg
Claus Gittinger <cg@exept.de>
parents: 1649
diff changeset
   784
                asByteArray.
899889bd8404 #UI_ENHANCEMENT by cg
Claus Gittinger <cg@exept.de>
parents: 1649
diff changeset
   785
    cbc := RijndaelCipher new key:key mode:#CFB.
899889bd8404 #UI_ENHANCEMENT by cg
Claus Gittinger <cg@exept.de>
parents: 1649
diff changeset
   786
    cbc initializationVector:iv.
899889bd8404 #UI_ENHANCEMENT by cg
Claus Gittinger <cg@exept.de>
parents: 1649
diff changeset
   787
    crypted := cbc encrypt:plaintext.
899889bd8404 #UI_ENHANCEMENT by cg
Claus Gittinger <cg@exept.de>
parents: 1649
diff changeset
   788
    hx := crypted hexPrintString asLowercase.
899889bd8404 #UI_ENHANCEMENT by cg
Claus Gittinger <cg@exept.de>
parents: 1649
diff changeset
   789
    self assert:(hx 
899889bd8404 #UI_ENHANCEMENT by cg
Claus Gittinger <cg@exept.de>
parents: 1649
diff changeset
   790
                = '3b3fd92eb72dad20333449f8e83cfb4ac8a64537a0b3a93fcde3cdad9f1ce58b26751f67a3cbb140b1808cf187a4f4dfc04b05357c5d1c0eeac4c66f9ff7f2e6').
899889bd8404 #UI_ENHANCEMENT by cg
Claus Gittinger <cg@exept.de>
parents: 1649
diff changeset
   791
    cbc initializationVector:iv.
899889bd8404 #UI_ENHANCEMENT by cg
Claus Gittinger <cg@exept.de>
parents: 1649
diff changeset
   792
    self assert:(cbc decrypt:crypted) = plaintext.
899889bd8404 #UI_ENHANCEMENT by cg
Claus Gittinger <cg@exept.de>
parents: 1649
diff changeset
   793
     
899889bd8404 #UI_ENHANCEMENT by cg
Claus Gittinger <cg@exept.de>
parents: 1649
diff changeset
   794
    "/ CFB128-AES-192
899889bd8404 #UI_ENHANCEMENT by cg
Claus Gittinger <cg@exept.de>
parents: 1649
diff changeset
   795
    
899889bd8404 #UI_ENHANCEMENT by cg
Claus Gittinger <cg@exept.de>
parents: 1649
diff changeset
   796
    key := ('8e73b0f7da0e6452c810f32b809079e562f8ead2522c6b7b' 
899889bd8404 #UI_ENHANCEMENT by cg
Claus Gittinger <cg@exept.de>
parents: 1649
diff changeset
   797
            pairWiseCollect:[:b1 :b2 | 
899889bd8404 #UI_ENHANCEMENT by cg
Claus Gittinger <cg@exept.de>
parents: 1649
diff changeset
   798
                Character value:(Integer readFrom:(b1 asString , b2) radix:16).
899889bd8404 #UI_ENHANCEMENT by cg
Claus Gittinger <cg@exept.de>
parents: 1649
diff changeset
   799
            ]) 
899889bd8404 #UI_ENHANCEMENT by cg
Claus Gittinger <cg@exept.de>
parents: 1649
diff changeset
   800
                asByteArray.
899889bd8404 #UI_ENHANCEMENT by cg
Claus Gittinger <cg@exept.de>
parents: 1649
diff changeset
   801
    plaintext := ('6bc1bee22e409f96e93d7e117393172aae2d8a571e03ac9c9eb76fac45af8e5130c81c46a35ce411e5fbc1191a0a52eff69f2445df4f9b17ad2b417be66c3710' 
899889bd8404 #UI_ENHANCEMENT by cg
Claus Gittinger <cg@exept.de>
parents: 1649
diff changeset
   802
            pairWiseCollect:[:b1 :b2 | 
899889bd8404 #UI_ENHANCEMENT by cg
Claus Gittinger <cg@exept.de>
parents: 1649
diff changeset
   803
                Character value:(Integer readFrom:(b1 asString , b2) radix:16).
899889bd8404 #UI_ENHANCEMENT by cg
Claus Gittinger <cg@exept.de>
parents: 1649
diff changeset
   804
            ]) 
899889bd8404 #UI_ENHANCEMENT by cg
Claus Gittinger <cg@exept.de>
parents: 1649
diff changeset
   805
                asByteArray.
899889bd8404 #UI_ENHANCEMENT by cg
Claus Gittinger <cg@exept.de>
parents: 1649
diff changeset
   806
    iv := ('000102030405060708090a0b0c0d0e0f' 
899889bd8404 #UI_ENHANCEMENT by cg
Claus Gittinger <cg@exept.de>
parents: 1649
diff changeset
   807
            pairWiseCollect:[:b1 :b2 | 
899889bd8404 #UI_ENHANCEMENT by cg
Claus Gittinger <cg@exept.de>
parents: 1649
diff changeset
   808
                Character value:(Integer readFrom:(b1 asString , b2) radix:16).
899889bd8404 #UI_ENHANCEMENT by cg
Claus Gittinger <cg@exept.de>
parents: 1649
diff changeset
   809
            ]) 
899889bd8404 #UI_ENHANCEMENT by cg
Claus Gittinger <cg@exept.de>
parents: 1649
diff changeset
   810
                asByteArray.
899889bd8404 #UI_ENHANCEMENT by cg
Claus Gittinger <cg@exept.de>
parents: 1649
diff changeset
   811
    cbc := RijndaelCipher new key:key mode:#CFB.
899889bd8404 #UI_ENHANCEMENT by cg
Claus Gittinger <cg@exept.de>
parents: 1649
diff changeset
   812
    cbc initializationVector:iv.
899889bd8404 #UI_ENHANCEMENT by cg
Claus Gittinger <cg@exept.de>
parents: 1649
diff changeset
   813
    crypted := cbc encrypt:plaintext.
899889bd8404 #UI_ENHANCEMENT by cg
Claus Gittinger <cg@exept.de>
parents: 1649
diff changeset
   814
    hx := crypted hexPrintString asLowercase.
899889bd8404 #UI_ENHANCEMENT by cg
Claus Gittinger <cg@exept.de>
parents: 1649
diff changeset
   815
    self assert:(hx 
899889bd8404 #UI_ENHANCEMENT by cg
Claus Gittinger <cg@exept.de>
parents: 1649
diff changeset
   816
                = 'cdc80d6fddf18cab34c25909c99a417467ce7f7f81173621961a2b70171d3d7a2e1e8a1dd59b88b1c8e60fed1efac4c9c05f9f9ca9834fa042ae8fba584b09ff').
899889bd8404 #UI_ENHANCEMENT by cg
Claus Gittinger <cg@exept.de>
parents: 1649
diff changeset
   817
    cbc initializationVector:iv.
899889bd8404 #UI_ENHANCEMENT by cg
Claus Gittinger <cg@exept.de>
parents: 1649
diff changeset
   818
    self assert:(cbc decrypt:crypted) = plaintext.
899889bd8404 #UI_ENHANCEMENT by cg
Claus Gittinger <cg@exept.de>
parents: 1649
diff changeset
   819
     
899889bd8404 #UI_ENHANCEMENT by cg
Claus Gittinger <cg@exept.de>
parents: 1649
diff changeset
   820
    "/ CFB128-AES-256
899889bd8404 #UI_ENHANCEMENT by cg
Claus Gittinger <cg@exept.de>
parents: 1649
diff changeset
   821
    
899889bd8404 #UI_ENHANCEMENT by cg
Claus Gittinger <cg@exept.de>
parents: 1649
diff changeset
   822
    key := ('603deb1015ca71be2b73aef0857d77811f352c073b6108d72d9810a30914dff4' 
899889bd8404 #UI_ENHANCEMENT by cg
Claus Gittinger <cg@exept.de>
parents: 1649
diff changeset
   823
            pairWiseCollect:[:b1 :b2 | 
899889bd8404 #UI_ENHANCEMENT by cg
Claus Gittinger <cg@exept.de>
parents: 1649
diff changeset
   824
                Character value:(Integer readFrom:(b1 asString , b2) radix:16).
899889bd8404 #UI_ENHANCEMENT by cg
Claus Gittinger <cg@exept.de>
parents: 1649
diff changeset
   825
            ]) 
899889bd8404 #UI_ENHANCEMENT by cg
Claus Gittinger <cg@exept.de>
parents: 1649
diff changeset
   826
                asByteArray.
899889bd8404 #UI_ENHANCEMENT by cg
Claus Gittinger <cg@exept.de>
parents: 1649
diff changeset
   827
    plaintext := ('6bc1bee22e409f96e93d7e117393172aae2d8a571e03ac9c9eb76fac45af8e5130c81c46a35ce411e5fbc1191a0a52eff69f2445df4f9b17ad2b417be66c3710' 
899889bd8404 #UI_ENHANCEMENT by cg
Claus Gittinger <cg@exept.de>
parents: 1649
diff changeset
   828
            pairWiseCollect:[:b1 :b2 | 
899889bd8404 #UI_ENHANCEMENT by cg
Claus Gittinger <cg@exept.de>
parents: 1649
diff changeset
   829
                Character value:(Integer readFrom:(b1 asString , b2) radix:16).
899889bd8404 #UI_ENHANCEMENT by cg
Claus Gittinger <cg@exept.de>
parents: 1649
diff changeset
   830
            ]) 
899889bd8404 #UI_ENHANCEMENT by cg
Claus Gittinger <cg@exept.de>
parents: 1649
diff changeset
   831
                asByteArray.
899889bd8404 #UI_ENHANCEMENT by cg
Claus Gittinger <cg@exept.de>
parents: 1649
diff changeset
   832
    iv := ('000102030405060708090a0b0c0d0e0f' 
899889bd8404 #UI_ENHANCEMENT by cg
Claus Gittinger <cg@exept.de>
parents: 1649
diff changeset
   833
            pairWiseCollect:[:b1 :b2 | 
899889bd8404 #UI_ENHANCEMENT by cg
Claus Gittinger <cg@exept.de>
parents: 1649
diff changeset
   834
                Character value:(Integer readFrom:(b1 asString , b2) radix:16).
899889bd8404 #UI_ENHANCEMENT by cg
Claus Gittinger <cg@exept.de>
parents: 1649
diff changeset
   835
            ]) 
899889bd8404 #UI_ENHANCEMENT by cg
Claus Gittinger <cg@exept.de>
parents: 1649
diff changeset
   836
                asByteArray.
899889bd8404 #UI_ENHANCEMENT by cg
Claus Gittinger <cg@exept.de>
parents: 1649
diff changeset
   837
    cbc := RijndaelCipher new key:key mode:#CFB.
899889bd8404 #UI_ENHANCEMENT by cg
Claus Gittinger <cg@exept.de>
parents: 1649
diff changeset
   838
    cbc initializationVector:iv.
899889bd8404 #UI_ENHANCEMENT by cg
Claus Gittinger <cg@exept.de>
parents: 1649
diff changeset
   839
    crypted := cbc encrypt:plaintext.
899889bd8404 #UI_ENHANCEMENT by cg
Claus Gittinger <cg@exept.de>
parents: 1649
diff changeset
   840
    hx := crypted hexPrintString asLowercase.
899889bd8404 #UI_ENHANCEMENT by cg
Claus Gittinger <cg@exept.de>
parents: 1649
diff changeset
   841
    self assert:(hx 
899889bd8404 #UI_ENHANCEMENT by cg
Claus Gittinger <cg@exept.de>
parents: 1649
diff changeset
   842
                = 'dc7e84bfda79164b7ecd8486985d386039ffed143b28b1c832113c6331e5407bdf10132415e54b92a13ed0a8267ae2f975a385741ab9cef82031623d55b1e471').
899889bd8404 #UI_ENHANCEMENT by cg
Claus Gittinger <cg@exept.de>
parents: 1649
diff changeset
   843
    cbc initializationVector:iv.
899889bd8404 #UI_ENHANCEMENT by cg
Claus Gittinger <cg@exept.de>
parents: 1649
diff changeset
   844
    self assert:(cbc decrypt:crypted) = plaintext.
899889bd8404 #UI_ENHANCEMENT by cg
Claus Gittinger <cg@exept.de>
parents: 1649
diff changeset
   845
     
899889bd8404 #UI_ENHANCEMENT by cg
Claus Gittinger <cg@exept.de>
parents: 1649
diff changeset
   846
    "/ OFB-AES-128
899889bd8404 #UI_ENHANCEMENT by cg
Claus Gittinger <cg@exept.de>
parents: 1649
diff changeset
   847
    
899889bd8404 #UI_ENHANCEMENT by cg
Claus Gittinger <cg@exept.de>
parents: 1649
diff changeset
   848
    key := ('2b7e151628aed2a6abf7158809cf4f3c' 
899889bd8404 #UI_ENHANCEMENT by cg
Claus Gittinger <cg@exept.de>
parents: 1649
diff changeset
   849
            pairWiseCollect:[:b1 :b2 | 
899889bd8404 #UI_ENHANCEMENT by cg
Claus Gittinger <cg@exept.de>
parents: 1649
diff changeset
   850
                Character value:(Integer readFrom:(b1 asString , b2) radix:16).
899889bd8404 #UI_ENHANCEMENT by cg
Claus Gittinger <cg@exept.de>
parents: 1649
diff changeset
   851
            ]) 
899889bd8404 #UI_ENHANCEMENT by cg
Claus Gittinger <cg@exept.de>
parents: 1649
diff changeset
   852
                asByteArray.
899889bd8404 #UI_ENHANCEMENT by cg
Claus Gittinger <cg@exept.de>
parents: 1649
diff changeset
   853
    plaintext := ('6bc1bee22e409f96e93d7e117393172aae2d8a571e03ac9c9eb76fac45af8e5130c81c46a35ce411e5fbc1191a0a52eff69f2445df4f9b17ad2b417be66c3710' 
899889bd8404 #UI_ENHANCEMENT by cg
Claus Gittinger <cg@exept.de>
parents: 1649
diff changeset
   854
            pairWiseCollect:[:b1 :b2 | 
899889bd8404 #UI_ENHANCEMENT by cg
Claus Gittinger <cg@exept.de>
parents: 1649
diff changeset
   855
                Character value:(Integer readFrom:(b1 asString , b2) radix:16).
899889bd8404 #UI_ENHANCEMENT by cg
Claus Gittinger <cg@exept.de>
parents: 1649
diff changeset
   856
            ]) 
899889bd8404 #UI_ENHANCEMENT by cg
Claus Gittinger <cg@exept.de>
parents: 1649
diff changeset
   857
                asByteArray.
899889bd8404 #UI_ENHANCEMENT by cg
Claus Gittinger <cg@exept.de>
parents: 1649
diff changeset
   858
    iv := ('000102030405060708090a0b0c0d0e0f' 
899889bd8404 #UI_ENHANCEMENT by cg
Claus Gittinger <cg@exept.de>
parents: 1649
diff changeset
   859
            pairWiseCollect:[:b1 :b2 | 
899889bd8404 #UI_ENHANCEMENT by cg
Claus Gittinger <cg@exept.de>
parents: 1649
diff changeset
   860
                Character value:(Integer readFrom:(b1 asString , b2) radix:16).
899889bd8404 #UI_ENHANCEMENT by cg
Claus Gittinger <cg@exept.de>
parents: 1649
diff changeset
   861
            ]) 
899889bd8404 #UI_ENHANCEMENT by cg
Claus Gittinger <cg@exept.de>
parents: 1649
diff changeset
   862
                asByteArray.
899889bd8404 #UI_ENHANCEMENT by cg
Claus Gittinger <cg@exept.de>
parents: 1649
diff changeset
   863
    ofb := RijndaelCipher new key:key mode:#OFB.
899889bd8404 #UI_ENHANCEMENT by cg
Claus Gittinger <cg@exept.de>
parents: 1649
diff changeset
   864
    ofb initializationVector:iv.
899889bd8404 #UI_ENHANCEMENT by cg
Claus Gittinger <cg@exept.de>
parents: 1649
diff changeset
   865
    crypted := ofb encrypt:plaintext.
899889bd8404 #UI_ENHANCEMENT by cg
Claus Gittinger <cg@exept.de>
parents: 1649
diff changeset
   866
    hx := crypted hexPrintString asLowercase.
899889bd8404 #UI_ENHANCEMENT by cg
Claus Gittinger <cg@exept.de>
parents: 1649
diff changeset
   867
    self assert:(hx 
899889bd8404 #UI_ENHANCEMENT by cg
Claus Gittinger <cg@exept.de>
parents: 1649
diff changeset
   868
                = '3b3fd92eb72dad20333449f8e83cfb4a7789508d16918f03f53c52dac54ed8259740051e9c5fecf64344f7a82260edcc304c6528f659c77866a510d9c1d6ae5e').
899889bd8404 #UI_ENHANCEMENT by cg
Claus Gittinger <cg@exept.de>
parents: 1649
diff changeset
   869
    ofb initializationVector:iv.
899889bd8404 #UI_ENHANCEMENT by cg
Claus Gittinger <cg@exept.de>
parents: 1649
diff changeset
   870
    self assert:(ofb decrypt:crypted) = plaintext.
899889bd8404 #UI_ENHANCEMENT by cg
Claus Gittinger <cg@exept.de>
parents: 1649
diff changeset
   871
     
899889bd8404 #UI_ENHANCEMENT by cg
Claus Gittinger <cg@exept.de>
parents: 1649
diff changeset
   872
    "/ OFB-AES-192
899889bd8404 #UI_ENHANCEMENT by cg
Claus Gittinger <cg@exept.de>
parents: 1649
diff changeset
   873
    
899889bd8404 #UI_ENHANCEMENT by cg
Claus Gittinger <cg@exept.de>
parents: 1649
diff changeset
   874
    key := ('8e73b0f7da0e6452c810f32b809079e562f8ead2522c6b7b' 
899889bd8404 #UI_ENHANCEMENT by cg
Claus Gittinger <cg@exept.de>
parents: 1649
diff changeset
   875
            pairWiseCollect:[:b1 :b2 | 
899889bd8404 #UI_ENHANCEMENT by cg
Claus Gittinger <cg@exept.de>
parents: 1649
diff changeset
   876
                Character value:(Integer readFrom:(b1 asString , b2) radix:16).
899889bd8404 #UI_ENHANCEMENT by cg
Claus Gittinger <cg@exept.de>
parents: 1649
diff changeset
   877
            ]) 
899889bd8404 #UI_ENHANCEMENT by cg
Claus Gittinger <cg@exept.de>
parents: 1649
diff changeset
   878
                asByteArray.
899889bd8404 #UI_ENHANCEMENT by cg
Claus Gittinger <cg@exept.de>
parents: 1649
diff changeset
   879
    plaintext := ('6bc1bee22e409f96e93d7e117393172aae2d8a571e03ac9c9eb76fac45af8e5130c81c46a35ce411e5fbc1191a0a52eff69f2445df4f9b17ad2b417be66c3710' 
899889bd8404 #UI_ENHANCEMENT by cg
Claus Gittinger <cg@exept.de>
parents: 1649
diff changeset
   880
            pairWiseCollect:[:b1 :b2 | 
899889bd8404 #UI_ENHANCEMENT by cg
Claus Gittinger <cg@exept.de>
parents: 1649
diff changeset
   881
                Character value:(Integer readFrom:(b1 asString , b2) radix:16).
899889bd8404 #UI_ENHANCEMENT by cg
Claus Gittinger <cg@exept.de>
parents: 1649
diff changeset
   882
            ]) 
899889bd8404 #UI_ENHANCEMENT by cg
Claus Gittinger <cg@exept.de>
parents: 1649
diff changeset
   883
                asByteArray.
899889bd8404 #UI_ENHANCEMENT by cg
Claus Gittinger <cg@exept.de>
parents: 1649
diff changeset
   884
    iv := ('000102030405060708090a0b0c0d0e0f' 
899889bd8404 #UI_ENHANCEMENT by cg
Claus Gittinger <cg@exept.de>
parents: 1649
diff changeset
   885
            pairWiseCollect:[:b1 :b2 | 
899889bd8404 #UI_ENHANCEMENT by cg
Claus Gittinger <cg@exept.de>
parents: 1649
diff changeset
   886
                Character value:(Integer readFrom:(b1 asString , b2) radix:16).
899889bd8404 #UI_ENHANCEMENT by cg
Claus Gittinger <cg@exept.de>
parents: 1649
diff changeset
   887
            ]) 
899889bd8404 #UI_ENHANCEMENT by cg
Claus Gittinger <cg@exept.de>
parents: 1649
diff changeset
   888
                asByteArray.
899889bd8404 #UI_ENHANCEMENT by cg
Claus Gittinger <cg@exept.de>
parents: 1649
diff changeset
   889
    ofb := RijndaelCipher new key:key mode:#OFB.
899889bd8404 #UI_ENHANCEMENT by cg
Claus Gittinger <cg@exept.de>
parents: 1649
diff changeset
   890
    ofb initializationVector:iv.
899889bd8404 #UI_ENHANCEMENT by cg
Claus Gittinger <cg@exept.de>
parents: 1649
diff changeset
   891
    crypted := ofb encrypt:plaintext.
899889bd8404 #UI_ENHANCEMENT by cg
Claus Gittinger <cg@exept.de>
parents: 1649
diff changeset
   892
    hx := crypted hexPrintString asLowercase.
899889bd8404 #UI_ENHANCEMENT by cg
Claus Gittinger <cg@exept.de>
parents: 1649
diff changeset
   893
    self assert:(hx 
899889bd8404 #UI_ENHANCEMENT by cg
Claus Gittinger <cg@exept.de>
parents: 1649
diff changeset
   894
                = 'cdc80d6fddf18cab34c25909c99a4174fcc28b8d4c63837c09e81700c11004018d9a9aeac0f6596f559c6d4daf59a5f26d9f200857ca6c3e9cac524bd9acc92a').
899889bd8404 #UI_ENHANCEMENT by cg
Claus Gittinger <cg@exept.de>
parents: 1649
diff changeset
   895
    ofb initializationVector:iv.
899889bd8404 #UI_ENHANCEMENT by cg
Claus Gittinger <cg@exept.de>
parents: 1649
diff changeset
   896
    self assert:(ofb decrypt:crypted) = plaintext.
899889bd8404 #UI_ENHANCEMENT by cg
Claus Gittinger <cg@exept.de>
parents: 1649
diff changeset
   897
     
899889bd8404 #UI_ENHANCEMENT by cg
Claus Gittinger <cg@exept.de>
parents: 1649
diff changeset
   898
    "/ OFB-AES-256
899889bd8404 #UI_ENHANCEMENT by cg
Claus Gittinger <cg@exept.de>
parents: 1649
diff changeset
   899
    
899889bd8404 #UI_ENHANCEMENT by cg
Claus Gittinger <cg@exept.de>
parents: 1649
diff changeset
   900
    key := ('603deb1015ca71be2b73aef0857d77811f352c073b6108d72d9810a30914dff4' 
899889bd8404 #UI_ENHANCEMENT by cg
Claus Gittinger <cg@exept.de>
parents: 1649
diff changeset
   901
            pairWiseCollect:[:b1 :b2 | 
899889bd8404 #UI_ENHANCEMENT by cg
Claus Gittinger <cg@exept.de>
parents: 1649
diff changeset
   902
                Character value:(Integer readFrom:(b1 asString , b2) radix:16).
899889bd8404 #UI_ENHANCEMENT by cg
Claus Gittinger <cg@exept.de>
parents: 1649
diff changeset
   903
            ]) 
899889bd8404 #UI_ENHANCEMENT by cg
Claus Gittinger <cg@exept.de>
parents: 1649
diff changeset
   904
                asByteArray.
899889bd8404 #UI_ENHANCEMENT by cg
Claus Gittinger <cg@exept.de>
parents: 1649
diff changeset
   905
    plaintext := ('6bc1bee22e409f96e93d7e117393172aae2d8a571e03ac9c9eb76fac45af8e5130c81c46a35ce411e5fbc1191a0a52eff69f2445df4f9b17ad2b417be66c3710' 
899889bd8404 #UI_ENHANCEMENT by cg
Claus Gittinger <cg@exept.de>
parents: 1649
diff changeset
   906
            pairWiseCollect:[:b1 :b2 | 
899889bd8404 #UI_ENHANCEMENT by cg
Claus Gittinger <cg@exept.de>
parents: 1649
diff changeset
   907
                Character value:(Integer readFrom:(b1 asString , b2) radix:16).
899889bd8404 #UI_ENHANCEMENT by cg
Claus Gittinger <cg@exept.de>
parents: 1649
diff changeset
   908
            ]) 
899889bd8404 #UI_ENHANCEMENT by cg
Claus Gittinger <cg@exept.de>
parents: 1649
diff changeset
   909
                asByteArray.
899889bd8404 #UI_ENHANCEMENT by cg
Claus Gittinger <cg@exept.de>
parents: 1649
diff changeset
   910
    iv := ('000102030405060708090a0b0c0d0e0f' 
899889bd8404 #UI_ENHANCEMENT by cg
Claus Gittinger <cg@exept.de>
parents: 1649
diff changeset
   911
            pairWiseCollect:[:b1 :b2 | 
899889bd8404 #UI_ENHANCEMENT by cg
Claus Gittinger <cg@exept.de>
parents: 1649
diff changeset
   912
                Character value:(Integer readFrom:(b1 asString , b2) radix:16).
899889bd8404 #UI_ENHANCEMENT by cg
Claus Gittinger <cg@exept.de>
parents: 1649
diff changeset
   913
            ]) 
899889bd8404 #UI_ENHANCEMENT by cg
Claus Gittinger <cg@exept.de>
parents: 1649
diff changeset
   914
                asByteArray.
899889bd8404 #UI_ENHANCEMENT by cg
Claus Gittinger <cg@exept.de>
parents: 1649
diff changeset
   915
    ofb := RijndaelCipher new key:key mode:#OFB.
899889bd8404 #UI_ENHANCEMENT by cg
Claus Gittinger <cg@exept.de>
parents: 1649
diff changeset
   916
    ofb initializationVector:iv.
899889bd8404 #UI_ENHANCEMENT by cg
Claus Gittinger <cg@exept.de>
parents: 1649
diff changeset
   917
    crypted := ofb encrypt:plaintext.
899889bd8404 #UI_ENHANCEMENT by cg
Claus Gittinger <cg@exept.de>
parents: 1649
diff changeset
   918
    hx := crypted hexPrintString asLowercase.
899889bd8404 #UI_ENHANCEMENT by cg
Claus Gittinger <cg@exept.de>
parents: 1649
diff changeset
   919
    self assert:(hx 
899889bd8404 #UI_ENHANCEMENT by cg
Claus Gittinger <cg@exept.de>
parents: 1649
diff changeset
   920
                = 'dc7e84bfda79164b7ecd8486985d38604febdc6740d20b3ac88f6ad82a4fb08d71ab47a086e86eedf39d1c5bba97c4080126141d67f37be8538f5a8be740e484').
899889bd8404 #UI_ENHANCEMENT by cg
Claus Gittinger <cg@exept.de>
parents: 1649
diff changeset
   921
    ofb initializationVector:iv.
899889bd8404 #UI_ENHANCEMENT by cg
Claus Gittinger <cg@exept.de>
parents: 1649
diff changeset
   922
    self assert:(ofb decrypt:crypted) = plaintext.
899889bd8404 #UI_ENHANCEMENT by cg
Claus Gittinger <cg@exept.de>
parents: 1649
diff changeset
   923
     
899889bd8404 #UI_ENHANCEMENT by cg
Claus Gittinger <cg@exept.de>
parents: 1649
diff changeset
   924
    "/ CTR-AES-128
899889bd8404 #UI_ENHANCEMENT by cg
Claus Gittinger <cg@exept.de>
parents: 1649
diff changeset
   925
    
899889bd8404 #UI_ENHANCEMENT by cg
Claus Gittinger <cg@exept.de>
parents: 1649
diff changeset
   926
    key := ByteArray fromHexString:'2b7e151628aed2a6abf7158809cf4f3c'.
899889bd8404 #UI_ENHANCEMENT by cg
Claus Gittinger <cg@exept.de>
parents: 1649
diff changeset
   927
    plaintext := ByteArray 
899889bd8404 #UI_ENHANCEMENT by cg
Claus Gittinger <cg@exept.de>
parents: 1649
diff changeset
   928
            fromHexString:'6bc1bee22e409f96e93d7e117393172aae2d8a571e03ac9c9eb76fac45af8e5130c81c46a35ce411e5fbc1191a0a52eff69f2445df4f9b17ad2b417be66c3710'.
899889bd8404 #UI_ENHANCEMENT by cg
Claus Gittinger <cg@exept.de>
parents: 1649
diff changeset
   929
    iv := ByteArray fromHexString:'f0f1f2f3f4f5f6f7f8f9fafbfcfdfeff'.
899889bd8404 #UI_ENHANCEMENT by cg
Claus Gittinger <cg@exept.de>
parents: 1649
diff changeset
   930
    ctr := RijndaelCipher new key:key mode:#CTR.
899889bd8404 #UI_ENHANCEMENT by cg
Claus Gittinger <cg@exept.de>
parents: 1649
diff changeset
   931
    ctr initializationVector:iv.
899889bd8404 #UI_ENHANCEMENT by cg
Claus Gittinger <cg@exept.de>
parents: 1649
diff changeset
   932
    crypted := ctr encrypt:plaintext.
899889bd8404 #UI_ENHANCEMENT by cg
Claus Gittinger <cg@exept.de>
parents: 1649
diff changeset
   933
    hx := crypted hexPrintString asLowercase.
899889bd8404 #UI_ENHANCEMENT by cg
Claus Gittinger <cg@exept.de>
parents: 1649
diff changeset
   934
    self assert:(hx 
899889bd8404 #UI_ENHANCEMENT by cg
Claus Gittinger <cg@exept.de>
parents: 1649
diff changeset
   935
                = '874d6191b620e3261bef6864990db6ce9806f66b7970fdff8617187bb9fffdff5ae4df3edbd5d35e5b4f09020db03eab1e031dda2fbe03d1792170a0f3009cee').
899889bd8404 #UI_ENHANCEMENT by cg
Claus Gittinger <cg@exept.de>
parents: 1649
diff changeset
   936
    ctr initializationVector:iv.
899889bd8404 #UI_ENHANCEMENT by cg
Claus Gittinger <cg@exept.de>
parents: 1649
diff changeset
   937
    self assert:(ctr decrypt:crypted) = plaintext.
899889bd8404 #UI_ENHANCEMENT by cg
Claus Gittinger <cg@exept.de>
parents: 1649
diff changeset
   938
     
899889bd8404 #UI_ENHANCEMENT by cg
Claus Gittinger <cg@exept.de>
parents: 1649
diff changeset
   939
    "/ CTR-AES-192
899889bd8404 #UI_ENHANCEMENT by cg
Claus Gittinger <cg@exept.de>
parents: 1649
diff changeset
   940
    
899889bd8404 #UI_ENHANCEMENT by cg
Claus Gittinger <cg@exept.de>
parents: 1649
diff changeset
   941
    key := ('8e73b0f7da0e6452c810f32b809079e562f8ead2522c6b7b' 
899889bd8404 #UI_ENHANCEMENT by cg
Claus Gittinger <cg@exept.de>
parents: 1649
diff changeset
   942
            pairWiseCollect:[:b1 :b2 | 
899889bd8404 #UI_ENHANCEMENT by cg
Claus Gittinger <cg@exept.de>
parents: 1649
diff changeset
   943
                Character value:(Integer readFrom:(b1 asString , b2) radix:16).
899889bd8404 #UI_ENHANCEMENT by cg
Claus Gittinger <cg@exept.de>
parents: 1649
diff changeset
   944
            ]) 
899889bd8404 #UI_ENHANCEMENT by cg
Claus Gittinger <cg@exept.de>
parents: 1649
diff changeset
   945
                asByteArray.
899889bd8404 #UI_ENHANCEMENT by cg
Claus Gittinger <cg@exept.de>
parents: 1649
diff changeset
   946
    plaintext := ('6bc1bee22e409f96e93d7e117393172aae2d8a571e03ac9c9eb76fac45af8e5130c81c46a35ce411e5fbc1191a0a52eff69f2445df4f9b17ad2b417be66c3710' 
899889bd8404 #UI_ENHANCEMENT by cg
Claus Gittinger <cg@exept.de>
parents: 1649
diff changeset
   947
            pairWiseCollect:[:b1 :b2 | 
899889bd8404 #UI_ENHANCEMENT by cg
Claus Gittinger <cg@exept.de>
parents: 1649
diff changeset
   948
                Character value:(Integer readFrom:(b1 asString , b2) radix:16).
899889bd8404 #UI_ENHANCEMENT by cg
Claus Gittinger <cg@exept.de>
parents: 1649
diff changeset
   949
            ]) 
899889bd8404 #UI_ENHANCEMENT by cg
Claus Gittinger <cg@exept.de>
parents: 1649
diff changeset
   950
                asByteArray.
899889bd8404 #UI_ENHANCEMENT by cg
Claus Gittinger <cg@exept.de>
parents: 1649
diff changeset
   951
    iv := ('f0f1f2f3f4f5f6f7f8f9fafbfcfdfeff' 
899889bd8404 #UI_ENHANCEMENT by cg
Claus Gittinger <cg@exept.de>
parents: 1649
diff changeset
   952
            pairWiseCollect:[:b1 :b2 | 
899889bd8404 #UI_ENHANCEMENT by cg
Claus Gittinger <cg@exept.de>
parents: 1649
diff changeset
   953
                Character value:(Integer readFrom:(b1 asString , b2) radix:16).
899889bd8404 #UI_ENHANCEMENT by cg
Claus Gittinger <cg@exept.de>
parents: 1649
diff changeset
   954
            ]) 
899889bd8404 #UI_ENHANCEMENT by cg
Claus Gittinger <cg@exept.de>
parents: 1649
diff changeset
   955
                asByteArray.
899889bd8404 #UI_ENHANCEMENT by cg
Claus Gittinger <cg@exept.de>
parents: 1649
diff changeset
   956
    ctr := RijndaelCipher new key:key mode:#CTR.
899889bd8404 #UI_ENHANCEMENT by cg
Claus Gittinger <cg@exept.de>
parents: 1649
diff changeset
   957
    ctr initializationVector:iv.
899889bd8404 #UI_ENHANCEMENT by cg
Claus Gittinger <cg@exept.de>
parents: 1649
diff changeset
   958
    crypted := ctr encrypt:plaintext.
899889bd8404 #UI_ENHANCEMENT by cg
Claus Gittinger <cg@exept.de>
parents: 1649
diff changeset
   959
    hx := crypted hexPrintString asLowercase.
899889bd8404 #UI_ENHANCEMENT by cg
Claus Gittinger <cg@exept.de>
parents: 1649
diff changeset
   960
    self assert:(hx 
899889bd8404 #UI_ENHANCEMENT by cg
Claus Gittinger <cg@exept.de>
parents: 1649
diff changeset
   961
                = '1abc932417521ca24f2b0459fe7e6e0b090339ec0aa6faefd5ccc2c6f4ce8e941e36b26bd1ebc670d1bd1d665620abf74f78a7f6d29809585a97daec58c6b050').
899889bd8404 #UI_ENHANCEMENT by cg
Claus Gittinger <cg@exept.de>
parents: 1649
diff changeset
   962
    ctr initializationVector:iv.
899889bd8404 #UI_ENHANCEMENT by cg
Claus Gittinger <cg@exept.de>
parents: 1649
diff changeset
   963
    self assert:(ctr decrypt:crypted) = plaintext.
899889bd8404 #UI_ENHANCEMENT by cg
Claus Gittinger <cg@exept.de>
parents: 1649
diff changeset
   964
     
899889bd8404 #UI_ENHANCEMENT by cg
Claus Gittinger <cg@exept.de>
parents: 1649
diff changeset
   965
    "/ CTR-AES-256
899889bd8404 #UI_ENHANCEMENT by cg
Claus Gittinger <cg@exept.de>
parents: 1649
diff changeset
   966
    
899889bd8404 #UI_ENHANCEMENT by cg
Claus Gittinger <cg@exept.de>
parents: 1649
diff changeset
   967
    key := ByteArray 
899889bd8404 #UI_ENHANCEMENT by cg
Claus Gittinger <cg@exept.de>
parents: 1649
diff changeset
   968
            fromHexString:'603deb1015ca71be2b73aef0857d77811f352c073b6108d72d9810a30914dff4'.
899889bd8404 #UI_ENHANCEMENT by cg
Claus Gittinger <cg@exept.de>
parents: 1649
diff changeset
   969
    plaintext := ByteArray 
899889bd8404 #UI_ENHANCEMENT by cg
Claus Gittinger <cg@exept.de>
parents: 1649
diff changeset
   970
            fromHexString:'6bc1bee22e409f96e93d7e117393172aae2d8a571e03ac9c9eb76fac45af8e5130c81c46a35ce411e5fbc1191a0a52eff69f2445df4f9b17ad2b417be66c3710'.
899889bd8404 #UI_ENHANCEMENT by cg
Claus Gittinger <cg@exept.de>
parents: 1649
diff changeset
   971
    iv := ByteArray fromHexString:'f0f1f2f3f4f5f6f7f8f9fafbfcfdfeff'.
899889bd8404 #UI_ENHANCEMENT by cg
Claus Gittinger <cg@exept.de>
parents: 1649
diff changeset
   972
    ctr := RijndaelCipher new key:key mode:#CTR.
899889bd8404 #UI_ENHANCEMENT by cg
Claus Gittinger <cg@exept.de>
parents: 1649
diff changeset
   973
    ctr initializationVector:iv.
899889bd8404 #UI_ENHANCEMENT by cg
Claus Gittinger <cg@exept.de>
parents: 1649
diff changeset
   974
    crypted := ctr encrypt:plaintext.
899889bd8404 #UI_ENHANCEMENT by cg
Claus Gittinger <cg@exept.de>
parents: 1649
diff changeset
   975
    hx := crypted hexPrintString asLowercase.
899889bd8404 #UI_ENHANCEMENT by cg
Claus Gittinger <cg@exept.de>
parents: 1649
diff changeset
   976
    self assert:(hx 
899889bd8404 #UI_ENHANCEMENT by cg
Claus Gittinger <cg@exept.de>
parents: 1649
diff changeset
   977
                = '601ec313775789a5b7a7f504bbf3d228f443e3ca4d62b59aca84e990cacaf5c52b0930daa23de94ce87017ba2d84988ddfc9c58db67aada613c2dd08457941a6').
899889bd8404 #UI_ENHANCEMENT by cg
Claus Gittinger <cg@exept.de>
parents: 1649
diff changeset
   978
    ctr initializationVector:iv.
899889bd8404 #UI_ENHANCEMENT by cg
Claus Gittinger <cg@exept.de>
parents: 1649
diff changeset
   979
    self assert:(ctr decrypt:crypted) = plaintext.
899889bd8404 #UI_ENHANCEMENT by cg
Claus Gittinger <cg@exept.de>
parents: 1649
diff changeset
   980
899889bd8404 #UI_ENHANCEMENT by cg
Claus Gittinger <cg@exept.de>
parents: 1649
diff changeset
   981
    "
899889bd8404 #UI_ENHANCEMENT by cg
Claus Gittinger <cg@exept.de>
parents: 1649
diff changeset
   982
     self run:#test12_aesRijndael
899889bd8404 #UI_ENHANCEMENT by cg
Claus Gittinger <cg@exept.de>
parents: 1649
diff changeset
   983
     self new test12_aesRijndael"
899889bd8404 #UI_ENHANCEMENT by cg
Claus Gittinger <cg@exept.de>
parents: 1649
diff changeset
   984
899889bd8404 #UI_ENHANCEMENT by cg
Claus Gittinger <cg@exept.de>
parents: 1649
diff changeset
   985
    "Created: / 26-07-2017 / 09:09:22 / cg"
899889bd8404 #UI_ENHANCEMENT by cg
Claus Gittinger <cg@exept.de>
parents: 1649
diff changeset
   986
    "Modified (format): / 23-08-2017 / 15:51:45 / cg"
2122
a9c72db987e7 #QUALITY by cg
Claus Gittinger <cg@exept.de>
parents: 2053
diff changeset
   987
!
a9c72db987e7 #QUALITY by cg
Claus Gittinger <cg@exept.de>
parents: 2053
diff changeset
   988
a9c72db987e7 #QUALITY by cg
Claus Gittinger <cg@exept.de>
parents: 2053
diff changeset
   989
test16_sha3_256
a9c72db987e7 #QUALITY by cg
Claus Gittinger <cg@exept.de>
parents: 2053
diff changeset
   990
    |h|
a9c72db987e7 #QUALITY by cg
Claus Gittinger <cg@exept.de>
parents: 2053
diff changeset
   991
a9c72db987e7 #QUALITY by cg
Claus Gittinger <cg@exept.de>
parents: 2053
diff changeset
   992
    "/ test vectors from https://www.di-mgt.com.au/sha_testvectors.html
a9c72db987e7 #QUALITY by cg
Claus Gittinger <cg@exept.de>
parents: 2053
diff changeset
   993
    "/ and others
a9c72db987e7 #QUALITY by cg
Claus Gittinger <cg@exept.de>
parents: 2053
diff changeset
   994
a9c72db987e7 #QUALITY by cg
Claus Gittinger <cg@exept.de>
parents: 2053
diff changeset
   995
    self
a9c72db987e7 #QUALITY by cg
Claus Gittinger <cg@exept.de>
parents: 2053
diff changeset
   996
        skipIf:(SHA3_256Stream isBehavior not or:[SHA3_256Stream isLoaded not])
a9c72db987e7 #QUALITY by cg
Claus Gittinger <cg@exept.de>
parents: 2053
diff changeset
   997
        description:'SHA3_256Stream/libcrypt is not loaded'.
a9c72db987e7 #QUALITY by cg
Claus Gittinger <cg@exept.de>
parents: 2053
diff changeset
   998
a9c72db987e7 #QUALITY by cg
Claus Gittinger <cg@exept.de>
parents: 2053
diff changeset
   999
    h := SHA3_256Stream hashValueOf:''.
a9c72db987e7 #QUALITY by cg
Claus Gittinger <cg@exept.de>
parents: 2053
diff changeset
  1000
    self assert:(h = (ByteArray fromHexStringWithSeparators:'a7ffc6f8bf1ed766 51c14756a061d662 f580ff4de43b49fa 82d80a4b80f8434a')).
a9c72db987e7 #QUALITY by cg
Claus Gittinger <cg@exept.de>
parents: 2053
diff changeset
  1001
a9c72db987e7 #QUALITY by cg
Claus Gittinger <cg@exept.de>
parents: 2053
diff changeset
  1002
"/    h := SHA3_256Stream hashValueOf:'The quick brown fox jumps over the lazy dog'.
a9c72db987e7 #QUALITY by cg
Claus Gittinger <cg@exept.de>
parents: 2053
diff changeset
  1003
"/    self assert:(h = (ByteArray fromHexStringWithSeparators:'d7a8fbb307d7809469ca9abcb0082e4f8d5651e46d3cdb762d02d0bf37c9e592')).
a9c72db987e7 #QUALITY by cg
Claus Gittinger <cg@exept.de>
parents: 2053
diff changeset
  1004
a9c72db987e7 #QUALITY by cg
Claus Gittinger <cg@exept.de>
parents: 2053
diff changeset
  1005
    h := SHA3_256Stream hashValueOf:'abc'.
a9c72db987e7 #QUALITY by cg
Claus Gittinger <cg@exept.de>
parents: 2053
diff changeset
  1006
    self assert:(h = (ByteArray fromHexStringWithSeparators:'3a985da74fe225b2 045c172d6bd390bd 855f086e3e9d525b 46bfe24511431532')).
a9c72db987e7 #QUALITY by cg
Claus Gittinger <cg@exept.de>
parents: 2053
diff changeset
  1007
a9c72db987e7 #QUALITY by cg
Claus Gittinger <cg@exept.de>
parents: 2053
diff changeset
  1008
    h := SHA3_256Stream hashValueOf:'abcdbcdecdefdefgefghfghighijhijkijkljklmklmnlmnomnopnopq'.
a9c72db987e7 #QUALITY by cg
Claus Gittinger <cg@exept.de>
parents: 2053
diff changeset
  1009
    self assert:(h = (ByteArray fromHexStringWithSeparators:'41c0dba2a9d62408 49100376a8235e2c 82e1b9998a999e21 db32dd97496d3376')).
a9c72db987e7 #QUALITY by cg
Claus Gittinger <cg@exept.de>
parents: 2053
diff changeset
  1010
a9c72db987e7 #QUALITY by cg
Claus Gittinger <cg@exept.de>
parents: 2053
diff changeset
  1011
    h := SHA3_256Stream hashValueOf:'abcdefghbcdefghicdefghijdefghijkefghijklfghijklmghijklmnhijklmnoijklmnopjklmnopqklmnopqrlmnopqrsmnopqrstnopqrstu'.
a9c72db987e7 #QUALITY by cg
Claus Gittinger <cg@exept.de>
parents: 2053
diff changeset
  1012
    self assert:(h = (ByteArray fromHexStringWithSeparators:'916f6061fe879741 ca6469b43971dfdb 28b1a32dc36cb325 4e812be27aad1d18')).
a9c72db987e7 #QUALITY by cg
Claus Gittinger <cg@exept.de>
parents: 2053
diff changeset
  1013
a9c72db987e7 #QUALITY by cg
Claus Gittinger <cg@exept.de>
parents: 2053
diff changeset
  1014
    h := SHA3_256Stream hashValueOf:(String new:1000000 withAll:$a).
a9c72db987e7 #QUALITY by cg
Claus Gittinger <cg@exept.de>
parents: 2053
diff changeset
  1015
    self assert:(h = (ByteArray fromHexStringWithSeparators:'5c8875ae474a3634 ba4fd55ec85bffd6 61f32aca75c6d699 d0cdcb6c115891c1')).
a9c72db987e7 #QUALITY by cg
Claus Gittinger <cg@exept.de>
parents: 2053
diff changeset
  1016
a9c72db987e7 #QUALITY by cg
Claus Gittinger <cg@exept.de>
parents: 2053
diff changeset
  1017
    "
a9c72db987e7 #QUALITY by cg
Claus Gittinger <cg@exept.de>
parents: 2053
diff changeset
  1018
     self run:#test16_sha3_256
a9c72db987e7 #QUALITY by cg
Claus Gittinger <cg@exept.de>
parents: 2053
diff changeset
  1019
     self new test16_sha3_256
a9c72db987e7 #QUALITY by cg
Claus Gittinger <cg@exept.de>
parents: 2053
diff changeset
  1020
    "
a9c72db987e7 #QUALITY by cg
Claus Gittinger <cg@exept.de>
parents: 2053
diff changeset
  1021
a9c72db987e7 #QUALITY by cg
Claus Gittinger <cg@exept.de>
parents: 2053
diff changeset
  1022
    "Created: / 22-03-2019 / 12:41:10 / Claus Gittinger"
a9c72db987e7 #QUALITY by cg
Claus Gittinger <cg@exept.de>
parents: 2053
diff changeset
  1023
!
a9c72db987e7 #QUALITY by cg
Claus Gittinger <cg@exept.de>
parents: 2053
diff changeset
  1024
a9c72db987e7 #QUALITY by cg
Claus Gittinger <cg@exept.de>
parents: 2053
diff changeset
  1025
test17_sha3_224
a9c72db987e7 #QUALITY by cg
Claus Gittinger <cg@exept.de>
parents: 2053
diff changeset
  1026
    |h|
a9c72db987e7 #QUALITY by cg
Claus Gittinger <cg@exept.de>
parents: 2053
diff changeset
  1027
a9c72db987e7 #QUALITY by cg
Claus Gittinger <cg@exept.de>
parents: 2053
diff changeset
  1028
    "/ test vectors from https://www.di-mgt.com.au/sha_testvectors.html
a9c72db987e7 #QUALITY by cg
Claus Gittinger <cg@exept.de>
parents: 2053
diff changeset
  1029
    "/ and others
a9c72db987e7 #QUALITY by cg
Claus Gittinger <cg@exept.de>
parents: 2053
diff changeset
  1030
a9c72db987e7 #QUALITY by cg
Claus Gittinger <cg@exept.de>
parents: 2053
diff changeset
  1031
    self
a9c72db987e7 #QUALITY by cg
Claus Gittinger <cg@exept.de>
parents: 2053
diff changeset
  1032
        skipIf:(SHA3_224Stream isBehavior not or:[SHA3_224Stream isLoaded not])
a9c72db987e7 #QUALITY by cg
Claus Gittinger <cg@exept.de>
parents: 2053
diff changeset
  1033
        description:'SHA3_224Stream/libcrypt is not loaded'.
a9c72db987e7 #QUALITY by cg
Claus Gittinger <cg@exept.de>
parents: 2053
diff changeset
  1034
a9c72db987e7 #QUALITY by cg
Claus Gittinger <cg@exept.de>
parents: 2053
diff changeset
  1035
    h := SHA3_224Stream hashValueOf:''.
a9c72db987e7 #QUALITY by cg
Claus Gittinger <cg@exept.de>
parents: 2053
diff changeset
  1036
    self assert:(h = (ByteArray fromHexStringWithSeparators:'6b4e03423667dbb7 3b6e15454f0eb1ab d4597f9a1b078e3f 5b5a6bc7')).
a9c72db987e7 #QUALITY by cg
Claus Gittinger <cg@exept.de>
parents: 2053
diff changeset
  1037
a9c72db987e7 #QUALITY by cg
Claus Gittinger <cg@exept.de>
parents: 2053
diff changeset
  1038
"/    h := SHA3_224Stream hashValueOf:'The quick brown fox jumps over the lazy dog'.
a9c72db987e7 #QUALITY by cg
Claus Gittinger <cg@exept.de>
parents: 2053
diff changeset
  1039
"/    self assert:(h = (ByteArray fromHexStringWithSeparators:'d7a8fbb307d7809469ca9abcb0082e4f8d5651e46d3cdb762d02d0bf37c9e592')).
a9c72db987e7 #QUALITY by cg
Claus Gittinger <cg@exept.de>
parents: 2053
diff changeset
  1040
a9c72db987e7 #QUALITY by cg
Claus Gittinger <cg@exept.de>
parents: 2053
diff changeset
  1041
    h := SHA3_224Stream hashValueOf:'abc'.
a9c72db987e7 #QUALITY by cg
Claus Gittinger <cg@exept.de>
parents: 2053
diff changeset
  1042
    self assert:(h = (ByteArray fromHexStringWithSeparators:'e642824c3f8cf24a d09234ee7d3c766f c9a3a5168d0c94ad 73b46fdf')).
a9c72db987e7 #QUALITY by cg
Claus Gittinger <cg@exept.de>
parents: 2053
diff changeset
  1043
a9c72db987e7 #QUALITY by cg
Claus Gittinger <cg@exept.de>
parents: 2053
diff changeset
  1044
    h := SHA3_224Stream hashValueOf:'abcdbcdecdefdefgefghfghighijhijkijkljklmklmnlmnomnopnopq'.
a9c72db987e7 #QUALITY by cg
Claus Gittinger <cg@exept.de>
parents: 2053
diff changeset
  1045
    self assert:(h = (ByteArray fromHexStringWithSeparators:'8a24108b154ada21 c9fd5574494479ba 5c7e7ab76ef264ea d0fcce33')).
a9c72db987e7 #QUALITY by cg
Claus Gittinger <cg@exept.de>
parents: 2053
diff changeset
  1046
a9c72db987e7 #QUALITY by cg
Claus Gittinger <cg@exept.de>
parents: 2053
diff changeset
  1047
    h := SHA3_224Stream hashValueOf:'abcdefghbcdefghicdefghijdefghijkefghijklfghijklmghijklmnhijklmnoijklmnopjklmnopqklmnopqrlmnopqrsmnopqrstnopqrstu'.
a9c72db987e7 #QUALITY by cg
Claus Gittinger <cg@exept.de>
parents: 2053
diff changeset
  1048
    self assert:(h = (ByteArray fromHexStringWithSeparators:'543e6868e1666c1a 643630df77367ae5 a62a85070a51c14c bf665cbc')).
a9c72db987e7 #QUALITY by cg
Claus Gittinger <cg@exept.de>
parents: 2053
diff changeset
  1049
a9c72db987e7 #QUALITY by cg
Claus Gittinger <cg@exept.de>
parents: 2053
diff changeset
  1050
    h := SHA3_224Stream hashValueOf:(String new:1000000 withAll:$a).
a9c72db987e7 #QUALITY by cg
Claus Gittinger <cg@exept.de>
parents: 2053
diff changeset
  1051
    self assert:(h = (ByteArray fromHexStringWithSeparators:'d69335b93325192e 516a912e6d19a15c b51c6ed5c15243e7 a7fd653c')).
a9c72db987e7 #QUALITY by cg
Claus Gittinger <cg@exept.de>
parents: 2053
diff changeset
  1052
a9c72db987e7 #QUALITY by cg
Claus Gittinger <cg@exept.de>
parents: 2053
diff changeset
  1053
    "
a9c72db987e7 #QUALITY by cg
Claus Gittinger <cg@exept.de>
parents: 2053
diff changeset
  1054
     self run:#test17_sha3_224
a9c72db987e7 #QUALITY by cg
Claus Gittinger <cg@exept.de>
parents: 2053
diff changeset
  1055
     self new test17_sha3_224
a9c72db987e7 #QUALITY by cg
Claus Gittinger <cg@exept.de>
parents: 2053
diff changeset
  1056
    "
a9c72db987e7 #QUALITY by cg
Claus Gittinger <cg@exept.de>
parents: 2053
diff changeset
  1057
a9c72db987e7 #QUALITY by cg
Claus Gittinger <cg@exept.de>
parents: 2053
diff changeset
  1058
    "Created: / 22-03-2019 / 12:42:49 / Claus Gittinger"
a9c72db987e7 #QUALITY by cg
Claus Gittinger <cg@exept.de>
parents: 2053
diff changeset
  1059
!
a9c72db987e7 #QUALITY by cg
Claus Gittinger <cg@exept.de>
parents: 2053
diff changeset
  1060
a9c72db987e7 #QUALITY by cg
Claus Gittinger <cg@exept.de>
parents: 2053
diff changeset
  1061
test18_sha3_384
a9c72db987e7 #QUALITY by cg
Claus Gittinger <cg@exept.de>
parents: 2053
diff changeset
  1062
    |h|
a9c72db987e7 #QUALITY by cg
Claus Gittinger <cg@exept.de>
parents: 2053
diff changeset
  1063
a9c72db987e7 #QUALITY by cg
Claus Gittinger <cg@exept.de>
parents: 2053
diff changeset
  1064
    "/ test vectors from https://www.di-mgt.com.au/sha_testvectors.html
a9c72db987e7 #QUALITY by cg
Claus Gittinger <cg@exept.de>
parents: 2053
diff changeset
  1065
    "/ and others
a9c72db987e7 #QUALITY by cg
Claus Gittinger <cg@exept.de>
parents: 2053
diff changeset
  1066
a9c72db987e7 #QUALITY by cg
Claus Gittinger <cg@exept.de>
parents: 2053
diff changeset
  1067
    self
a9c72db987e7 #QUALITY by cg
Claus Gittinger <cg@exept.de>
parents: 2053
diff changeset
  1068
        skipIf:(SHA3_384Stream isBehavior not or:[SHA3_384Stream isLoaded not])
a9c72db987e7 #QUALITY by cg
Claus Gittinger <cg@exept.de>
parents: 2053
diff changeset
  1069
        description:'SHA3_384Stream/libcrypt is not loaded'.
a9c72db987e7 #QUALITY by cg
Claus Gittinger <cg@exept.de>
parents: 2053
diff changeset
  1070
a9c72db987e7 #QUALITY by cg
Claus Gittinger <cg@exept.de>
parents: 2053
diff changeset
  1071
    h := SHA3_384Stream hashValueOf:''.
a9c72db987e7 #QUALITY by cg
Claus Gittinger <cg@exept.de>
parents: 2053
diff changeset
  1072
    self assert:(h = (ByteArray fromHexStringWithSeparators:'0c63a75b845e4f7d 01107d852e4c2485 c51a50aaaa94fc61 995e71bbee983a2a c3713831264adb47 fb6bd1e058d5f004')).
a9c72db987e7 #QUALITY by cg
Claus Gittinger <cg@exept.de>
parents: 2053
diff changeset
  1073
a9c72db987e7 #QUALITY by cg
Claus Gittinger <cg@exept.de>
parents: 2053
diff changeset
  1074
"/    h := SHA3_384Stream hashValueOf:'The quick brown fox jumps over the lazy dog'.
a9c72db987e7 #QUALITY by cg
Claus Gittinger <cg@exept.de>
parents: 2053
diff changeset
  1075
"/    self assert:(h = (ByteArray fromHexStringWithSeparators:'d7a8fbb307d7809469ca9abcb0082e4f8d5651e46d3cdb762d02d0bf37c9e592')).
a9c72db987e7 #QUALITY by cg
Claus Gittinger <cg@exept.de>
parents: 2053
diff changeset
  1076
a9c72db987e7 #QUALITY by cg
Claus Gittinger <cg@exept.de>
parents: 2053
diff changeset
  1077
    h := SHA3_384Stream hashValueOf:'abc'.
a9c72db987e7 #QUALITY by cg
Claus Gittinger <cg@exept.de>
parents: 2053
diff changeset
  1078
    self assert:(h = (ByteArray fromHexStringWithSeparators:'ec01498288516fc9 26459f58e2c6ad8d f9b473cb0fc08c25 96da7cf0e49be4b2 98d88cea927ac7f5 39f1edf228376d25')).
a9c72db987e7 #QUALITY by cg
Claus Gittinger <cg@exept.de>
parents: 2053
diff changeset
  1079
a9c72db987e7 #QUALITY by cg
Claus Gittinger <cg@exept.de>
parents: 2053
diff changeset
  1080
    h := SHA3_384Stream hashValueOf:'abcdbcdecdefdefgefghfghighijhijkijkljklmklmnlmnomnopnopq'.
a9c72db987e7 #QUALITY by cg
Claus Gittinger <cg@exept.de>
parents: 2053
diff changeset
  1081
    self assert:(h = (ByteArray fromHexStringWithSeparators:'991c665755eb3a4b 6bbdfb75c78a492e 8c56a22c5c4d7e42 9bfdbc32b9d4ad5a a04a1f076e62fea1 9eef51acd0657c22')).
a9c72db987e7 #QUALITY by cg
Claus Gittinger <cg@exept.de>
parents: 2053
diff changeset
  1082
a9c72db987e7 #QUALITY by cg
Claus Gittinger <cg@exept.de>
parents: 2053
diff changeset
  1083
    h := SHA3_384Stream hashValueOf:'abcdefghbcdefghicdefghijdefghijkefghijklfghijklmghijklmnhijklmnoijklmnopjklmnopqklmnopqrlmnopqrsmnopqrstnopqrstu'.
a9c72db987e7 #QUALITY by cg
Claus Gittinger <cg@exept.de>
parents: 2053
diff changeset
  1084
    self assert:(h = (ByteArray fromHexStringWithSeparators:'79407d3b5916b59c 3e30b09822974791 c313fb9ecc849e40 6f23592d04f625dc 8c709b98b43b3852 b337216179aa7fc7')).
a9c72db987e7 #QUALITY by cg
Claus Gittinger <cg@exept.de>
parents: 2053
diff changeset
  1085
a9c72db987e7 #QUALITY by cg
Claus Gittinger <cg@exept.de>
parents: 2053
diff changeset
  1086
    h := SHA3_384Stream hashValueOf:(String new:1000000 withAll:$a).
a9c72db987e7 #QUALITY by cg
Claus Gittinger <cg@exept.de>
parents: 2053
diff changeset
  1087
    self assert:(h = (ByteArray fromHexStringWithSeparators:'eee9e24d78c18553 37983451df97c8ad 9eedf256c6334f8e 948d252d5e0e7684 7aa0774ddb90a842 190d2c558b4b8340')).
a9c72db987e7 #QUALITY by cg
Claus Gittinger <cg@exept.de>
parents: 2053
diff changeset
  1088
a9c72db987e7 #QUALITY by cg
Claus Gittinger <cg@exept.de>
parents: 2053
diff changeset
  1089
    "
a9c72db987e7 #QUALITY by cg
Claus Gittinger <cg@exept.de>
parents: 2053
diff changeset
  1090
     self run:#test18_sha3_384
a9c72db987e7 #QUALITY by cg
Claus Gittinger <cg@exept.de>
parents: 2053
diff changeset
  1091
     self new test18_sha3_384
a9c72db987e7 #QUALITY by cg
Claus Gittinger <cg@exept.de>
parents: 2053
diff changeset
  1092
    "
a9c72db987e7 #QUALITY by cg
Claus Gittinger <cg@exept.de>
parents: 2053
diff changeset
  1093
a9c72db987e7 #QUALITY by cg
Claus Gittinger <cg@exept.de>
parents: 2053
diff changeset
  1094
    "Created: / 22-03-2019 / 12:44:17 / Claus Gittinger"
a9c72db987e7 #QUALITY by cg
Claus Gittinger <cg@exept.de>
parents: 2053
diff changeset
  1095
!
a9c72db987e7 #QUALITY by cg
Claus Gittinger <cg@exept.de>
parents: 2053
diff changeset
  1096
a9c72db987e7 #QUALITY by cg
Claus Gittinger <cg@exept.de>
parents: 2053
diff changeset
  1097
test19_sha3_512
a9c72db987e7 #QUALITY by cg
Claus Gittinger <cg@exept.de>
parents: 2053
diff changeset
  1098
    |h|
a9c72db987e7 #QUALITY by cg
Claus Gittinger <cg@exept.de>
parents: 2053
diff changeset
  1099
2141
3f081e763b87 #QUALITY by cg
Claus Gittinger <cg@exept.de>
parents: 2140
diff changeset
  1100
    "/ test vectors from https://www.di-mgt.com.au/sha_testvectors.html,
3f081e763b87 #QUALITY by cg
Claus Gittinger <cg@exept.de>
parents: 2140
diff changeset
  1101
    "/ https://github.com/XKCP/XKCP/blob/master/tests/TestVectors/ShortMsgKAT_SHA3-512.txt
2122
a9c72db987e7 #QUALITY by cg
Claus Gittinger <cg@exept.de>
parents: 2053
diff changeset
  1102
    "/ and others
a9c72db987e7 #QUALITY by cg
Claus Gittinger <cg@exept.de>
parents: 2053
diff changeset
  1103
a9c72db987e7 #QUALITY by cg
Claus Gittinger <cg@exept.de>
parents: 2053
diff changeset
  1104
    self
a9c72db987e7 #QUALITY by cg
Claus Gittinger <cg@exept.de>
parents: 2053
diff changeset
  1105
        skipIf:(SHA3_512Stream isBehavior not or:[SHA3_512Stream isLoaded not])
a9c72db987e7 #QUALITY by cg
Claus Gittinger <cg@exept.de>
parents: 2053
diff changeset
  1106
        description:'SHA3_512Stream/libcrypt is not loaded'.
a9c72db987e7 #QUALITY by cg
Claus Gittinger <cg@exept.de>
parents: 2053
diff changeset
  1107
a9c72db987e7 #QUALITY by cg
Claus Gittinger <cg@exept.de>
parents: 2053
diff changeset
  1108
    h := SHA3_512Stream hashValueOf:''.
a9c72db987e7 #QUALITY by cg
Claus Gittinger <cg@exept.de>
parents: 2053
diff changeset
  1109
    self assert:(h = (ByteArray fromHexStringWithSeparators:'a69f73cca23a9ac5 c8b567dc185a756e 97c982164fe25859 e0d1dcc1475c80a6 15b2123af1f5f94c 11e3e9402c3ac558 f500199d95b6d3e3 01758586281dcd26')).
a9c72db987e7 #QUALITY by cg
Claus Gittinger <cg@exept.de>
parents: 2053
diff changeset
  1110
2141
3f081e763b87 #QUALITY by cg
Claus Gittinger <cg@exept.de>
parents: 2140
diff changeset
  1111
    h := SHA3_512Stream hashValueOf:#[16rcc].
3f081e763b87 #QUALITY by cg
Claus Gittinger <cg@exept.de>
parents: 2140
diff changeset
  1112
    self assert:(h = (ByteArray fromHexStringWithSeparators:'3939FCC8B57B63612542DA31A834E5DCC36E2EE0F652AC72E02624FA2E5ADEECC7DD6BB3580224B4D6138706FC6E80597B528051230B00621CC2B22999EAA205')).
3f081e763b87 #QUALITY by cg
Claus Gittinger <cg@exept.de>
parents: 2140
diff changeset
  1113
3f081e763b87 #QUALITY by cg
Claus Gittinger <cg@exept.de>
parents: 2140
diff changeset
  1114
    h := SHA3_512Stream hashValueOf:#[16r41 16rFB].
3f081e763b87 #QUALITY by cg
Claus Gittinger <cg@exept.de>
parents: 2140
diff changeset
  1115
    self assert:(h = (ByteArray fromHexStringWithSeparators:'AA092865A40694D91754DBC767B5202C546E226877147A95CB8B4C8F8709FE8CD6905256B089DA37896EA5CA19D2CD9AB94C7192FC39F7CD4D598975A3013C69')).
3f081e763b87 #QUALITY by cg
Claus Gittinger <cg@exept.de>
parents: 2140
diff changeset
  1116
3f081e763b87 #QUALITY by cg
Claus Gittinger <cg@exept.de>
parents: 2140
diff changeset
  1117
    h := SHA3_512Stream hashValueOf:#[16r1F 16r87 16r7C].
3f081e763b87 #QUALITY by cg
Claus Gittinger <cg@exept.de>
parents: 2140
diff changeset
  1118
    self assert:(h = (ByteArray fromHexStringWithSeparators:'CB20DCF54955F8091111688BECCEF48C1A2F0D0608C3A575163751F002DB30F40F2F671834B22D208591CFAF1F5ECFE43C49863A53B3225BDFD7C6591BA7658B')).
3f081e763b87 #QUALITY by cg
Claus Gittinger <cg@exept.de>
parents: 2140
diff changeset
  1119
3f081e763b87 #QUALITY by cg
Claus Gittinger <cg@exept.de>
parents: 2140
diff changeset
  1120
    h := SHA3_512Stream hashValueOf:#[16r21 16rF1 16r34 16rAC 16r57].
3f081e763b87 #QUALITY by cg
Claus Gittinger <cg@exept.de>
parents: 2140
diff changeset
  1121
    self assert:(h = (ByteArray fromHexStringWithSeparators:'584219A84E8796076BF1178B14B9D1E2F96A4B4EF11F10CC516FBE1A29639D6BA74FB92815F9E3C5192ED4DCA20AEA5B109D52237C9956401FD44B221F82AB37')).
3f081e763b87 #QUALITY by cg
Claus Gittinger <cg@exept.de>
parents: 2140
diff changeset
  1122
2122
a9c72db987e7 #QUALITY by cg
Claus Gittinger <cg@exept.de>
parents: 2053
diff changeset
  1123
"/    h := SHA3_512Stream hashValueOf:'The quick brown fox jumps over the lazy dog'.
a9c72db987e7 #QUALITY by cg
Claus Gittinger <cg@exept.de>
parents: 2053
diff changeset
  1124
"/    self assert:(h = (ByteArray fromHexStringWithSeparators:'d7a8fbb307d7809469ca9abcb0082e4f8d5651e46d3cdb762d02d0bf37c9e592')).
a9c72db987e7 #QUALITY by cg
Claus Gittinger <cg@exept.de>
parents: 2053
diff changeset
  1125
a9c72db987e7 #QUALITY by cg
Claus Gittinger <cg@exept.de>
parents: 2053
diff changeset
  1126
    h := SHA3_512Stream hashValueOf:'abc'.
a9c72db987e7 #QUALITY by cg
Claus Gittinger <cg@exept.de>
parents: 2053
diff changeset
  1127
    self assert:(h = (ByteArray fromHexStringWithSeparators:'b751850b1a57168a 5693cd924b6b096e 08f621827444f70d 884f5d0240d2712e 10e116e9192af3c9 1a7ec57647e39340 57340b4cf408d5a5 6592f8274eec53f0')).
a9c72db987e7 #QUALITY by cg
Claus Gittinger <cg@exept.de>
parents: 2053
diff changeset
  1128
a9c72db987e7 #QUALITY by cg
Claus Gittinger <cg@exept.de>
parents: 2053
diff changeset
  1129
    h := SHA3_512Stream hashValueOf:'abcdbcdecdefdefgefghfghighijhijkijkljklmklmnlmnomnopnopq'.
a9c72db987e7 #QUALITY by cg
Claus Gittinger <cg@exept.de>
parents: 2053
diff changeset
  1130
    self assert:(h = (ByteArray fromHexStringWithSeparators:'04a371e84ecfb5b8 b77cb48610fca818 2dd457ce6f326a0f d3d7ec2f1e91636d ee691fbe0c985302 ba1b0d8dc78c0863 46b533b49c030d99 a27daf1139d6e75e')).
a9c72db987e7 #QUALITY by cg
Claus Gittinger <cg@exept.de>
parents: 2053
diff changeset
  1131
a9c72db987e7 #QUALITY by cg
Claus Gittinger <cg@exept.de>
parents: 2053
diff changeset
  1132
    h := SHA3_512Stream hashValueOf:'abcdefghbcdefghicdefghijdefghijkefghijklfghijklmghijklmnhijklmnoijklmnopjklmnopqklmnopqrlmnopqrsmnopqrstnopqrstu'.
a9c72db987e7 #QUALITY by cg
Claus Gittinger <cg@exept.de>
parents: 2053
diff changeset
  1133
    self assert:(h = (ByteArray fromHexStringWithSeparators:'afebb2ef542e6579 c50cad06d2e578f9 f8dd6881d7dc824d 26360feebf18a4fa 73e3261122948efc fd492e74e82e2189 ed0fb440d187f382 270cb455f21dd185')).
a9c72db987e7 #QUALITY by cg
Claus Gittinger <cg@exept.de>
parents: 2053
diff changeset
  1134
a9c72db987e7 #QUALITY by cg
Claus Gittinger <cg@exept.de>
parents: 2053
diff changeset
  1135
    h := SHA3_512Stream hashValueOf:(String new:1000000 withAll:$a).
a9c72db987e7 #QUALITY by cg
Claus Gittinger <cg@exept.de>
parents: 2053
diff changeset
  1136
    self assert:(h = (ByteArray fromHexStringWithSeparators:'3c3a876da14034ab 60627c077bb98f7e 120a2a5370212dff b3385a18d4f38859 ed311d0a9d5141ce 9cc5c66ee689b266 a8aa18ace8282a0e 0db596c90b0a7b87')).
a9c72db987e7 #QUALITY by cg
Claus Gittinger <cg@exept.de>
parents: 2053
diff changeset
  1137
a9c72db987e7 #QUALITY by cg
Claus Gittinger <cg@exept.de>
parents: 2053
diff changeset
  1138
    "
a9c72db987e7 #QUALITY by cg
Claus Gittinger <cg@exept.de>
parents: 2053
diff changeset
  1139
     self run:#test19_sha3_512
a9c72db987e7 #QUALITY by cg
Claus Gittinger <cg@exept.de>
parents: 2053
diff changeset
  1140
     self new test19_sha3_512
a9c72db987e7 #QUALITY by cg
Claus Gittinger <cg@exept.de>
parents: 2053
diff changeset
  1141
    "
a9c72db987e7 #QUALITY by cg
Claus Gittinger <cg@exept.de>
parents: 2053
diff changeset
  1142
a9c72db987e7 #QUALITY by cg
Claus Gittinger <cg@exept.de>
parents: 2053
diff changeset
  1143
    "Created: / 22-03-2019 / 12:45:45 / Claus Gittinger"
2141
3f081e763b87 #QUALITY by cg
Claus Gittinger <cg@exept.de>
parents: 2140
diff changeset
  1144
    "Modified: / 23-03-2019 / 23:25:53 / Claus Gittinger"
2135
e15ffe219b3f #QUALITY by cg
Claus Gittinger <cg@exept.de>
parents: 2122
diff changeset
  1145
!
e15ffe219b3f #QUALITY by cg
Claus Gittinger <cg@exept.de>
parents: 2122
diff changeset
  1146
e15ffe219b3f #QUALITY by cg
Claus Gittinger <cg@exept.de>
parents: 2122
diff changeset
  1147
test99_speed
e15ffe219b3f #QUALITY by cg
Claus Gittinger <cg@exept.de>
parents: 2122
diff changeset
  1148
    |oneTest speedTest|
e15ffe219b3f #QUALITY by cg
Claus Gittinger <cg@exept.de>
parents: 2122
diff changeset
  1149
e15ffe219b3f #QUALITY by cg
Claus Gittinger <cg@exept.de>
parents: 2122
diff changeset
  1150
    self skipIf:true description:'speedtest; not part of automated test suite'.
e15ffe219b3f #QUALITY by cg
Claus Gittinger <cg@exept.de>
parents: 2122
diff changeset
  1151
e15ffe219b3f #QUALITY by cg
Claus Gittinger <cg@exept.de>
parents: 2122
diff changeset
  1152
    oneTest := [:name :hashStream :n :s |
e15ffe219b3f #QUALITY by cg
Claus Gittinger <cg@exept.de>
parents: 2122
diff changeset
  1153
        |l t nMb|
e15ffe219b3f #QUALITY by cg
Claus Gittinger <cg@exept.de>
parents: 2122
diff changeset
  1154
e15ffe219b3f #QUALITY by cg
Claus Gittinger <cg@exept.de>
parents: 2122
diff changeset
  1155
        l := s size.
e15ffe219b3f #QUALITY by cg
Claus Gittinger <cg@exept.de>
parents: 2122
diff changeset
  1156
        t := Time millisecondsToRun:[
e15ffe219b3f #QUALITY by cg
Claus Gittinger <cg@exept.de>
parents: 2122
diff changeset
  1157
                n timesRepeat:[
e15ffe219b3f #QUALITY by cg
Claus Gittinger <cg@exept.de>
parents: 2122
diff changeset
  1158
                        hashStream nextPutAll:s
e15ffe219b3f #QUALITY by cg
Claus Gittinger <cg@exept.de>
parents: 2122
diff changeset
  1159
                ].
e15ffe219b3f #QUALITY by cg
Claus Gittinger <cg@exept.de>
parents: 2122
diff changeset
  1160
             ].
e15ffe219b3f #QUALITY by cg
Claus Gittinger <cg@exept.de>
parents: 2122
diff changeset
  1161
        t := (t / 1000) asFloat.
e15ffe219b3f #QUALITY by cg
Claus Gittinger <cg@exept.de>
parents: 2122
diff changeset
  1162
        nMb := n*l/1024/1024.
e15ffe219b3f #QUALITY by cg
Claus Gittinger <cg@exept.de>
parents: 2122
diff changeset
  1163
        Transcript showCR:'%1: %2 (chunk size %3)' with:name with:(hashStream hashValue hexPrintString) with:l.
e15ffe219b3f #QUALITY by cg
Claus Gittinger <cg@exept.de>
parents: 2122
diff changeset
  1164
        Transcript showCR:'  %1 seconds for %2 Mb' with:t with:(nMb asFixedPoint:2).
e15ffe219b3f #QUALITY by cg
Claus Gittinger <cg@exept.de>
parents: 2122
diff changeset
  1165
        Transcript showCR:'  %1 Mb/s' with:((nMb / t) asFixedPoint:2).
e15ffe219b3f #QUALITY by cg
Claus Gittinger <cg@exept.de>
parents: 2122
diff changeset
  1166
    ].
e15ffe219b3f #QUALITY by cg
Claus Gittinger <cg@exept.de>
parents: 2122
diff changeset
  1167
e15ffe219b3f #QUALITY by cg
Claus Gittinger <cg@exept.de>
parents: 2122
diff changeset
  1168
    speedTest := [:name :hashStreamMaker |
e15ffe219b3f #QUALITY by cg
Claus Gittinger <cg@exept.de>
parents: 2122
diff changeset
  1169
        Transcript showCR:'-----------------------'.
e15ffe219b3f #QUALITY by cg
Claus Gittinger <cg@exept.de>
parents: 2122
diff changeset
  1170
        oneTest 
e15ffe219b3f #QUALITY by cg
Claus Gittinger <cg@exept.de>
parents: 2122
diff changeset
  1171
            value:name value:(hashStreamMaker value) value:2000000
e15ffe219b3f #QUALITY by cg
Claus Gittinger <cg@exept.de>
parents: 2122
diff changeset
  1172
            value:'1234567890'.
e15ffe219b3f #QUALITY by cg
Claus Gittinger <cg@exept.de>
parents: 2122
diff changeset
  1173
        oneTest
e15ffe219b3f #QUALITY by cg
Claus Gittinger <cg@exept.de>
parents: 2122
diff changeset
  1174
            value:name value:(hashStreamMaker value) value:2000000
e15ffe219b3f #QUALITY by cg
Claus Gittinger <cg@exept.de>
parents: 2122
diff changeset
  1175
            value:'12345678901234567890123456789012345678901234567890'.
e15ffe219b3f #QUALITY by cg
Claus Gittinger <cg@exept.de>
parents: 2122
diff changeset
  1176
        oneTest
e15ffe219b3f #QUALITY by cg
Claus Gittinger <cg@exept.de>
parents: 2122
diff changeset
  1177
            value:name value:(hashStreamMaker value) value:200000
e15ffe219b3f #QUALITY by cg
Claus Gittinger <cg@exept.de>
parents: 2122
diff changeset
  1178
            value:('12345678901234567890123456789012345678901234567890' ,* 20).
e15ffe219b3f #QUALITY by cg
Claus Gittinger <cg@exept.de>
parents: 2122
diff changeset
  1179
        oneTest
e15ffe219b3f #QUALITY by cg
Claus Gittinger <cg@exept.de>
parents: 2122
diff changeset
  1180
            value:name value:(hashStreamMaker value) value:20000
e15ffe219b3f #QUALITY by cg
Claus Gittinger <cg@exept.de>
parents: 2122
diff changeset
  1181
            value:('12345678901234567890123456789012345678901234567890' ,* 1000).
e15ffe219b3f #QUALITY by cg
Claus Gittinger <cg@exept.de>
parents: 2122
diff changeset
  1182
    ].
e15ffe219b3f #QUALITY by cg
Claus Gittinger <cg@exept.de>
parents: 2122
diff changeset
  1183
e15ffe219b3f #QUALITY by cg
Claus Gittinger <cg@exept.de>
parents: 2122
diff changeset
  1184
    speedTest 
e15ffe219b3f #QUALITY by cg
Claus Gittinger <cg@exept.de>
parents: 2122
diff changeset
  1185
        value:'md5' value:[MD5Stream new].
e15ffe219b3f #QUALITY by cg
Claus Gittinger <cg@exept.de>
parents: 2122
diff changeset
  1186
    speedTest 
e15ffe219b3f #QUALITY by cg
Claus Gittinger <cg@exept.de>
parents: 2122
diff changeset
  1187
        value:'sha1' value:[SHA1Stream new].
2140
52c5782a14b9 #DOCUMENTATION by cg
Claus Gittinger <cg@exept.de>
parents: 2139
diff changeset
  1188
    speedTest 
52c5782a14b9 #DOCUMENTATION by cg
Claus Gittinger <cg@exept.de>
parents: 2139
diff changeset
  1189
        value:'sha2-256' value:[SHA256Stream new].
52c5782a14b9 #DOCUMENTATION by cg
Claus Gittinger <cg@exept.de>
parents: 2139
diff changeset
  1190
    speedTest 
52c5782a14b9 #DOCUMENTATION by cg
Claus Gittinger <cg@exept.de>
parents: 2139
diff changeset
  1191
        value:'sha2-512' value:[SHA512Stream new].
52c5782a14b9 #DOCUMENTATION by cg
Claus Gittinger <cg@exept.de>
parents: 2139
diff changeset
  1192
    speedTest 
52c5782a14b9 #DOCUMENTATION by cg
Claus Gittinger <cg@exept.de>
parents: 2139
diff changeset
  1193
        value:'sha3-256' value:[SHA3_256Stream new].
52c5782a14b9 #DOCUMENTATION by cg
Claus Gittinger <cg@exept.de>
parents: 2139
diff changeset
  1194
    speedTest 
52c5782a14b9 #DOCUMENTATION by cg
Claus Gittinger <cg@exept.de>
parents: 2139
diff changeset
  1195
        value:'sha3-512' value:[SHA3_512Stream new].
52c5782a14b9 #DOCUMENTATION by cg
Claus Gittinger <cg@exept.de>
parents: 2139
diff changeset
  1196
52c5782a14b9 #DOCUMENTATION by cg
Claus Gittinger <cg@exept.de>
parents: 2139
diff changeset
  1197
    "current values (2012 MacBook; 2.6Ghz CoreI7):
52c5782a14b9 #DOCUMENTATION by cg
Claus Gittinger <cg@exept.de>
parents: 2139
diff changeset
  1198
md5: (chunk size 10)          61.53 Mb/s
52c5782a14b9 #DOCUMENTATION by cg
Claus Gittinger <cg@exept.de>
parents: 2139
diff changeset
  1199
md5: (chunk size 50)         156.34 Mb/s
52c5782a14b9 #DOCUMENTATION by cg
Claus Gittinger <cg@exept.de>
parents: 2139
diff changeset
  1200
md5: (chunk size 1000)       257.75 Mb/s
52c5782a14b9 #DOCUMENTATION by cg
Claus Gittinger <cg@exept.de>
parents: 2139
diff changeset
  1201
md5: (chunk size 50000)      277.23 Mb/s
52c5782a14b9 #DOCUMENTATION by cg
Claus Gittinger <cg@exept.de>
parents: 2139
diff changeset
  1202
-----------------------
52c5782a14b9 #DOCUMENTATION by cg
Claus Gittinger <cg@exept.de>
parents: 2139
diff changeset
  1203
sha1: (chunk size 10)         76.29 Mb/s
52c5782a14b9 #DOCUMENTATION by cg
Claus Gittinger <cg@exept.de>
parents: 2139
diff changeset
  1204
sha1: (chunk size 50)        211.93 Mb/s
52c5782a14b9 #DOCUMENTATION by cg
Claus Gittinger <cg@exept.de>
parents: 2139
diff changeset
  1205
sha1: (chunk size 1000)      433.49 Mb/s
52c5782a14b9 #DOCUMENTATION by cg
Claus Gittinger <cg@exept.de>
parents: 2139
diff changeset
  1206
sha1: (chunk size 50000)     449.85 Mb/s
52c5782a14b9 #DOCUMENTATION by cg
Claus Gittinger <cg@exept.de>
parents: 2139
diff changeset
  1207
-----------------------
52c5782a14b9 #DOCUMENTATION by cg
Claus Gittinger <cg@exept.de>
parents: 2139
diff changeset
  1208
sha2-256: (chunk size 10)     59.60 Mb/s
52c5782a14b9 #DOCUMENTATION by cg
Claus Gittinger <cg@exept.de>
parents: 2139
diff changeset
  1209
sha2-256: (chunk size 50)    125.48 Mb/s
52c5782a14b9 #DOCUMENTATION by cg
Claus Gittinger <cg@exept.de>
parents: 2139
diff changeset
  1210
sha2-256: (chunk size 1000)  185.18 Mb/s
52c5782a14b9 #DOCUMENTATION by cg
Claus Gittinger <cg@exept.de>
parents: 2139
diff changeset
  1211
sha2-256: (chunk size 50000) 188.10 Mb/s
52c5782a14b9 #DOCUMENTATION by cg
Claus Gittinger <cg@exept.de>
parents: 2139
diff changeset
  1212
-----------------------
52c5782a14b9 #DOCUMENTATION by cg
Claus Gittinger <cg@exept.de>
parents: 2139
diff changeset
  1213
sha2-512: (chunk size 10)     65.77 Mb/s
52c5782a14b9 #DOCUMENTATION by cg
Claus Gittinger <cg@exept.de>
parents: 2139
diff changeset
  1214
sha2-512: (chunk size 50)    140.25 Mb/s
52c5782a14b9 #DOCUMENTATION by cg
Claus Gittinger <cg@exept.de>
parents: 2139
diff changeset
  1215
sha2-512: (chunk size 1000)  207.32 Mb/s
52c5782a14b9 #DOCUMENTATION by cg
Claus Gittinger <cg@exept.de>
parents: 2139
diff changeset
  1216
sha2-512: (chunk size 50000) 222.82 Mb/s
52c5782a14b9 #DOCUMENTATION by cg
Claus Gittinger <cg@exept.de>
parents: 2139
diff changeset
  1217
-----------------------
52c5782a14b9 #DOCUMENTATION by cg
Claus Gittinger <cg@exept.de>
parents: 2139
diff changeset
  1218
sha3-256: (chunk size 10)     42.39 Mb/s
52c5782a14b9 #DOCUMENTATION by cg
Claus Gittinger <cg@exept.de>
parents: 2139
diff changeset
  1219
sha3-256: (chunk size 50)     69.61 Mb/s
52c5782a14b9 #DOCUMENTATION by cg
Claus Gittinger <cg@exept.de>
parents: 2139
diff changeset
  1220
sha3-256: (chunk size 1000)   78.17 Mb/s
52c5782a14b9 #DOCUMENTATION by cg
Claus Gittinger <cg@exept.de>
parents: 2139
diff changeset
  1221
sha3-256: (chunk size 50000)  83.29 Mb/s
52c5782a14b9 #DOCUMENTATION by cg
Claus Gittinger <cg@exept.de>
parents: 2139
diff changeset
  1222
-----------------------
52c5782a14b9 #DOCUMENTATION by cg
Claus Gittinger <cg@exept.de>
parents: 2139
diff changeset
  1223
sha3-512: (chunk size 10)     28.47 Mb/s
52c5782a14b9 #DOCUMENTATION by cg
Claus Gittinger <cg@exept.de>
parents: 2139
diff changeset
  1224
sha3-512: (chunk size 50)     39.74 Mb/s
52c5782a14b9 #DOCUMENTATION by cg
Claus Gittinger <cg@exept.de>
parents: 2139
diff changeset
  1225
sha3-512: (chunk size 1000)   44.88 Mb/s
52c5782a14b9 #DOCUMENTATION by cg
Claus Gittinger <cg@exept.de>
parents: 2139
diff changeset
  1226
sha3-512: (chunk size 50000)  45.31 Mb/s
52c5782a14b9 #DOCUMENTATION by cg
Claus Gittinger <cg@exept.de>
parents: 2139
diff changeset
  1227
    
52c5782a14b9 #DOCUMENTATION by cg
Claus Gittinger <cg@exept.de>
parents: 2139
diff changeset
  1228
    "
2135
e15ffe219b3f #QUALITY by cg
Claus Gittinger <cg@exept.de>
parents: 2122
diff changeset
  1229
e15ffe219b3f #QUALITY by cg
Claus Gittinger <cg@exept.de>
parents: 2122
diff changeset
  1230
    "Created: / 23-03-2019 / 14:47:01 / Claus Gittinger"
2140
52c5782a14b9 #DOCUMENTATION by cg
Claus Gittinger <cg@exept.de>
parents: 2139
diff changeset
  1231
    "Modified (comment): / 23-03-2019 / 23:05:24 / Claus Gittinger"
805
93f37c5c8c6b *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1232
! !
93f37c5c8c6b *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1233
93f37c5c8c6b *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1234
!CryptTests class methodsFor:'documentation'!
93f37c5c8c6b *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1235
93f37c5c8c6b *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1236
version
93f37c5c8c6b *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1237
    ^ '$Header$'
93f37c5c8c6b *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1238
!
93f37c5c8c6b *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1239
93f37c5c8c6b *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1240
version_CVS
93f37c5c8c6b *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1241
    ^ '$Header$'
93f37c5c8c6b *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1242
! !
93f37c5c8c6b *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1243
1100
1991bf9454ab Load exept:libcrypt if not already loaded.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 1038
diff changeset
  1244
1991bf9454ab Load exept:libcrypt if not already loaded.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 1038
diff changeset
  1245
CryptTests initialize!