RegressionTests__CryptTests.st
author sr
Wed, 15 Nov 2017 16:41:47 +0100
changeset 1890 9367c7639c2d
parent 1690 899889bd8404
child 2045 4495922b72e8
permissions -rw-r--r--
removed not existing Class from project definition
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
1447
2351db93aa5b package changes
Claus Gittinger <cg@exept.de>
parents: 1403
diff changeset
     1
"{ Package: 'stx:goodies/regression' }"
805
93f37c5c8c6b *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
     2
93f37c5c8c6b *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
     3
"{ NameSpace: RegressionTests }"
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
TestCase subclass:#CryptTests
1036
c42c54df984e class: RegressionTests::CryptTests
Claus Gittinger <cg@exept.de>
parents: 1035
diff changeset
     6
	instanceVariableNames:''
1100
1991bf9454ab Load exept:libcrypt if not already loaded.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 1038
diff changeset
     7
	classVariableNames:'LibCryptLoaded'
1036
c42c54df984e class: RegressionTests::CryptTests
Claus Gittinger <cg@exept.de>
parents: 1035
diff changeset
     8
	poolDictionaries:''
c42c54df984e class: RegressionTests::CryptTests
Claus Gittinger <cg@exept.de>
parents: 1035
diff changeset
     9
	category:'tests-Regression'
805
93f37c5c8c6b *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    10
!
93f37c5c8c6b *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    11
93f37c5c8c6b *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    12
!CryptTests class methodsFor:'documentation'!
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
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 to be added.
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
    [author:]
1447
2351db93aa5b package changes
Claus Gittinger <cg@exept.de>
parents: 1403
diff changeset
    19
	exept
805
93f37c5c8c6b *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    20
93f37c5c8c6b *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    21
    [instance variables:]
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
    [class 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
    [see also:]
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
"
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
1100
1991bf9454ab Load exept:libcrypt if not already loaded.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 1038
diff changeset
    30
!CryptTests class methodsFor:'initialization'!
1991bf9454ab Load exept:libcrypt if not already loaded.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 1038
diff changeset
    31
1991bf9454ab Load exept:libcrypt if not already loaded.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 1038
diff changeset
    32
initialize
1991bf9454ab Load exept:libcrypt if not already loaded.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 1038
diff changeset
    33
    "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
    34
1991bf9454ab Load exept:libcrypt if not already loaded.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 1038
diff changeset
    35
    "/ please change as required (and remove this comment)
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>"
1991bf9454ab Load exept:libcrypt if not already loaded.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 1038
diff changeset
    40
! !
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
!CryptTests class methodsFor:'utilities'!
1991bf9454ab Load exept:libcrypt if not already loaded.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 1038
diff changeset
    43
1991bf9454ab Load exept:libcrypt if not already loaded.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 1038
diff changeset
    44
loadLibcryptIfAvailable
1991bf9454ab Load exept:libcrypt if not already loaded.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 1038
diff changeset
    45
    "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
    46
1447
2351db93aa5b package changes
Claus Gittinger <cg@exept.de>
parents: 1403
diff changeset
    47
    LibCryptLoaded ifFalse:[
2351db93aa5b package changes
Claus Gittinger <cg@exept.de>
parents: 1403
diff changeset
    48
	(Smalltalk at: #SHA384Stream) isNil ifTrue:[
2351db93aa5b package changes
Claus Gittinger <cg@exept.de>
parents: 1403
diff changeset
    49
	    [
2351db93aa5b package changes
Claus Gittinger <cg@exept.de>
parents: 1403
diff changeset
    50
		Smalltalk loadPackage: #'exept:libcrypt'
2351db93aa5b package changes
Claus Gittinger <cg@exept.de>
parents: 1403
diff changeset
    51
	    ] on: PackageLoadError do:[:ex |
2351db93aa5b package changes
Claus Gittinger <cg@exept.de>
parents: 1403
diff changeset
    52
		"/Libcrypt not not available.
2351db93aa5b package changes
Claus Gittinger <cg@exept.de>
parents: 1403
diff changeset
    53
	    ].
2351db93aa5b package changes
Claus Gittinger <cg@exept.de>
parents: 1403
diff changeset
    54
	].
2351db93aa5b package changes
Claus Gittinger <cg@exept.de>
parents: 1403
diff changeset
    55
	LibCryptLoaded := true.
1100
1991bf9454ab Load exept:libcrypt if not already loaded.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 1038
diff changeset
    56
    ].
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
    "Created: / 03-03-2014 / 12:03:54 / Jan Vrany <jan.vrany@fit.cvut.cz>"
1991bf9454ab Load exept:libcrypt if not already loaded.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 1038
diff changeset
    59
! !
1991bf9454ab Load exept:libcrypt if not already loaded.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 1038
diff changeset
    60
805
93f37c5c8c6b *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    61
!CryptTests methodsFor:'initialize / release'!
93f37c5c8c6b *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    62
93f37c5c8c6b *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    63
setUp
93f37c5c8c6b *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    64
    "common setup - invoked before testing."
93f37c5c8c6b *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    65
1100
1991bf9454ab Load exept:libcrypt if not already loaded.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 1038
diff changeset
    66
    self class loadLibcryptIfAvailable.
1991bf9454ab Load exept:libcrypt if not already loaded.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 1038
diff changeset
    67
1991bf9454ab Load exept:libcrypt if not already loaded.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 1038
diff changeset
    68
    "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
    69
!
93f37c5c8c6b *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    70
93f37c5c8c6b *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    71
tearDown
93f37c5c8c6b *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    72
    "common cleanup - invoked after testing."
93f37c5c8c6b *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    73
93f37c5c8c6b *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    74
    super tearDown
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
93f37c5c8c6b *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    77
!CryptTests methodsFor:'tests'!
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
test01_crc32
93f37c5c8c6b *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    80
    |h|
93f37c5c8c6b *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    81
93f37c5c8c6b *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    82
    h := CRC32Stream hashValueOf:''.
93f37c5c8c6b *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    83
    self assert:(h = 0).
93f37c5c8c6b *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    84
93f37c5c8c6b *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    85
    h := CRC32Stream hashValueOf:'The quick brown fox jumps over the lazy dog'.
93f37c5c8c6b *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    86
    self assert:(h = 16r414fa339).
93f37c5c8c6b *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    87
93f37c5c8c6b *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    88
    h := CRC32Stream hashValueOf:'resume'.
93f37c5c8c6b *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    89
    self assert:(h = 16r60C1D0A0).
93f37c5c8c6b *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    90
93f37c5c8c6b *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    91
    h := (CRC32Stream new
1447
2351db93aa5b package changes
Claus Gittinger <cg@exept.de>
parents: 1403
diff changeset
    92
		    nextPut:$r;
2351db93aa5b package changes
Claus Gittinger <cg@exept.de>
parents: 1403
diff changeset
    93
		    nextPut:$e;
2351db93aa5b package changes
Claus Gittinger <cg@exept.de>
parents: 1403
diff changeset
    94
		    nextPut:$s;
2351db93aa5b package changes
Claus Gittinger <cg@exept.de>
parents: 1403
diff changeset
    95
		    nextPut:$u;
2351db93aa5b package changes
Claus Gittinger <cg@exept.de>
parents: 1403
diff changeset
    96
		    nextPut:$m;
2351db93aa5b package changes
Claus Gittinger <cg@exept.de>
parents: 1403
diff changeset
    97
		    nextPut:$e;
2351db93aa5b package changes
Claus Gittinger <cg@exept.de>
parents: 1403
diff changeset
    98
		    hashValue).
805
93f37c5c8c6b *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    99
    self assert:(h = 16r60C1D0A0).
93f37c5c8c6b *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   100
93f37c5c8c6b *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   101
    h := (CRC32Stream hashValueOf:#[1 2 3 4 5 6 7]).
93f37c5c8c6b *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   102
    self assert:(h = 16r70E46888).
93f37c5c8c6b *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   103
1447
2351db93aa5b package changes
Claus Gittinger <cg@exept.de>
parents: 1403
diff changeset
   104
    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
   105
	     16rFF 16rFF 16rFF 16rFF 16rFF 16rFF 16rFF 16rFF 16rFF 16rFF
2351db93aa5b package changes
Claus Gittinger <cg@exept.de>
parents: 1403
diff changeset
   106
	     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]).
805
93f37c5c8c6b *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   108
    self assert:(h = 16r8CD04C73).
93f37c5c8c6b *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   109
93f37c5c8c6b *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   110
    h := (CRC32Stream new
1447
2351db93aa5b package changes
Claus Gittinger <cg@exept.de>
parents: 1403
diff changeset
   111
		    next:100000 putAll:'12345678901234567890123456789012345678901234567890';
2351db93aa5b package changes
Claus Gittinger <cg@exept.de>
parents: 1403
diff changeset
   112
		    hashValue).
805
93f37c5c8c6b *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   113
    self assert:(h = 16r86D7D79A).
93f37c5c8c6b *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   114
93f37c5c8c6b *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   115
    "
93f37c5c8c6b *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   116
     self run:#test01_crc32
93f37c5c8c6b *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   117
     self new test01_crc32
93f37c5c8c6b *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   118
    "
93f37c5c8c6b *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   119
!
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
test02_md5
93f37c5c8c6b *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   122
    |h|
93f37c5c8c6b *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   123
93f37c5c8c6b *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   124
    h := MD5Stream hashValueOf:''.
93f37c5c8c6b *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   125
    self assert:(h = (ByteArray fromHexString:'d41d8cd98f00b204e9800998ecf8427e')).
93f37c5c8c6b *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   126
93f37c5c8c6b *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   127
    h := MD5Stream hashValueOf:'The quick brown fox jumps over the lazy dog'.
93f37c5c8c6b *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   128
    self assert:(h = (ByteArray fromHexString:'9e107d9d372bb6826bd81d3542a419d6')).
93f37c5c8c6b *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   129
93f37c5c8c6b *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   130
    h := MD5Stream hashValueOf:'abc'.
1447
2351db93aa5b package changes
Claus Gittinger <cg@exept.de>
parents: 1403
diff changeset
   131
    self assert:(h = #[16r90 16r01 16r50 16r98 16r3C 16rD2 16r4F 16rB0
2351db93aa5b package changes
Claus Gittinger <cg@exept.de>
parents: 1403
diff changeset
   132
		       16rD6 16r96 16r3F 16r7D 16r28 16rE1 16r7F 16r72]).
805
93f37c5c8c6b *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   133
93f37c5c8c6b *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   134
    h := MD5Stream hashValueOf:'abcdbcdecdefdefgefghfghighijhijkijkljklmklmnlmnomnopnopq'.
1447
2351db93aa5b package changes
Claus Gittinger <cg@exept.de>
parents: 1403
diff changeset
   135
    self assert:(h = #[16r82 16r15 16rEF 16r07 16r96 16rA2 16r0B 16rCA
2351db93aa5b package changes
Claus Gittinger <cg@exept.de>
parents: 1403
diff changeset
   136
		       16rAA 16rE1 16r16 16rD3 16r87 16r6C 16r66 16r4A]).
805
93f37c5c8c6b *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   137
93f37c5c8c6b *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   138
    h := (MD5Stream new
1447
2351db93aa5b package changes
Claus Gittinger <cg@exept.de>
parents: 1403
diff changeset
   139
		next:1000000 put:$a;
2351db93aa5b package changes
Claus Gittinger <cg@exept.de>
parents: 1403
diff changeset
   140
		hashValue).
2351db93aa5b package changes
Claus Gittinger <cg@exept.de>
parents: 1403
diff changeset
   141
    self assert:(h = #[16r77 16r07 16rD6 16rAE 16r4E 16r02 16r7C 16r70
2351db93aa5b package changes
Claus Gittinger <cg@exept.de>
parents: 1403
diff changeset
   142
		       16rEE 16rA2 16rA9 16r35 16rC2 16r29 16r6F 16r21]).
805
93f37c5c8c6b *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   143
93f37c5c8c6b *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   144
    "
93f37c5c8c6b *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   145
     self run:#test02_md5
93f37c5c8c6b *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   146
     self new test02_md5
93f37c5c8c6b *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   147
    "
93f37c5c8c6b *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   148
!
93f37c5c8c6b *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   149
93f37c5c8c6b *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   150
test03_sha1
93f37c5c8c6b *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   151
    |h|
93f37c5c8c6b *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   152
93f37c5c8c6b *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   153
    h := SHA1Stream hashValueOf:''.
93f37c5c8c6b *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   154
    self assert:(h = (ByteArray fromHexString:'da39a3ee5e6b4b0d3255bfef95601890afd80709')).
93f37c5c8c6b *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   155
93f37c5c8c6b *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   156
    h := SHA1Stream hashValueOf:'The quick brown fox jumps over the lazy dog'.
93f37c5c8c6b *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   157
    self assert:(h = (ByteArray fromHexString:'2fd4e1c67a2d28fced849ee1bb76e7391b93eb12')).
93f37c5c8c6b *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   158
1022
abdf6a161bc3 class: RegressionTests::CryptTests
Claus Gittinger <cg@exept.de>
parents: 1020
diff changeset
   159
    h := SHA1Stream hashValueOf:#[16r00 16r01 16r02 16r40 16r08 16r10 16r20 16r40 16r80
1447
2351db93aa5b package changes
Claus Gittinger <cg@exept.de>
parents: 1403
diff changeset
   160
				  16rFF 16rFE 16rFC 16rF8 16rF0 16rE0 16rC0 16r80].
1022
abdf6a161bc3 class: RegressionTests::CryptTests
Claus Gittinger <cg@exept.de>
parents: 1020
diff changeset
   161
    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
   162
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
     self run:#test03_sha1
93f37c5c8c6b *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   165
     self new test03_sha1
93f37c5c8c6b *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   166
    "
1022
abdf6a161bc3 class: RegressionTests::CryptTests
Claus Gittinger <cg@exept.de>
parents: 1020
diff changeset
   167
abdf6a161bc3 class: RegressionTests::CryptTests
Claus Gittinger <cg@exept.de>
parents: 1020
diff changeset
   168
    "Modified: / 25-11-2013 / 11:42:46 / cg"
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
1038
5443ea4b780e class: RegressionTests::CryptTests
Claus Gittinger <cg@exept.de>
parents: 1036
diff changeset
   171
test03b_sha1
5443ea4b780e class: RegressionTests::CryptTests
Claus Gittinger <cg@exept.de>
parents: 1036
diff changeset
   172
    |h|
5443ea4b780e class: RegressionTests::CryptTests
Claus Gittinger <cg@exept.de>
parents: 1036
diff changeset
   173
5443ea4b780e class: RegressionTests::CryptTests
Claus Gittinger <cg@exept.de>
parents: 1036
diff changeset
   174
    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].
5443ea4b780e class: RegressionTests::CryptTests
Claus Gittinger <cg@exept.de>
parents: 1036
diff changeset
   175
    self assert:(h = #[152 185 22 239 129 56 192 23 215 67 254 147 139 91 251 28 96 142 185 186]).
5443ea4b780e class: RegressionTests::CryptTests
Claus Gittinger <cg@exept.de>
parents: 1036
diff changeset
   176
5443ea4b780e class: RegressionTests::CryptTests
Claus Gittinger <cg@exept.de>
parents: 1036
diff changeset
   177
    "
5443ea4b780e class: RegressionTests::CryptTests
Claus Gittinger <cg@exept.de>
parents: 1036
diff changeset
   178
     self run:#test03b_sha1
5443ea4b780e class: RegressionTests::CryptTests
Claus Gittinger <cg@exept.de>
parents: 1036
diff changeset
   179
     self new test03b_sha1
5443ea4b780e class: RegressionTests::CryptTests
Claus Gittinger <cg@exept.de>
parents: 1036
diff changeset
   180
    "
5443ea4b780e class: RegressionTests::CryptTests
Claus Gittinger <cg@exept.de>
parents: 1036
diff changeset
   181
5443ea4b780e class: RegressionTests::CryptTests
Claus Gittinger <cg@exept.de>
parents: 1036
diff changeset
   182
    "Created: / 24-01-2014 / 17:47:22 / cg"
5443ea4b780e class: RegressionTests::CryptTests
Claus Gittinger <cg@exept.de>
parents: 1036
diff changeset
   183
!
5443ea4b780e class: RegressionTests::CryptTests
Claus Gittinger <cg@exept.de>
parents: 1036
diff changeset
   184
805
93f37c5c8c6b *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   185
test04_md2
93f37c5c8c6b *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   186
    |h|
93f37c5c8c6b *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   187
1447
2351db93aa5b package changes
Claus Gittinger <cg@exept.de>
parents: 1403
diff changeset
   188
    self
2351db93aa5b package changes
Claus Gittinger <cg@exept.de>
parents: 1403
diff changeset
   189
	skipIf:(MD2Stream isBehavior not or:[MD2Stream isLoaded not])
2351db93aa5b package changes
Claus Gittinger <cg@exept.de>
parents: 1403
diff changeset
   190
	description:'MD2Stream/libcrypt is not loaded'.
951
d9fe0a97fc74 class: RegressionTests::CryptTests
Stefan Vogel <sv@exept.de>
parents: 936
diff changeset
   191
805
93f37c5c8c6b *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   192
    h := MD2Stream hashValueOf:''.
93f37c5c8c6b *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   193
    self assert:(h = (ByteArray fromHexString:'8350e5a3e24c153df2275c9f80692773')).
93f37c5c8c6b *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   194
93f37c5c8c6b *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   195
    h := MD2Stream hashValueOf:'The quick brown fox jumps over the lazy dog'.
93f37c5c8c6b *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   196
    self assert:(h = (ByteArray fromHexString:'03d85a0d629d2c442e987525319fc471')).
93f37c5c8c6b *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   197
93f37c5c8c6b *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   198
    "
93f37c5c8c6b *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   199
     self run:#test04_md2
93f37c5c8c6b *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   200
     self new test04_md2
93f37c5c8c6b *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   201
    "
93f37c5c8c6b *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   202
!
93f37c5c8c6b *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   203
93f37c5c8c6b *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   204
test05_md4
93f37c5c8c6b *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   205
    |h|
93f37c5c8c6b *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   206
1447
2351db93aa5b package changes
Claus Gittinger <cg@exept.de>
parents: 1403
diff changeset
   207
    self
2351db93aa5b package changes
Claus Gittinger <cg@exept.de>
parents: 1403
diff changeset
   208
	skipIf:(MD4Stream isBehavior not or:[MD4Stream isLoaded not])
2351db93aa5b package changes
Claus Gittinger <cg@exept.de>
parents: 1403
diff changeset
   209
	description:'MD4Stream/libcrypt is not loaded'.
951
d9fe0a97fc74 class: RegressionTests::CryptTests
Stefan Vogel <sv@exept.de>
parents: 936
diff changeset
   210
805
93f37c5c8c6b *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   211
    h := MD4Stream hashValueOf:''.
93f37c5c8c6b *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   212
    self assert:(h = (ByteArray fromHexString:'31d6cfe0d16ae931b73c59d7e0c089c0')).
93f37c5c8c6b *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   213
93f37c5c8c6b *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   214
    h := MD4Stream hashValueOf:'The quick brown fox jumps over the lazy dog'.
93f37c5c8c6b *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   215
    self assert:(h = (ByteArray fromHexString:'1bee69a46ba811185c194762abaeae90')).
93f37c5c8c6b *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   216
93f37c5c8c6b *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   217
    "
93f37c5c8c6b *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   218
     self run:#test05_md4
93f37c5c8c6b *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   219
     self new test05_md4
93f37c5c8c6b *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   220
    "
93f37c5c8c6b *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   221
!
93f37c5c8c6b *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   222
93f37c5c8c6b *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   223
test06_sha256
93f37c5c8c6b *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   224
    |h|
93f37c5c8c6b *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   225
1447
2351db93aa5b package changes
Claus Gittinger <cg@exept.de>
parents: 1403
diff changeset
   226
    self
2351db93aa5b package changes
Claus Gittinger <cg@exept.de>
parents: 1403
diff changeset
   227
	skipIf:(SHA256Stream isBehavior not or:[SHA256Stream isLoaded not])
2351db93aa5b package changes
Claus Gittinger <cg@exept.de>
parents: 1403
diff changeset
   228
	description:'SHA256Stream/libcrypt is not loaded'.
951
d9fe0a97fc74 class: RegressionTests::CryptTests
Stefan Vogel <sv@exept.de>
parents: 936
diff changeset
   229
805
93f37c5c8c6b *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   230
    h := SHA256Stream hashValueOf:''.
93f37c5c8c6b *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   231
    self assert:(h = (ByteArray fromHexString:'e3b0c44298fc1c149afbf4c8996fb92427ae41e4649b934ca495991b7852b855')).
93f37c5c8c6b *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   232
93f37c5c8c6b *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   233
    h := SHA256Stream hashValueOf:'The quick brown fox jumps over the lazy dog'.
93f37c5c8c6b *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   234
    self assert:(h = (ByteArray fromHexString:'d7a8fbb307d7809469ca9abcb0082e4f8d5651e46d3cdb762d02d0bf37c9e592')).
93f37c5c8c6b *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   235
93f37c5c8c6b *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   236
    "
93f37c5c8c6b *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   237
     self run:#test06_sha256
93f37c5c8c6b *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   238
     self new test06_sha256
93f37c5c8c6b *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   239
    "
93f37c5c8c6b *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   240
!
93f37c5c8c6b *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   241
93f37c5c8c6b *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   242
test07_sha224
93f37c5c8c6b *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   243
    |h|
93f37c5c8c6b *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   244
1447
2351db93aa5b package changes
Claus Gittinger <cg@exept.de>
parents: 1403
diff changeset
   245
    self
2351db93aa5b package changes
Claus Gittinger <cg@exept.de>
parents: 1403
diff changeset
   246
	skipIf:(SHA224Stream isBehavior not or:[SHA224Stream isLoaded not])
2351db93aa5b package changes
Claus Gittinger <cg@exept.de>
parents: 1403
diff changeset
   247
	description:'SHA224Stream/libcrypt is not loaded'.
951
d9fe0a97fc74 class: RegressionTests::CryptTests
Stefan Vogel <sv@exept.de>
parents: 936
diff changeset
   248
805
93f37c5c8c6b *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   249
    h := SHA224Stream hashValueOf:''.
93f37c5c8c6b *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   250
    self assert:(h = (ByteArray fromHexString:'d14a028c2a3a2bc9476102bb288234c415a2b01f828ea62ac5b3e42f')).
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
    h := SHA224Stream hashValueOf:'The quick brown fox jumps over the lazy dog'.
93f37c5c8c6b *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   253
    self assert:(h = (ByteArray fromHexString:'730e109bd7a8a32b1cb9d9a09aa2325d2430587ddbc0c38bad911525')).
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
     self run:#test07_sha224
93f37c5c8c6b *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   257
     self new test07_sha224
93f37c5c8c6b *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   258
    "
93f37c5c8c6b *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   259
!
93f37c5c8c6b *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   260
93f37c5c8c6b *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   261
test08_sha384
93f37c5c8c6b *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   262
    |h|
93f37c5c8c6b *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   263
1447
2351db93aa5b package changes
Claus Gittinger <cg@exept.de>
parents: 1403
diff changeset
   264
    self
2351db93aa5b package changes
Claus Gittinger <cg@exept.de>
parents: 1403
diff changeset
   265
	skipIf:(SHA384Stream isBehavior not or:[SHA384Stream isLoaded not])
2351db93aa5b package changes
Claus Gittinger <cg@exept.de>
parents: 1403
diff changeset
   266
	description:'SHA384Stream/libcrypt is not loaded'.
951
d9fe0a97fc74 class: RegressionTests::CryptTests
Stefan Vogel <sv@exept.de>
parents: 936
diff changeset
   267
805
93f37c5c8c6b *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   268
    h := SHA384Stream hashValueOf:''.
93f37c5c8c6b *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   269
    self assert:(h = (ByteArray fromHexString:'38b060a751ac96384cd9327eb1b1e36a21fdb71114be07434c0cc7bf63f6e1da274edebfe76f65fbd51ad2f14898b95b')).
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
    h := SHA384Stream hashValueOf:'The quick brown fox jumps over the lazy dog'.
93f37c5c8c6b *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   272
    self assert:(h = (ByteArray fromHexString:'ca737f1014a48f4c0b6dd43cb177b0afd9e5169367544c494011e3317dbf9a509cb1e5dc1e85a941bbee3d7f2afbc9b1')).
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
     self run:#test08_sha384
93f37c5c8c6b *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   276
     self new test08_sha384
93f37c5c8c6b *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   277
    "
93f37c5c8c6b *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   278
!
93f37c5c8c6b *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   279
93f37c5c8c6b *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   280
test09_sha512
93f37c5c8c6b *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   281
    |h|
93f37c5c8c6b *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   282
1447
2351db93aa5b package changes
Claus Gittinger <cg@exept.de>
parents: 1403
diff changeset
   283
    self
2351db93aa5b package changes
Claus Gittinger <cg@exept.de>
parents: 1403
diff changeset
   284
	skipIf:(SHA512Stream isBehavior not or:[SHA512Stream isLoaded not])
2351db93aa5b package changes
Claus Gittinger <cg@exept.de>
parents: 1403
diff changeset
   285
	description:'SHA512Stream/libcrypt is not loaded'.
951
d9fe0a97fc74 class: RegressionTests::CryptTests
Stefan Vogel <sv@exept.de>
parents: 936
diff changeset
   286
805
93f37c5c8c6b *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   287
    h := SHA512Stream hashValueOf:''.
93f37c5c8c6b *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   288
    self assert:(h = (ByteArray fromHexString:'cf83e1357eefb8bdf1542850d66d8007d620e4050b5715dc83f4a921d36ce9ce47d0d13c5d85f2b0ff8318d2877eec2f63b931bd47417a81a538327af927da3e')).
93f37c5c8c6b *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   289
93f37c5c8c6b *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   290
    h := SHA512Stream hashValueOf:'The quick brown fox jumps over the lazy dog'.
93f37c5c8c6b *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   291
    self assert:(h = (ByteArray fromHexString:'07e547d9586f6a73f73fbac0435ed76951218fb7d0c8d788a309d785436bbb642e93a252a954f23912547d1e8a3b5ed6e1bfd7097821233fa0538f3db854fee6')).
93f37c5c8c6b *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   292
93f37c5c8c6b *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   293
    "
93f37c5c8c6b *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   294
     self run:#test09_sha512
93f37c5c8c6b *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   295
     self new test09_sha512
93f37c5c8c6b *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   296
    "
1020
a1a9948420e1 class: RegressionTests::CryptTests
Claus Gittinger <cg@exept.de>
parents: 951
diff changeset
   297
!
a1a9948420e1 class: RegressionTests::CryptTests
Claus Gittinger <cg@exept.de>
parents: 951
diff changeset
   298
a1a9948420e1 class: RegressionTests::CryptTests
Claus Gittinger <cg@exept.de>
parents: 951
diff changeset
   299
test10_des
1447
2351db93aa5b package changes
Claus Gittinger <cg@exept.de>
parents: 1403
diff changeset
   300
    |des crypt s s2|
1020
a1a9948420e1 class: RegressionTests::CryptTests
Claus Gittinger <cg@exept.de>
parents: 951
diff changeset
   301
a1a9948420e1 class: RegressionTests::CryptTests
Claus Gittinger <cg@exept.de>
parents: 951
diff changeset
   302
    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
   303
    crypt := des encrypt:'12345678'.
a1a9948420e1 class: RegressionTests::CryptTests
Claus Gittinger <cg@exept.de>
parents: 951
diff changeset
   304
    self assert:(crypt = #[85 205 168 117 136 155 222 239]).
a1a9948420e1 class: RegressionTests::CryptTests
Claus Gittinger <cg@exept.de>
parents: 951
diff changeset
   305
a1a9948420e1 class: RegressionTests::CryptTests
Claus Gittinger <cg@exept.de>
parents: 951
diff changeset
   306
    "/ ------------------------------------------------
a1a9948420e1 class: RegressionTests::CryptTests
Claus Gittinger <cg@exept.de>
parents: 951
diff changeset
   307
a1a9948420e1 class: RegressionTests::CryptTests
Claus Gittinger <cg@exept.de>
parents: 951
diff changeset
   308
    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
   309
    s := '12345678'.
a1a9948420e1 class: RegressionTests::CryptTests
Claus Gittinger <cg@exept.de>
parents: 951
diff changeset
   310
    10 timesRepeat:[
1447
2351db93aa5b package changes
Claus Gittinger <cg@exept.de>
parents: 1403
diff changeset
   311
	s2 := ByteArray new:s size.
2351db93aa5b package changes
Claus Gittinger <cg@exept.de>
parents: 1403
diff changeset
   312
	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
   313
	s := s2.
1020
a1a9948420e1 class: RegressionTests::CryptTests
Claus Gittinger <cg@exept.de>
parents: 951
diff changeset
   314
    ].
a1a9948420e1 class: RegressionTests::CryptTests
Claus Gittinger <cg@exept.de>
parents: 951
diff changeset
   315
    self assert:(s = #[212 114 83 160 109 1 37 83]).
a1a9948420e1 class: RegressionTests::CryptTests
Claus Gittinger <cg@exept.de>
parents: 951
diff changeset
   316
1023
ddc17abfb668 class: RegressionTests::CryptTests
Claus Gittinger <cg@exept.de>
parents: 1022
diff changeset
   317
    "/ ------------------------------------------------
ddc17abfb668 class: RegressionTests::CryptTests
Claus Gittinger <cg@exept.de>
parents: 1022
diff changeset
   318
ddc17abfb668 class: RegressionTests::CryptTests
Claus Gittinger <cg@exept.de>
parents: 1022
diff changeset
   319
    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
   320
    crypt := des encrypt:'12345678'.
ddc17abfb668 class: RegressionTests::CryptTests
Claus Gittinger <cg@exept.de>
parents: 1022
diff changeset
   321
    self assert:(crypt = #[54 60 159 218 32 8 70 60]).
ddc17abfb668 class: RegressionTests::CryptTests
Claus Gittinger <cg@exept.de>
parents: 1022
diff changeset
   322
ddc17abfb668 class: RegressionTests::CryptTests
Claus Gittinger <cg@exept.de>
parents: 1022
diff changeset
   323
1020
a1a9948420e1 class: RegressionTests::CryptTests
Claus Gittinger <cg@exept.de>
parents: 951
diff changeset
   324
    "
a1a9948420e1 class: RegressionTests::CryptTests
Claus Gittinger <cg@exept.de>
parents: 951
diff changeset
   325
     self run:#test10_des
a1a9948420e1 class: RegressionTests::CryptTests
Claus Gittinger <cg@exept.de>
parents: 951
diff changeset
   326
     self new test10_des
a1a9948420e1 class: RegressionTests::CryptTests
Claus Gittinger <cg@exept.de>
parents: 951
diff changeset
   327
    "
1023
ddc17abfb668 class: RegressionTests::CryptTests
Claus Gittinger <cg@exept.de>
parents: 1022
diff changeset
   328
ddc17abfb668 class: RegressionTests::CryptTests
Claus Gittinger <cg@exept.de>
parents: 1022
diff changeset
   329
    "Modified: / 25-11-2013 / 11:45:34 / cg"
1035
2be1f5b478ca class: RegressionTests::CryptTests
Claus Gittinger <cg@exept.de>
parents: 1023
diff changeset
   330
!
2be1f5b478ca class: RegressionTests::CryptTests
Claus Gittinger <cg@exept.de>
parents: 1023
diff changeset
   331
2be1f5b478ca class: RegressionTests::CryptTests
Claus Gittinger <cg@exept.de>
parents: 1023
diff changeset
   332
test11_rsaKey
2be1f5b478ca class: RegressionTests::CryptTests
Claus Gittinger <cg@exept.de>
parents: 1023
diff changeset
   333
    |dir fn key ks plain cipher|
2be1f5b478ca class: RegressionTests::CryptTests
Claus Gittinger <cg@exept.de>
parents: 1023
diff changeset
   334
2be1f5b478ca class: RegressionTests::CryptTests
Claus Gittinger <cg@exept.de>
parents: 1023
diff changeset
   335
    dir := Smalltalk packageDirectoryForPackageId:'exept:expecco'.
2be1f5b478ca class: RegressionTests::CryptTests
Claus Gittinger <cg@exept.de>
parents: 1023
diff changeset
   336
    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
   337
    fn := dir asFilename construct:'license/expeccoKey.pem'.
2be1f5b478ca class: RegressionTests::CryptTests
Claus Gittinger <cg@exept.de>
parents: 1023
diff changeset
   338
    self skipIf:fn exists not description:'test key is not present'.
2be1f5b478ca class: RegressionTests::CryptTests
Claus Gittinger <cg@exept.de>
parents: 1023
diff changeset
   339
2be1f5b478ca class: RegressionTests::CryptTests
Claus Gittinger <cg@exept.de>
parents: 1023
diff changeset
   340
    key := RSASecretCryptKey fromPemStream:fn readStream.
2be1f5b478ca class: RegressionTests::CryptTests
Claus Gittinger <cg@exept.de>
parents: 1023
diff changeset
   341
2be1f5b478ca class: RegressionTests::CryptTests
Claus Gittinger <cg@exept.de>
parents: 1023
diff changeset
   342
    ks := RSACryptStream new.
2be1f5b478ca class: RegressionTests::CryptTests
Claus Gittinger <cg@exept.de>
parents: 1023
diff changeset
   343
    ks encryptWithSecretKey:true.
2be1f5b478ca class: RegressionTests::CryptTests
Claus Gittinger <cg@exept.de>
parents: 1023
diff changeset
   344
    ks key:key.
2be1f5b478ca class: RegressionTests::CryptTests
Claus Gittinger <cg@exept.de>
parents: 1023
diff changeset
   345
    ks stream:#[] writeStream.
2be1f5b478ca class: RegressionTests::CryptTests
Claus Gittinger <cg@exept.de>
parents: 1023
diff changeset
   346
2be1f5b478ca class: RegressionTests::CryptTests
Claus Gittinger <cg@exept.de>
parents: 1023
diff changeset
   347
    plain := '12345678901234567890'.
2be1f5b478ca class: RegressionTests::CryptTests
Claus Gittinger <cg@exept.de>
parents: 1023
diff changeset
   348
    ks encrypt:plain.
2be1f5b478ca class: RegressionTests::CryptTests
Claus Gittinger <cg@exept.de>
parents: 1023
diff changeset
   349
    cipher := ks stream contents.
2be1f5b478ca class: RegressionTests::CryptTests
Claus Gittinger <cg@exept.de>
parents: 1023
diff changeset
   350
2be1f5b478ca class: RegressionTests::CryptTests
Claus Gittinger <cg@exept.de>
parents: 1023
diff changeset
   351
    ks := RSACryptStream new.
2be1f5b478ca class: RegressionTests::CryptTests
Claus Gittinger <cg@exept.de>
parents: 1023
diff changeset
   352
    ks encryptWithSecretKey:true.
2be1f5b478ca class: RegressionTests::CryptTests
Claus Gittinger <cg@exept.de>
parents: 1023
diff changeset
   353
    ks key:key.
2be1f5b478ca class: RegressionTests::CryptTests
Claus Gittinger <cg@exept.de>
parents: 1023
diff changeset
   354
    ks stream:#[] writeStream.
2be1f5b478ca class: RegressionTests::CryptTests
Claus Gittinger <cg@exept.de>
parents: 1023
diff changeset
   355
2be1f5b478ca class: RegressionTests::CryptTests
Claus Gittinger <cg@exept.de>
parents: 1023
diff changeset
   356
    ks decrypt:cipher.
2be1f5b478ca class: RegressionTests::CryptTests
Claus Gittinger <cg@exept.de>
parents: 1023
diff changeset
   357
2be1f5b478ca class: RegressionTests::CryptTests
Claus Gittinger <cg@exept.de>
parents: 1023
diff changeset
   358
    self assert:(ks stream contents asString = plain).
2be1f5b478ca class: RegressionTests::CryptTests
Claus Gittinger <cg@exept.de>
parents: 1023
diff changeset
   359
1036
c42c54df984e class: RegressionTests::CryptTests
Claus Gittinger <cg@exept.de>
parents: 1035
diff changeset
   360
    "/ -------------------------------------------
c42c54df984e class: RegressionTests::CryptTests
Claus Gittinger <cg@exept.de>
parents: 1035
diff changeset
   361
c42c54df984e class: RegressionTests::CryptTests
Claus Gittinger <cg@exept.de>
parents: 1035
diff changeset
   362
    ks := RSACryptStream new.
c42c54df984e class: RegressionTests::CryptTests
Claus Gittinger <cg@exept.de>
parents: 1035
diff changeset
   363
    ks encryptWithSecretKey:true.
c42c54df984e class: RegressionTests::CryptTests
Claus Gittinger <cg@exept.de>
parents: 1035
diff changeset
   364
    ks key:key.
c42c54df984e class: RegressionTests::CryptTests
Claus Gittinger <cg@exept.de>
parents: 1035
diff changeset
   365
    ks stream:#[] writeStream.
c42c54df984e class: RegressionTests::CryptTests
Claus Gittinger <cg@exept.de>
parents: 1035
diff changeset
   366
c42c54df984e class: RegressionTests::CryptTests
Claus Gittinger <cg@exept.de>
parents: 1035
diff changeset
   367
    plain := #[16rFF 16r80 16r00].
c42c54df984e class: RegressionTests::CryptTests
Claus Gittinger <cg@exept.de>
parents: 1035
diff changeset
   368
    ks encrypt:plain.
c42c54df984e class: RegressionTests::CryptTests
Claus Gittinger <cg@exept.de>
parents: 1035
diff changeset
   369
    cipher := ks stream contents.
c42c54df984e class: RegressionTests::CryptTests
Claus Gittinger <cg@exept.de>
parents: 1035
diff changeset
   370
c42c54df984e class: RegressionTests::CryptTests
Claus Gittinger <cg@exept.de>
parents: 1035
diff changeset
   371
    ks := RSACryptStream new.
c42c54df984e class: RegressionTests::CryptTests
Claus Gittinger <cg@exept.de>
parents: 1035
diff changeset
   372
    ks encryptWithSecretKey:true.
c42c54df984e class: RegressionTests::CryptTests
Claus Gittinger <cg@exept.de>
parents: 1035
diff changeset
   373
    ks key:key.
c42c54df984e class: RegressionTests::CryptTests
Claus Gittinger <cg@exept.de>
parents: 1035
diff changeset
   374
    ks stream:#[] writeStream.
c42c54df984e class: RegressionTests::CryptTests
Claus Gittinger <cg@exept.de>
parents: 1035
diff changeset
   375
c42c54df984e class: RegressionTests::CryptTests
Claus Gittinger <cg@exept.de>
parents: 1035
diff changeset
   376
    ks decrypt:cipher.
c42c54df984e class: RegressionTests::CryptTests
Claus Gittinger <cg@exept.de>
parents: 1035
diff changeset
   377
c42c54df984e class: RegressionTests::CryptTests
Claus Gittinger <cg@exept.de>
parents: 1035
diff changeset
   378
    self assert:(ks stream contents = plain).
c42c54df984e class: RegressionTests::CryptTests
Claus Gittinger <cg@exept.de>
parents: 1035
diff changeset
   379
1035
2be1f5b478ca class: RegressionTests::CryptTests
Claus Gittinger <cg@exept.de>
parents: 1023
diff changeset
   380
    "
2be1f5b478ca class: RegressionTests::CryptTests
Claus Gittinger <cg@exept.de>
parents: 1023
diff changeset
   381
     self run:#test11_rsaKey
2be1f5b478ca class: RegressionTests::CryptTests
Claus Gittinger <cg@exept.de>
parents: 1023
diff changeset
   382
     self new test11_rsaKey
2be1f5b478ca class: RegressionTests::CryptTests
Claus Gittinger <cg@exept.de>
parents: 1023
diff changeset
   383
    "
2be1f5b478ca class: RegressionTests::CryptTests
Claus Gittinger <cg@exept.de>
parents: 1023
diff changeset
   384
2be1f5b478ca class: RegressionTests::CryptTests
Claus Gittinger <cg@exept.de>
parents: 1023
diff changeset
   385
    "Created: / 02-12-2013 / 12:58:19 / cg"
1511
1376ae5d577f #QUALITY by cg
Claus Gittinger <cg@exept.de>
parents: 1447
diff changeset
   386
!
1376ae5d577f #QUALITY by cg
Claus Gittinger <cg@exept.de>
parents: 1447
diff changeset
   387
1376ae5d577f #QUALITY by cg
Claus Gittinger <cg@exept.de>
parents: 1447
diff changeset
   388
test12_whirlpool
1376ae5d577f #QUALITY by cg
Claus Gittinger <cg@exept.de>
parents: 1447
diff changeset
   389
    |h|
1376ae5d577f #QUALITY by cg
Claus Gittinger <cg@exept.de>
parents: 1447
diff changeset
   390
1376ae5d577f #QUALITY by cg
Claus Gittinger <cg@exept.de>
parents: 1447
diff changeset
   391
    self
1376ae5d577f #QUALITY by cg
Claus Gittinger <cg@exept.de>
parents: 1447
diff changeset
   392
        skipIf:(WhirlpoolStream isBehavior not or:[WhirlpoolStream isLoaded not])
1376ae5d577f #QUALITY by cg
Claus Gittinger <cg@exept.de>
parents: 1447
diff changeset
   393
        description:'WhirlpoolStream/libcrypt is not loaded'.
1376ae5d577f #QUALITY by cg
Claus Gittinger <cg@exept.de>
parents: 1447
diff changeset
   394
1376ae5d577f #QUALITY by cg
Claus Gittinger <cg@exept.de>
parents: 1447
diff changeset
   395
    "/ hashes taken from wikipedia-page on whirlpool
1376ae5d577f #QUALITY by cg
Claus Gittinger <cg@exept.de>
parents: 1447
diff changeset
   396
    
1376ae5d577f #QUALITY by cg
Claus Gittinger <cg@exept.de>
parents: 1447
diff changeset
   397
    h := WhirlpoolStream hashValueOf:''.
1376ae5d577f #QUALITY by cg
Claus Gittinger <cg@exept.de>
parents: 1447
diff changeset
   398
    self assert:(h = (ByteArray fromHexString:'19FA61D75522A4669B44E39C1D2E1726C530232130D407F89AFEE0964997F7A73E83BE698B288FEBCF88E3E03C4F0757EA8964E59B63D93708B138CC42A66EB3')).
1376ae5d577f #QUALITY by cg
Claus Gittinger <cg@exept.de>
parents: 1447
diff changeset
   399
1376ae5d577f #QUALITY by cg
Claus Gittinger <cg@exept.de>
parents: 1447
diff changeset
   400
    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
   401
    self assert:(h = (ByteArray fromHexString:'B97DE512E91E3828B40D2B0FDCE9CEB3C4A71F9BEA8D88E75C4FA854DF36725FD2B52EB6544EDCACD6F8BEDDFEA403CB55AE31F03AD62A5EF54E42EE82C3FB35')).
1376ae5d577f #QUALITY by cg
Claus Gittinger <cg@exept.de>
parents: 1447
diff changeset
   402
1512
4ce2945272dd #QUALITY by cg
Claus Gittinger <cg@exept.de>
parents: 1511
diff changeset
   403
    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
   404
    self assert:(h = (ByteArray fromHexString:'C27BA124205F72E6847F3E19834F925CC666D0974167AF915BB462420ED40CC50900D85A1F923219D832357750492D5C143011A76988344C2635E69D06F2D38C')).
4ce2945272dd #QUALITY by cg
Claus Gittinger <cg@exept.de>
parents: 1511
diff changeset
   405
1511
1376ae5d577f #QUALITY by cg
Claus Gittinger <cg@exept.de>
parents: 1447
diff changeset
   406
    "
1376ae5d577f #QUALITY by cg
Claus Gittinger <cg@exept.de>
parents: 1447
diff changeset
   407
     self run:#test12_whirlpool
1376ae5d577f #QUALITY by cg
Claus Gittinger <cg@exept.de>
parents: 1447
diff changeset
   408
     self new test12_whirlpool
1376ae5d577f #QUALITY by cg
Claus Gittinger <cg@exept.de>
parents: 1447
diff changeset
   409
    "
1649
f195a2d879cd #QUALITY by cg
Claus Gittinger <cg@exept.de>
parents: 1512
diff changeset
   410
!
f195a2d879cd #QUALITY by cg
Claus Gittinger <cg@exept.de>
parents: 1512
diff changeset
   411
f195a2d879cd #QUALITY by cg
Claus Gittinger <cg@exept.de>
parents: 1512
diff changeset
   412
test13_sha3
f195a2d879cd #QUALITY by cg
Claus Gittinger <cg@exept.de>
parents: 1512
diff changeset
   413
    |h|
f195a2d879cd #QUALITY by cg
Claus Gittinger <cg@exept.de>
parents: 1512
diff changeset
   414
f195a2d879cd #QUALITY by cg
Claus Gittinger <cg@exept.de>
parents: 1512
diff changeset
   415
    self
f195a2d879cd #QUALITY by cg
Claus Gittinger <cg@exept.de>
parents: 1512
diff changeset
   416
        skipIf:(SHA3_256Stream isBehavior not or:[SHA3_256Stream isLoaded not])
f195a2d879cd #QUALITY by cg
Claus Gittinger <cg@exept.de>
parents: 1512
diff changeset
   417
        description:'SHA3Stream/libcrypt is not loaded'.
f195a2d879cd #QUALITY by cg
Claus Gittinger <cg@exept.de>
parents: 1512
diff changeset
   418
f195a2d879cd #QUALITY by cg
Claus Gittinger <cg@exept.de>
parents: 1512
diff changeset
   419
    "/ hashes taken from wikipedia-page on SHA3
f195a2d879cd #QUALITY by cg
Claus Gittinger <cg@exept.de>
parents: 1512
diff changeset
   420
    
f195a2d879cd #QUALITY by cg
Claus Gittinger <cg@exept.de>
parents: 1512
diff changeset
   421
    h := SHA3_224Stream hashValueOf:''.
f195a2d879cd #QUALITY by cg
Claus Gittinger <cg@exept.de>
parents: 1512
diff changeset
   422
    self assert:(h = (ByteArray fromHexString:'6b4e03423667dbb73b6e15454f0eb1abd4597f9a1b078e3f5b5a6bc7')).
f195a2d879cd #QUALITY by cg
Claus Gittinger <cg@exept.de>
parents: 1512
diff changeset
   423
f195a2d879cd #QUALITY by cg
Claus Gittinger <cg@exept.de>
parents: 1512
diff changeset
   424
    h := SHA3_256Stream hashValueOf:''.
f195a2d879cd #QUALITY by cg
Claus Gittinger <cg@exept.de>
parents: 1512
diff changeset
   425
    self assert:(h = (ByteArray fromHexString:'a7ffc6f8bf1ed76651c14756a061d662f580ff4de43b49fa82d80a4b80f8434a')).
f195a2d879cd #QUALITY by cg
Claus Gittinger <cg@exept.de>
parents: 1512
diff changeset
   426
f195a2d879cd #QUALITY by cg
Claus Gittinger <cg@exept.de>
parents: 1512
diff changeset
   427
    h := SHA3_384Stream hashValueOf:''.
f195a2d879cd #QUALITY by cg
Claus Gittinger <cg@exept.de>
parents: 1512
diff changeset
   428
    self assert:(h = (ByteArray fromHexString:'0c63a75b845e4f7d01107d852e4c2485c51a50aaaa94fc61995e71bbee983a2ac3713831264adb47fb6bd1e058d5f004')).
f195a2d879cd #QUALITY by cg
Claus Gittinger <cg@exept.de>
parents: 1512
diff changeset
   429
f195a2d879cd #QUALITY by cg
Claus Gittinger <cg@exept.de>
parents: 1512
diff changeset
   430
    h := SHA3_512Stream hashValueOf:''.
f195a2d879cd #QUALITY by cg
Claus Gittinger <cg@exept.de>
parents: 1512
diff changeset
   431
    self assert:(h = (ByteArray fromHexString:'a69f73cca23a9ac5c8b567dc185a756e97c982164fe25859e0d1dcc1475c80a615b2123af1f5f94c11e3e9402c3ac558f500199d95b6d3e301758586281dcd26')).
f195a2d879cd #QUALITY by cg
Claus Gittinger <cg@exept.de>
parents: 1512
diff changeset
   432
f195a2d879cd #QUALITY by cg
Claus Gittinger <cg@exept.de>
parents: 1512
diff changeset
   433
f195a2d879cd #QUALITY by cg
Claus Gittinger <cg@exept.de>
parents: 1512
diff changeset
   434
    h := SHA3_Shake128_256Stream hashValueOf:''.
f195a2d879cd #QUALITY by cg
Claus Gittinger <cg@exept.de>
parents: 1512
diff changeset
   435
    self assert:(h = (ByteArray fromHexString:'7f9c2ba4e88f827d616045507605853ed73b8093f6efbc88eb1a6eacfa66ef26')).
f195a2d879cd #QUALITY by cg
Claus Gittinger <cg@exept.de>
parents: 1512
diff changeset
   436
f195a2d879cd #QUALITY by cg
Claus Gittinger <cg@exept.de>
parents: 1512
diff changeset
   437
    h := SHA3_Shake256_512Stream hashValueOf:''.
f195a2d879cd #QUALITY by cg
Claus Gittinger <cg@exept.de>
parents: 1512
diff changeset
   438
    self assert:(h = (ByteArray fromHexString:'46b9dd2b0ba88d13233b3feb743eeb243fcd52ea62b81b82b50c27646ed5762fd75dc4ddd8c0f200cb05019d67b592f6fc821c49479ab48640292eacb3b7c4be')).
f195a2d879cd #QUALITY by cg
Claus Gittinger <cg@exept.de>
parents: 1512
diff changeset
   439
f195a2d879cd #QUALITY by cg
Claus Gittinger <cg@exept.de>
parents: 1512
diff changeset
   440
    h := SHA3_Shake128_256Stream hashValueOf:'The quick brown fox jumps over the lazy dog'.
f195a2d879cd #QUALITY by cg
Claus Gittinger <cg@exept.de>
parents: 1512
diff changeset
   441
    self assert:(h = (ByteArray fromHexString:'f4202e3c5852f9182a0430fd8144f0a74b95e7417ecae17db0f8cfeed0e3e66e')).
f195a2d879cd #QUALITY by cg
Claus Gittinger <cg@exept.de>
parents: 1512
diff changeset
   442
f195a2d879cd #QUALITY by cg
Claus Gittinger <cg@exept.de>
parents: 1512
diff changeset
   443
    h := SHA3_Shake128_256Stream hashValueOf:'The quick brown fox jumps over the lazy dof'.
f195a2d879cd #QUALITY by cg
Claus Gittinger <cg@exept.de>
parents: 1512
diff changeset
   444
    self assert:(h = (ByteArray fromHexString:'853f4538be0db9621a6cea659a06c1107b1f83f02b13d18297bd39d7411cf10c')).
f195a2d879cd #QUALITY by cg
Claus Gittinger <cg@exept.de>
parents: 1512
diff changeset
   445
f195a2d879cd #QUALITY by cg
Claus Gittinger <cg@exept.de>
parents: 1512
diff changeset
   446
    "
f195a2d879cd #QUALITY by cg
Claus Gittinger <cg@exept.de>
parents: 1512
diff changeset
   447
     self run:#test13_sha3
f195a2d879cd #QUALITY by cg
Claus Gittinger <cg@exept.de>
parents: 1512
diff changeset
   448
     self new test13_sha3
f195a2d879cd #QUALITY by cg
Claus Gittinger <cg@exept.de>
parents: 1512
diff changeset
   449
    "
f195a2d879cd #QUALITY by cg
Claus Gittinger <cg@exept.de>
parents: 1512
diff changeset
   450
f195a2d879cd #QUALITY by cg
Claus Gittinger <cg@exept.de>
parents: 1512
diff changeset
   451
    "Created: / 27-07-2017 / 13:40:51 / cg"
1690
899889bd8404 #UI_ENHANCEMENT by cg
Claus Gittinger <cg@exept.de>
parents: 1649
diff changeset
   452
!
899889bd8404 #UI_ENHANCEMENT by cg
Claus Gittinger <cg@exept.de>
parents: 1649
diff changeset
   453
899889bd8404 #UI_ENHANCEMENT by cg
Claus Gittinger <cg@exept.de>
parents: 1649
diff changeset
   454
test14_aesRijndael
899889bd8404 #UI_ENHANCEMENT by cg
Claus Gittinger <cg@exept.de>
parents: 1649
diff changeset
   455
    |plaintext key crypted hx ecb cbc ofb ctr iv|
899889bd8404 #UI_ENHANCEMENT by cg
Claus Gittinger <cg@exept.de>
parents: 1649
diff changeset
   456
899889bd8404 #UI_ENHANCEMENT by cg
Claus Gittinger <cg@exept.de>
parents: 1649
diff changeset
   457
    "/ ECB-AES-256
899889bd8404 #UI_ENHANCEMENT by cg
Claus Gittinger <cg@exept.de>
parents: 1649
diff changeset
   458
899889bd8404 #UI_ENHANCEMENT by cg
Claus Gittinger <cg@exept.de>
parents: 1649
diff changeset
   459
    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
   460
                    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
   461
    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
   462
              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
   463
    ecb := RijndaelCipher new key:key mode:#ECB.
899889bd8404 #UI_ENHANCEMENT by cg
Claus Gittinger <cg@exept.de>
parents: 1649
diff changeset
   464
    crypted := ecb encrypt:plaintext.
899889bd8404 #UI_ENHANCEMENT by cg
Claus Gittinger <cg@exept.de>
parents: 1649
diff changeset
   465
    hx := crypted hexPrintString asLowercase.
899889bd8404 #UI_ENHANCEMENT by cg
Claus Gittinger <cg@exept.de>
parents: 1649
diff changeset
   466
    self assert:(hx = 'f2258e225d794572393a6484cfced7cf925d1aa18366bcd93c33d104294c8a6f').
899889bd8404 #UI_ENHANCEMENT by cg
Claus Gittinger <cg@exept.de>
parents: 1649
diff changeset
   467
899889bd8404 #UI_ENHANCEMENT by cg
Claus Gittinger <cg@exept.de>
parents: 1649
diff changeset
   468
    ecb := RijndaelCipher new key:key mode:#ECB.
899889bd8404 #UI_ENHANCEMENT by cg
Claus Gittinger <cg@exept.de>
parents: 1649
diff changeset
   469
    self assert:(ecb decrypt:crypted) = plaintext.
899889bd8404 #UI_ENHANCEMENT by cg
Claus Gittinger <cg@exept.de>
parents: 1649
diff changeset
   470
    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
   471
                    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
   472
    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
   473
              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
   474
    cbc := RijndaelCipher new key:key mode:#CBC.
899889bd8404 #UI_ENHANCEMENT by cg
Claus Gittinger <cg@exept.de>
parents: 1649
diff changeset
   475
    crypted := cbc encrypt:plaintext.
899889bd8404 #UI_ENHANCEMENT by cg
Claus Gittinger <cg@exept.de>
parents: 1649
diff changeset
   476
    hx := crypted hexPrintString asLowercase.
899889bd8404 #UI_ENHANCEMENT by cg
Claus Gittinger <cg@exept.de>
parents: 1649
diff changeset
   477
    self assert:(hx = 'f2258e225d794572393a6484cfced7cfb487a41f6b6286c00c9c8d80cb3ee9f8').
899889bd8404 #UI_ENHANCEMENT by cg
Claus Gittinger <cg@exept.de>
parents: 1649
diff changeset
   478
    cbc := RijndaelCipher new key:key mode:#CBC.
899889bd8404 #UI_ENHANCEMENT by cg
Claus Gittinger <cg@exept.de>
parents: 1649
diff changeset
   479
    self assert:(cbc decrypt:crypted) = plaintext.
899889bd8404 #UI_ENHANCEMENT by cg
Claus Gittinger <cg@exept.de>
parents: 1649
diff changeset
   480
     
899889bd8404 #UI_ENHANCEMENT by cg
Claus Gittinger <cg@exept.de>
parents: 1649
diff changeset
   481
    "/ ECB-AES-256
899889bd8404 #UI_ENHANCEMENT by cg
Claus Gittinger <cg@exept.de>
parents: 1649
diff changeset
   482
    
899889bd8404 #UI_ENHANCEMENT by cg
Claus Gittinger <cg@exept.de>
parents: 1649
diff changeset
   483
    plaintext := #[ 0 17 34 51 68 85 102 119
899889bd8404 #UI_ENHANCEMENT by cg
Claus Gittinger <cg@exept.de>
parents: 1649
diff changeset
   484
                    136 153 170 187 204 221 238 255 ] asString.
899889bd8404 #UI_ENHANCEMENT by cg
Claus Gittinger <cg@exept.de>
parents: 1649
diff changeset
   485
    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
   486
              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
   487
    ecb := RijndaelCipher new key:key mode:#ECB.
899889bd8404 #UI_ENHANCEMENT by cg
Claus Gittinger <cg@exept.de>
parents: 1649
diff changeset
   488
    crypted := ecb encrypt:plaintext.
899889bd8404 #UI_ENHANCEMENT by cg
Claus Gittinger <cg@exept.de>
parents: 1649
diff changeset
   489
    hx := crypted hexPrintString asLowercase.
899889bd8404 #UI_ENHANCEMENT by cg
Claus Gittinger <cg@exept.de>
parents: 1649
diff changeset
   490
    self assert:(hx = '8ea2b7ca516745bfeafc49904b496089').
899889bd8404 #UI_ENHANCEMENT by cg
Claus Gittinger <cg@exept.de>
parents: 1649
diff changeset
   491
    ecb := RijndaelCipher new key:key mode:#ECB.
899889bd8404 #UI_ENHANCEMENT by cg
Claus Gittinger <cg@exept.de>
parents: 1649
diff changeset
   492
    self assert:(ecb decrypt:crypted) asString = plaintext.
899889bd8404 #UI_ENHANCEMENT by cg
Claus Gittinger <cg@exept.de>
parents: 1649
diff changeset
   493
     
899889bd8404 #UI_ENHANCEMENT by cg
Claus Gittinger <cg@exept.de>
parents: 1649
diff changeset
   494
    "/ ECB-AES-192
899889bd8404 #UI_ENHANCEMENT by cg
Claus Gittinger <cg@exept.de>
parents: 1649
diff changeset
   495
    
899889bd8404 #UI_ENHANCEMENT by cg
Claus Gittinger <cg@exept.de>
parents: 1649
diff changeset
   496
    plaintext := #[ 0 17 34 51 68 85 102 119
899889bd8404 #UI_ENHANCEMENT by cg
Claus Gittinger <cg@exept.de>
parents: 1649
diff changeset
   497
                    136 153 170 187 204 221 238 255 ] asString.
899889bd8404 #UI_ENHANCEMENT by cg
Claus Gittinger <cg@exept.de>
parents: 1649
diff changeset
   498
    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
   499
              16 17 18 19 20 21 22 23 ] asString.
899889bd8404 #UI_ENHANCEMENT by cg
Claus Gittinger <cg@exept.de>
parents: 1649
diff changeset
   500
    ecb := RijndaelCipher new key:key mode:#ECB.
899889bd8404 #UI_ENHANCEMENT by cg
Claus Gittinger <cg@exept.de>
parents: 1649
diff changeset
   501
    crypted := ecb encrypt:plaintext.
899889bd8404 #UI_ENHANCEMENT by cg
Claus Gittinger <cg@exept.de>
parents: 1649
diff changeset
   502
    hx := crypted hexPrintString asLowercase.
899889bd8404 #UI_ENHANCEMENT by cg
Claus Gittinger <cg@exept.de>
parents: 1649
diff changeset
   503
    self assert:(hx = 'dda97ca4864cdfe06eaf70a0ec0d7191').
899889bd8404 #UI_ENHANCEMENT by cg
Claus Gittinger <cg@exept.de>
parents: 1649
diff changeset
   504
    ecb := RijndaelCipher new key:key mode:#ECB.
899889bd8404 #UI_ENHANCEMENT by cg
Claus Gittinger <cg@exept.de>
parents: 1649
diff changeset
   505
    self assert:(ecb decrypt:crypted) asString = plaintext.
899889bd8404 #UI_ENHANCEMENT by cg
Claus Gittinger <cg@exept.de>
parents: 1649
diff changeset
   506
     
899889bd8404 #UI_ENHANCEMENT by cg
Claus Gittinger <cg@exept.de>
parents: 1649
diff changeset
   507
    "/ ECB-AES-128
899889bd8404 #UI_ENHANCEMENT by cg
Claus Gittinger <cg@exept.de>
parents: 1649
diff changeset
   508
    
899889bd8404 #UI_ENHANCEMENT by cg
Claus Gittinger <cg@exept.de>
parents: 1649
diff changeset
   509
    plaintext := #[ 0 17 34 51 68 85 102 119
899889bd8404 #UI_ENHANCEMENT by cg
Claus Gittinger <cg@exept.de>
parents: 1649
diff changeset
   510
                    136 153 170 187 204 221 238 255 ] asString.
899889bd8404 #UI_ENHANCEMENT by cg
Claus Gittinger <cg@exept.de>
parents: 1649
diff changeset
   511
    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
   512
    ecb := RijndaelCipher new key:key mode:#ECB.
899889bd8404 #UI_ENHANCEMENT by cg
Claus Gittinger <cg@exept.de>
parents: 1649
diff changeset
   513
    crypted := ecb encrypt:plaintext.
899889bd8404 #UI_ENHANCEMENT by cg
Claus Gittinger <cg@exept.de>
parents: 1649
diff changeset
   514
    hx := crypted hexPrintString asLowercase.
899889bd8404 #UI_ENHANCEMENT by cg
Claus Gittinger <cg@exept.de>
parents: 1649
diff changeset
   515
    self assert:(hx = '69c4e0d86a7b0430d8cdb78070b4c55a').
899889bd8404 #UI_ENHANCEMENT by cg
Claus Gittinger <cg@exept.de>
parents: 1649
diff changeset
   516
    ecb := RijndaelCipher new key:key mode:#ECB.
899889bd8404 #UI_ENHANCEMENT by cg
Claus Gittinger <cg@exept.de>
parents: 1649
diff changeset
   517
    self assert:(ecb decrypt:crypted) asString = plaintext.
899889bd8404 #UI_ENHANCEMENT by cg
Claus Gittinger <cg@exept.de>
parents: 1649
diff changeset
   518
     
899889bd8404 #UI_ENHANCEMENT by cg
Claus Gittinger <cg@exept.de>
parents: 1649
diff changeset
   519
    "/ Modes of operation -- NIST paper tests
899889bd8404 #UI_ENHANCEMENT by cg
Claus Gittinger <cg@exept.de>
parents: 1649
diff changeset
   520
    "/ ECB-AES-128
899889bd8404 #UI_ENHANCEMENT by cg
Claus Gittinger <cg@exept.de>
parents: 1649
diff changeset
   521
    
899889bd8404 #UI_ENHANCEMENT by cg
Claus Gittinger <cg@exept.de>
parents: 1649
diff changeset
   522
    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
   523
    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
   524
    ecb := RijndaelCipher new key:key mode:#ECB.
899889bd8404 #UI_ENHANCEMENT by cg
Claus Gittinger <cg@exept.de>
parents: 1649
diff changeset
   525
    crypted := ecb encrypt:plaintext.
899889bd8404 #UI_ENHANCEMENT by cg
Claus Gittinger <cg@exept.de>
parents: 1649
diff changeset
   526
    hx := crypted hexPrintString asLowercase.
899889bd8404 #UI_ENHANCEMENT by cg
Claus Gittinger <cg@exept.de>
parents: 1649
diff changeset
   527
    self assert:(hx 
899889bd8404 #UI_ENHANCEMENT by cg
Claus Gittinger <cg@exept.de>
parents: 1649
diff changeset
   528
                = '3ad77bb40d7a3660a89ecaf32466ef97f5d3d58503b9699de785895a96fdbaaf43b1cd7f598ece23881b00e3ed0306887b0c785e27e8ad3f8223207104725dd4').
899889bd8404 #UI_ENHANCEMENT by cg
Claus Gittinger <cg@exept.de>
parents: 1649
diff changeset
   529
    ecb := RijndaelCipher new key:key mode:#ECB.
899889bd8404 #UI_ENHANCEMENT by cg
Claus Gittinger <cg@exept.de>
parents: 1649
diff changeset
   530
    self assert:(ecb decrypt:crypted) = plaintext.
899889bd8404 #UI_ENHANCEMENT by cg
Claus Gittinger <cg@exept.de>
parents: 1649
diff changeset
   531
     
899889bd8404 #UI_ENHANCEMENT by cg
Claus Gittinger <cg@exept.de>
parents: 1649
diff changeset
   532
    "/ ECB-AES-192
899889bd8404 #UI_ENHANCEMENT by cg
Claus Gittinger <cg@exept.de>
parents: 1649
diff changeset
   533
    
899889bd8404 #UI_ENHANCEMENT by cg
Claus Gittinger <cg@exept.de>
parents: 1649
diff changeset
   534
    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
   535
    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
   536
    ecb := RijndaelCipher new key:key mode:#ECB.
899889bd8404 #UI_ENHANCEMENT by cg
Claus Gittinger <cg@exept.de>
parents: 1649
diff changeset
   537
    crypted := ecb encrypt:plaintext.
899889bd8404 #UI_ENHANCEMENT by cg
Claus Gittinger <cg@exept.de>
parents: 1649
diff changeset
   538
    hx := crypted hexPrintString asLowercase.
899889bd8404 #UI_ENHANCEMENT by cg
Claus Gittinger <cg@exept.de>
parents: 1649
diff changeset
   539
    self assert:(hx 
899889bd8404 #UI_ENHANCEMENT by cg
Claus Gittinger <cg@exept.de>
parents: 1649
diff changeset
   540
                = 'bd334f1d6e45f25ff712a214571fa5cc974104846d0ad3ad7734ecb3ecee4eefef7afd2270e2e60adce0ba2face6444e9a4b41ba738d6c72fb16691603c18e0e').
899889bd8404 #UI_ENHANCEMENT by cg
Claus Gittinger <cg@exept.de>
parents: 1649
diff changeset
   541
    ecb := RijndaelCipher new key:key mode:#ECB.
899889bd8404 #UI_ENHANCEMENT by cg
Claus Gittinger <cg@exept.de>
parents: 1649
diff changeset
   542
    self assert:(ecb decrypt:crypted) = plaintext.
899889bd8404 #UI_ENHANCEMENT by cg
Claus Gittinger <cg@exept.de>
parents: 1649
diff changeset
   543
     
899889bd8404 #UI_ENHANCEMENT by cg
Claus Gittinger <cg@exept.de>
parents: 1649
diff changeset
   544
    "/ ECB-AES-256
899889bd8404 #UI_ENHANCEMENT by cg
Claus Gittinger <cg@exept.de>
parents: 1649
diff changeset
   545
    
899889bd8404 #UI_ENHANCEMENT by cg
Claus Gittinger <cg@exept.de>
parents: 1649
diff changeset
   546
    key := ('603deb1015ca71be2b73aef0857d77811f352c073b6108d72d9810a30914dff4' 
899889bd8404 #UI_ENHANCEMENT by cg
Claus Gittinger <cg@exept.de>
parents: 1649
diff changeset
   547
            pairWiseCollect:[:b1 :b2 | 
899889bd8404 #UI_ENHANCEMENT by cg
Claus Gittinger <cg@exept.de>
parents: 1649
diff changeset
   548
                Character value:(Integer readFrom:(b1 asString , b2) radix:16).
899889bd8404 #UI_ENHANCEMENT by cg
Claus Gittinger <cg@exept.de>
parents: 1649
diff changeset
   549
            ]) 
899889bd8404 #UI_ENHANCEMENT by cg
Claus Gittinger <cg@exept.de>
parents: 1649
diff changeset
   550
                asByteArray.
899889bd8404 #UI_ENHANCEMENT by cg
Claus Gittinger <cg@exept.de>
parents: 1649
diff changeset
   551
    plaintext := ('6bc1bee22e409f96e93d7e117393172aae2d8a571e03ac9c9eb76fac45af8e5130c81c46a35ce411e5fbc1191a0a52eff69f2445df4f9b17ad2b417be66c3710' 
899889bd8404 #UI_ENHANCEMENT by cg
Claus Gittinger <cg@exept.de>
parents: 1649
diff changeset
   552
            pairWiseCollect:[:b1 :b2 | 
899889bd8404 #UI_ENHANCEMENT by cg
Claus Gittinger <cg@exept.de>
parents: 1649
diff changeset
   553
                Character value:(Integer readFrom:(b1 asString , b2) radix:16).
899889bd8404 #UI_ENHANCEMENT by cg
Claus Gittinger <cg@exept.de>
parents: 1649
diff changeset
   554
            ]) 
899889bd8404 #UI_ENHANCEMENT by cg
Claus Gittinger <cg@exept.de>
parents: 1649
diff changeset
   555
                asByteArray.
899889bd8404 #UI_ENHANCEMENT by cg
Claus Gittinger <cg@exept.de>
parents: 1649
diff changeset
   556
    ecb := RijndaelCipher new key:key mode:#ECB.
899889bd8404 #UI_ENHANCEMENT by cg
Claus Gittinger <cg@exept.de>
parents: 1649
diff changeset
   557
    crypted := ecb encrypt:plaintext.
899889bd8404 #UI_ENHANCEMENT by cg
Claus Gittinger <cg@exept.de>
parents: 1649
diff changeset
   558
    hx := crypted hexPrintString asLowercase.
899889bd8404 #UI_ENHANCEMENT by cg
Claus Gittinger <cg@exept.de>
parents: 1649
diff changeset
   559
    self assert:(hx 
899889bd8404 #UI_ENHANCEMENT by cg
Claus Gittinger <cg@exept.de>
parents: 1649
diff changeset
   560
                = 'f3eed1bdb5d2a03c064b5a7e3db181f8591ccb10d410ed26dc5ba74a31362870b6ed21b99ca6f4f9f153e7b1beafed1d23304b7a39f9f3ff067d8d8f9e24ecc7').
899889bd8404 #UI_ENHANCEMENT by cg
Claus Gittinger <cg@exept.de>
parents: 1649
diff changeset
   561
    ecb := RijndaelCipher new key:key mode:#ECB.
899889bd8404 #UI_ENHANCEMENT by cg
Claus Gittinger <cg@exept.de>
parents: 1649
diff changeset
   562
    self assert:(ecb decrypt:crypted) = plaintext.
899889bd8404 #UI_ENHANCEMENT by cg
Claus Gittinger <cg@exept.de>
parents: 1649
diff changeset
   563
     
899889bd8404 #UI_ENHANCEMENT by cg
Claus Gittinger <cg@exept.de>
parents: 1649
diff changeset
   564
    "/ CBC-AES-128
899889bd8404 #UI_ENHANCEMENT by cg
Claus Gittinger <cg@exept.de>
parents: 1649
diff changeset
   565
    
899889bd8404 #UI_ENHANCEMENT by cg
Claus Gittinger <cg@exept.de>
parents: 1649
diff changeset
   566
    key := ('2b7e151628aed2a6abf7158809cf4f3c' 
899889bd8404 #UI_ENHANCEMENT by cg
Claus Gittinger <cg@exept.de>
parents: 1649
diff changeset
   567
            pairWiseCollect:[:b1 :b2 | 
899889bd8404 #UI_ENHANCEMENT by cg
Claus Gittinger <cg@exept.de>
parents: 1649
diff changeset
   568
                Character value:(Integer readFrom:(b1 asString , b2) radix:16).
899889bd8404 #UI_ENHANCEMENT by cg
Claus Gittinger <cg@exept.de>
parents: 1649
diff changeset
   569
            ]) 
899889bd8404 #UI_ENHANCEMENT by cg
Claus Gittinger <cg@exept.de>
parents: 1649
diff changeset
   570
                asByteArray.
899889bd8404 #UI_ENHANCEMENT by cg
Claus Gittinger <cg@exept.de>
parents: 1649
diff changeset
   571
    plaintext := ('6bc1bee22e409f96e93d7e117393172aae2d8a571e03ac9c9eb76fac45af8e5130c81c46a35ce411e5fbc1191a0a52eff69f2445df4f9b17ad2b417be66c3710' 
899889bd8404 #UI_ENHANCEMENT by cg
Claus Gittinger <cg@exept.de>
parents: 1649
diff changeset
   572
            pairWiseCollect:[:b1 :b2 | 
899889bd8404 #UI_ENHANCEMENT by cg
Claus Gittinger <cg@exept.de>
parents: 1649
diff changeset
   573
                Character value:(Integer readFrom:(b1 asString , b2) radix:16).
899889bd8404 #UI_ENHANCEMENT by cg
Claus Gittinger <cg@exept.de>
parents: 1649
diff changeset
   574
            ]) 
899889bd8404 #UI_ENHANCEMENT by cg
Claus Gittinger <cg@exept.de>
parents: 1649
diff changeset
   575
                asByteArray.
899889bd8404 #UI_ENHANCEMENT by cg
Claus Gittinger <cg@exept.de>
parents: 1649
diff changeset
   576
    iv := ('000102030405060708090a0b0c0d0e0f' 
899889bd8404 #UI_ENHANCEMENT by cg
Claus Gittinger <cg@exept.de>
parents: 1649
diff changeset
   577
            pairWiseCollect:[:b1 :b2 | 
899889bd8404 #UI_ENHANCEMENT by cg
Claus Gittinger <cg@exept.de>
parents: 1649
diff changeset
   578
                Character value:(Integer readFrom:(b1 asString , b2) radix:16).
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
                asByteArray.
899889bd8404 #UI_ENHANCEMENT by cg
Claus Gittinger <cg@exept.de>
parents: 1649
diff changeset
   581
    cbc := RijndaelCipher new key:key mode:#CBC.
899889bd8404 #UI_ENHANCEMENT by cg
Claus Gittinger <cg@exept.de>
parents: 1649
diff changeset
   582
    cbc initializationVector:iv.
899889bd8404 #UI_ENHANCEMENT by cg
Claus Gittinger <cg@exept.de>
parents: 1649
diff changeset
   583
    crypted := cbc encrypt:plaintext.
899889bd8404 #UI_ENHANCEMENT by cg
Claus Gittinger <cg@exept.de>
parents: 1649
diff changeset
   584
    hx := crypted hexPrintString asLowercase.
899889bd8404 #UI_ENHANCEMENT by cg
Claus Gittinger <cg@exept.de>
parents: 1649
diff changeset
   585
    self assert:(hx 
899889bd8404 #UI_ENHANCEMENT by cg
Claus Gittinger <cg@exept.de>
parents: 1649
diff changeset
   586
                = '7649abac8119b246cee98e9b12e9197d5086cb9b507219ee95db113a917678b273bed6b8e3c1743b7116e69e222295163ff1caa1681fac09120eca307586e1a7').
899889bd8404 #UI_ENHANCEMENT by cg
Claus Gittinger <cg@exept.de>
parents: 1649
diff changeset
   587
    cbc initializationVector:iv.
899889bd8404 #UI_ENHANCEMENT by cg
Claus Gittinger <cg@exept.de>
parents: 1649
diff changeset
   588
    self assert:(cbc decrypt:crypted) = plaintext.
899889bd8404 #UI_ENHANCEMENT by cg
Claus Gittinger <cg@exept.de>
parents: 1649
diff changeset
   589
     
899889bd8404 #UI_ENHANCEMENT by cg
Claus Gittinger <cg@exept.de>
parents: 1649
diff changeset
   590
    "/ CBC-AES-192
899889bd8404 #UI_ENHANCEMENT by cg
Claus Gittinger <cg@exept.de>
parents: 1649
diff changeset
   591
    
899889bd8404 #UI_ENHANCEMENT by cg
Claus Gittinger <cg@exept.de>
parents: 1649
diff changeset
   592
    key := ('8e73b0f7da0e6452c810f32b809079e562f8ead2522c6b7b' 
899889bd8404 #UI_ENHANCEMENT by cg
Claus Gittinger <cg@exept.de>
parents: 1649
diff changeset
   593
            pairWiseCollect:[:b1 :b2 | 
899889bd8404 #UI_ENHANCEMENT by cg
Claus Gittinger <cg@exept.de>
parents: 1649
diff changeset
   594
                Character value:(Integer readFrom:(b1 asString , b2) radix:16).
899889bd8404 #UI_ENHANCEMENT by cg
Claus Gittinger <cg@exept.de>
parents: 1649
diff changeset
   595
            ]) 
899889bd8404 #UI_ENHANCEMENT by cg
Claus Gittinger <cg@exept.de>
parents: 1649
diff changeset
   596
                asByteArray.
899889bd8404 #UI_ENHANCEMENT by cg
Claus Gittinger <cg@exept.de>
parents: 1649
diff changeset
   597
    plaintext := ('6bc1bee22e409f96e93d7e117393172aae2d8a571e03ac9c9eb76fac45af8e5130c81c46a35ce411e5fbc1191a0a52eff69f2445df4f9b17ad2b417be66c3710' 
899889bd8404 #UI_ENHANCEMENT by cg
Claus Gittinger <cg@exept.de>
parents: 1649
diff changeset
   598
            pairWiseCollect:[:b1 :b2 | 
899889bd8404 #UI_ENHANCEMENT by cg
Claus Gittinger <cg@exept.de>
parents: 1649
diff changeset
   599
                Character value:(Integer readFrom:(b1 asString , b2) radix:16).
899889bd8404 #UI_ENHANCEMENT by cg
Claus Gittinger <cg@exept.de>
parents: 1649
diff changeset
   600
            ]) 
899889bd8404 #UI_ENHANCEMENT by cg
Claus Gittinger <cg@exept.de>
parents: 1649
diff changeset
   601
                asByteArray.
899889bd8404 #UI_ENHANCEMENT by cg
Claus Gittinger <cg@exept.de>
parents: 1649
diff changeset
   602
    iv := ('000102030405060708090a0b0c0d0e0f' 
899889bd8404 #UI_ENHANCEMENT by cg
Claus Gittinger <cg@exept.de>
parents: 1649
diff changeset
   603
            pairWiseCollect:[:b1 :b2 | 
899889bd8404 #UI_ENHANCEMENT by cg
Claus Gittinger <cg@exept.de>
parents: 1649
diff changeset
   604
                Character value:(Integer readFrom:(b1 asString , b2) radix:16).
899889bd8404 #UI_ENHANCEMENT by cg
Claus Gittinger <cg@exept.de>
parents: 1649
diff changeset
   605
            ]) 
899889bd8404 #UI_ENHANCEMENT by cg
Claus Gittinger <cg@exept.de>
parents: 1649
diff changeset
   606
                asByteArray.
899889bd8404 #UI_ENHANCEMENT by cg
Claus Gittinger <cg@exept.de>
parents: 1649
diff changeset
   607
    cbc := RijndaelCipher new key:key mode:#CBC.
899889bd8404 #UI_ENHANCEMENT by cg
Claus Gittinger <cg@exept.de>
parents: 1649
diff changeset
   608
    cbc initializationVector:iv.
899889bd8404 #UI_ENHANCEMENT by cg
Claus Gittinger <cg@exept.de>
parents: 1649
diff changeset
   609
    crypted := cbc encrypt:plaintext.
899889bd8404 #UI_ENHANCEMENT by cg
Claus Gittinger <cg@exept.de>
parents: 1649
diff changeset
   610
    hx := crypted hexPrintString asLowercase.
899889bd8404 #UI_ENHANCEMENT by cg
Claus Gittinger <cg@exept.de>
parents: 1649
diff changeset
   611
    self assert:(hx 
899889bd8404 #UI_ENHANCEMENT by cg
Claus Gittinger <cg@exept.de>
parents: 1649
diff changeset
   612
                = '4f021db243bc633d7178183a9fa071e8b4d9ada9ad7dedf4e5e738763f69145a571b242012fb7ae07fa9baac3df102e008b0e27988598881d920a9e64f5615cd').
899889bd8404 #UI_ENHANCEMENT by cg
Claus Gittinger <cg@exept.de>
parents: 1649
diff changeset
   613
    cbc initializationVector:iv.
899889bd8404 #UI_ENHANCEMENT by cg
Claus Gittinger <cg@exept.de>
parents: 1649
diff changeset
   614
    self assert:(cbc decrypt:crypted) = plaintext.
899889bd8404 #UI_ENHANCEMENT by cg
Claus Gittinger <cg@exept.de>
parents: 1649
diff changeset
   615
     
899889bd8404 #UI_ENHANCEMENT by cg
Claus Gittinger <cg@exept.de>
parents: 1649
diff changeset
   616
    "/ CBC-AES-256
899889bd8404 #UI_ENHANCEMENT by cg
Claus Gittinger <cg@exept.de>
parents: 1649
diff changeset
   617
    
899889bd8404 #UI_ENHANCEMENT by cg
Claus Gittinger <cg@exept.de>
parents: 1649
diff changeset
   618
    key := ('603deb1015ca71be2b73aef0857d77811f352c073b6108d72d9810a30914dff4' 
899889bd8404 #UI_ENHANCEMENT by cg
Claus Gittinger <cg@exept.de>
parents: 1649
diff changeset
   619
            pairWiseCollect:[:b1 :b2 | 
899889bd8404 #UI_ENHANCEMENT by cg
Claus Gittinger <cg@exept.de>
parents: 1649
diff changeset
   620
                Character value:(Integer readFrom:(b1 asString , b2) radix:16).
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
                asByteArray.
899889bd8404 #UI_ENHANCEMENT by cg
Claus Gittinger <cg@exept.de>
parents: 1649
diff changeset
   623
    plaintext := ('6bc1bee22e409f96e93d7e117393172aae2d8a571e03ac9c9eb76fac45af8e5130c81c46a35ce411e5fbc1191a0a52eff69f2445df4f9b17ad2b417be66c3710' 
899889bd8404 #UI_ENHANCEMENT by cg
Claus Gittinger <cg@exept.de>
parents: 1649
diff changeset
   624
            pairWiseCollect:[:b1 :b2 | 
899889bd8404 #UI_ENHANCEMENT by cg
Claus Gittinger <cg@exept.de>
parents: 1649
diff changeset
   625
                Character value:(Integer readFrom:(b1 asString , b2) radix:16).
899889bd8404 #UI_ENHANCEMENT by cg
Claus Gittinger <cg@exept.de>
parents: 1649
diff changeset
   626
            ]) 
899889bd8404 #UI_ENHANCEMENT by cg
Claus Gittinger <cg@exept.de>
parents: 1649
diff changeset
   627
                asByteArray.
899889bd8404 #UI_ENHANCEMENT by cg
Claus Gittinger <cg@exept.de>
parents: 1649
diff changeset
   628
    iv := ('000102030405060708090a0b0c0d0e0f' 
899889bd8404 #UI_ENHANCEMENT by cg
Claus Gittinger <cg@exept.de>
parents: 1649
diff changeset
   629
            pairWiseCollect:[:b1 :b2 | 
899889bd8404 #UI_ENHANCEMENT by cg
Claus Gittinger <cg@exept.de>
parents: 1649
diff changeset
   630
                Character value:(Integer readFrom:(b1 asString , b2) radix:16).
899889bd8404 #UI_ENHANCEMENT by cg
Claus Gittinger <cg@exept.de>
parents: 1649
diff changeset
   631
            ]) 
899889bd8404 #UI_ENHANCEMENT by cg
Claus Gittinger <cg@exept.de>
parents: 1649
diff changeset
   632
                asByteArray.
899889bd8404 #UI_ENHANCEMENT by cg
Claus Gittinger <cg@exept.de>
parents: 1649
diff changeset
   633
    cbc := RijndaelCipher new key:key mode:#CBC.
899889bd8404 #UI_ENHANCEMENT by cg
Claus Gittinger <cg@exept.de>
parents: 1649
diff changeset
   634
    cbc initializationVector:iv.
899889bd8404 #UI_ENHANCEMENT by cg
Claus Gittinger <cg@exept.de>
parents: 1649
diff changeset
   635
    crypted := cbc encrypt:plaintext.
899889bd8404 #UI_ENHANCEMENT by cg
Claus Gittinger <cg@exept.de>
parents: 1649
diff changeset
   636
    hx := crypted hexPrintString asLowercase.
899889bd8404 #UI_ENHANCEMENT by cg
Claus Gittinger <cg@exept.de>
parents: 1649
diff changeset
   637
    self assert:(hx 
899889bd8404 #UI_ENHANCEMENT by cg
Claus Gittinger <cg@exept.de>
parents: 1649
diff changeset
   638
                = 'f58c4c04d6e5f1ba779eabfb5f7bfbd69cfc4e967edb808d679f777bc6702c7d39f23369a9d9bacfa530e26304231461b2eb05e2c39be9fcda6c19078c6a9d1b').
899889bd8404 #UI_ENHANCEMENT by cg
Claus Gittinger <cg@exept.de>
parents: 1649
diff changeset
   639
    cbc initializationVector:iv.
899889bd8404 #UI_ENHANCEMENT by cg
Claus Gittinger <cg@exept.de>
parents: 1649
diff changeset
   640
    self assert:(cbc decrypt:crypted) = plaintext.
899889bd8404 #UI_ENHANCEMENT by cg
Claus Gittinger <cg@exept.de>
parents: 1649
diff changeset
   641
     
899889bd8404 #UI_ENHANCEMENT by cg
Claus Gittinger <cg@exept.de>
parents: 1649
diff changeset
   642
    "/ CFB128-AES-128
899889bd8404 #UI_ENHANCEMENT by cg
Claus Gittinger <cg@exept.de>
parents: 1649
diff changeset
   643
    
899889bd8404 #UI_ENHANCEMENT by cg
Claus Gittinger <cg@exept.de>
parents: 1649
diff changeset
   644
    key := ('2b7e151628aed2a6abf7158809cf4f3c' 
899889bd8404 #UI_ENHANCEMENT by cg
Claus Gittinger <cg@exept.de>
parents: 1649
diff changeset
   645
            pairWiseCollect:[:b1 :b2 | 
899889bd8404 #UI_ENHANCEMENT by cg
Claus Gittinger <cg@exept.de>
parents: 1649
diff changeset
   646
                Character value:(Integer readFrom:(b1 asString , b2) radix:16).
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
                asByteArray.
899889bd8404 #UI_ENHANCEMENT by cg
Claus Gittinger <cg@exept.de>
parents: 1649
diff changeset
   649
    plaintext := ('6bc1bee22e409f96e93d7e117393172aae2d8a571e03ac9c9eb76fac45af8e5130c81c46a35ce411e5fbc1191a0a52eff69f2445df4f9b17ad2b417be66c3710' 
899889bd8404 #UI_ENHANCEMENT by cg
Claus Gittinger <cg@exept.de>
parents: 1649
diff changeset
   650
            pairWiseCollect:[:b1 :b2 | 
899889bd8404 #UI_ENHANCEMENT by cg
Claus Gittinger <cg@exept.de>
parents: 1649
diff changeset
   651
                Character value:(Integer readFrom:(b1 asString , b2) radix:16).
899889bd8404 #UI_ENHANCEMENT by cg
Claus Gittinger <cg@exept.de>
parents: 1649
diff changeset
   652
            ]) 
899889bd8404 #UI_ENHANCEMENT by cg
Claus Gittinger <cg@exept.de>
parents: 1649
diff changeset
   653
                asByteArray.
899889bd8404 #UI_ENHANCEMENT by cg
Claus Gittinger <cg@exept.de>
parents: 1649
diff changeset
   654
    iv := ('000102030405060708090a0b0c0d0e0f' 
899889bd8404 #UI_ENHANCEMENT by cg
Claus Gittinger <cg@exept.de>
parents: 1649
diff changeset
   655
            pairWiseCollect:[:b1 :b2 | 
899889bd8404 #UI_ENHANCEMENT by cg
Claus Gittinger <cg@exept.de>
parents: 1649
diff changeset
   656
                Character value:(Integer readFrom:(b1 asString , b2) radix:16).
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
                asByteArray.
899889bd8404 #UI_ENHANCEMENT by cg
Claus Gittinger <cg@exept.de>
parents: 1649
diff changeset
   659
    cbc := RijndaelCipher new key:key mode:#CFB.
899889bd8404 #UI_ENHANCEMENT by cg
Claus Gittinger <cg@exept.de>
parents: 1649
diff changeset
   660
    cbc initializationVector:iv.
899889bd8404 #UI_ENHANCEMENT by cg
Claus Gittinger <cg@exept.de>
parents: 1649
diff changeset
   661
    crypted := cbc encrypt:plaintext.
899889bd8404 #UI_ENHANCEMENT by cg
Claus Gittinger <cg@exept.de>
parents: 1649
diff changeset
   662
    hx := crypted hexPrintString asLowercase.
899889bd8404 #UI_ENHANCEMENT by cg
Claus Gittinger <cg@exept.de>
parents: 1649
diff changeset
   663
    self assert:(hx 
899889bd8404 #UI_ENHANCEMENT by cg
Claus Gittinger <cg@exept.de>
parents: 1649
diff changeset
   664
                = '3b3fd92eb72dad20333449f8e83cfb4ac8a64537a0b3a93fcde3cdad9f1ce58b26751f67a3cbb140b1808cf187a4f4dfc04b05357c5d1c0eeac4c66f9ff7f2e6').
899889bd8404 #UI_ENHANCEMENT by cg
Claus Gittinger <cg@exept.de>
parents: 1649
diff changeset
   665
    cbc initializationVector:iv.
899889bd8404 #UI_ENHANCEMENT by cg
Claus Gittinger <cg@exept.de>
parents: 1649
diff changeset
   666
    self assert:(cbc decrypt:crypted) = plaintext.
899889bd8404 #UI_ENHANCEMENT by cg
Claus Gittinger <cg@exept.de>
parents: 1649
diff changeset
   667
     
899889bd8404 #UI_ENHANCEMENT by cg
Claus Gittinger <cg@exept.de>
parents: 1649
diff changeset
   668
    "/ CFB128-AES-192
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
    key := ('8e73b0f7da0e6452c810f32b809079e562f8ead2522c6b7b' 
899889bd8404 #UI_ENHANCEMENT by cg
Claus Gittinger <cg@exept.de>
parents: 1649
diff changeset
   671
            pairWiseCollect:[:b1 :b2 | 
899889bd8404 #UI_ENHANCEMENT by cg
Claus Gittinger <cg@exept.de>
parents: 1649
diff changeset
   672
                Character value:(Integer readFrom:(b1 asString , b2) radix:16).
899889bd8404 #UI_ENHANCEMENT by cg
Claus Gittinger <cg@exept.de>
parents: 1649
diff changeset
   673
            ]) 
899889bd8404 #UI_ENHANCEMENT by cg
Claus Gittinger <cg@exept.de>
parents: 1649
diff changeset
   674
                asByteArray.
899889bd8404 #UI_ENHANCEMENT by cg
Claus Gittinger <cg@exept.de>
parents: 1649
diff changeset
   675
    plaintext := ('6bc1bee22e409f96e93d7e117393172aae2d8a571e03ac9c9eb76fac45af8e5130c81c46a35ce411e5fbc1191a0a52eff69f2445df4f9b17ad2b417be66c3710' 
899889bd8404 #UI_ENHANCEMENT by cg
Claus Gittinger <cg@exept.de>
parents: 1649
diff changeset
   676
            pairWiseCollect:[:b1 :b2 | 
899889bd8404 #UI_ENHANCEMENT by cg
Claus Gittinger <cg@exept.de>
parents: 1649
diff changeset
   677
                Character value:(Integer readFrom:(b1 asString , b2) radix:16).
899889bd8404 #UI_ENHANCEMENT by cg
Claus Gittinger <cg@exept.de>
parents: 1649
diff changeset
   678
            ]) 
899889bd8404 #UI_ENHANCEMENT by cg
Claus Gittinger <cg@exept.de>
parents: 1649
diff changeset
   679
                asByteArray.
899889bd8404 #UI_ENHANCEMENT by cg
Claus Gittinger <cg@exept.de>
parents: 1649
diff changeset
   680
    iv := ('000102030405060708090a0b0c0d0e0f' 
899889bd8404 #UI_ENHANCEMENT by cg
Claus Gittinger <cg@exept.de>
parents: 1649
diff changeset
   681
            pairWiseCollect:[:b1 :b2 | 
899889bd8404 #UI_ENHANCEMENT by cg
Claus Gittinger <cg@exept.de>
parents: 1649
diff changeset
   682
                Character value:(Integer readFrom:(b1 asString , b2) radix:16).
899889bd8404 #UI_ENHANCEMENT by cg
Claus Gittinger <cg@exept.de>
parents: 1649
diff changeset
   683
            ]) 
899889bd8404 #UI_ENHANCEMENT by cg
Claus Gittinger <cg@exept.de>
parents: 1649
diff changeset
   684
                asByteArray.
899889bd8404 #UI_ENHANCEMENT by cg
Claus Gittinger <cg@exept.de>
parents: 1649
diff changeset
   685
    cbc := RijndaelCipher new key:key mode:#CFB.
899889bd8404 #UI_ENHANCEMENT by cg
Claus Gittinger <cg@exept.de>
parents: 1649
diff changeset
   686
    cbc initializationVector:iv.
899889bd8404 #UI_ENHANCEMENT by cg
Claus Gittinger <cg@exept.de>
parents: 1649
diff changeset
   687
    crypted := cbc encrypt:plaintext.
899889bd8404 #UI_ENHANCEMENT by cg
Claus Gittinger <cg@exept.de>
parents: 1649
diff changeset
   688
    hx := crypted hexPrintString asLowercase.
899889bd8404 #UI_ENHANCEMENT by cg
Claus Gittinger <cg@exept.de>
parents: 1649
diff changeset
   689
    self assert:(hx 
899889bd8404 #UI_ENHANCEMENT by cg
Claus Gittinger <cg@exept.de>
parents: 1649
diff changeset
   690
                = 'cdc80d6fddf18cab34c25909c99a417467ce7f7f81173621961a2b70171d3d7a2e1e8a1dd59b88b1c8e60fed1efac4c9c05f9f9ca9834fa042ae8fba584b09ff').
899889bd8404 #UI_ENHANCEMENT by cg
Claus Gittinger <cg@exept.de>
parents: 1649
diff changeset
   691
    cbc initializationVector:iv.
899889bd8404 #UI_ENHANCEMENT by cg
Claus Gittinger <cg@exept.de>
parents: 1649
diff changeset
   692
    self assert:(cbc decrypt:crypted) = plaintext.
899889bd8404 #UI_ENHANCEMENT by cg
Claus Gittinger <cg@exept.de>
parents: 1649
diff changeset
   693
     
899889bd8404 #UI_ENHANCEMENT by cg
Claus Gittinger <cg@exept.de>
parents: 1649
diff changeset
   694
    "/ CFB128-AES-256
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
    key := ('603deb1015ca71be2b73aef0857d77811f352c073b6108d72d9810a30914dff4' 
899889bd8404 #UI_ENHANCEMENT by cg
Claus Gittinger <cg@exept.de>
parents: 1649
diff changeset
   697
            pairWiseCollect:[:b1 :b2 | 
899889bd8404 #UI_ENHANCEMENT by cg
Claus Gittinger <cg@exept.de>
parents: 1649
diff changeset
   698
                Character value:(Integer readFrom:(b1 asString , b2) radix:16).
899889bd8404 #UI_ENHANCEMENT by cg
Claus Gittinger <cg@exept.de>
parents: 1649
diff changeset
   699
            ]) 
899889bd8404 #UI_ENHANCEMENT by cg
Claus Gittinger <cg@exept.de>
parents: 1649
diff changeset
   700
                asByteArray.
899889bd8404 #UI_ENHANCEMENT by cg
Claus Gittinger <cg@exept.de>
parents: 1649
diff changeset
   701
    plaintext := ('6bc1bee22e409f96e93d7e117393172aae2d8a571e03ac9c9eb76fac45af8e5130c81c46a35ce411e5fbc1191a0a52eff69f2445df4f9b17ad2b417be66c3710' 
899889bd8404 #UI_ENHANCEMENT by cg
Claus Gittinger <cg@exept.de>
parents: 1649
diff changeset
   702
            pairWiseCollect:[:b1 :b2 | 
899889bd8404 #UI_ENHANCEMENT by cg
Claus Gittinger <cg@exept.de>
parents: 1649
diff changeset
   703
                Character value:(Integer readFrom:(b1 asString , b2) radix:16).
899889bd8404 #UI_ENHANCEMENT by cg
Claus Gittinger <cg@exept.de>
parents: 1649
diff changeset
   704
            ]) 
899889bd8404 #UI_ENHANCEMENT by cg
Claus Gittinger <cg@exept.de>
parents: 1649
diff changeset
   705
                asByteArray.
899889bd8404 #UI_ENHANCEMENT by cg
Claus Gittinger <cg@exept.de>
parents: 1649
diff changeset
   706
    iv := ('000102030405060708090a0b0c0d0e0f' 
899889bd8404 #UI_ENHANCEMENT by cg
Claus Gittinger <cg@exept.de>
parents: 1649
diff changeset
   707
            pairWiseCollect:[:b1 :b2 | 
899889bd8404 #UI_ENHANCEMENT by cg
Claus Gittinger <cg@exept.de>
parents: 1649
diff changeset
   708
                Character value:(Integer readFrom:(b1 asString , b2) radix:16).
899889bd8404 #UI_ENHANCEMENT by cg
Claus Gittinger <cg@exept.de>
parents: 1649
diff changeset
   709
            ]) 
899889bd8404 #UI_ENHANCEMENT by cg
Claus Gittinger <cg@exept.de>
parents: 1649
diff changeset
   710
                asByteArray.
899889bd8404 #UI_ENHANCEMENT by cg
Claus Gittinger <cg@exept.de>
parents: 1649
diff changeset
   711
    cbc := RijndaelCipher new key:key mode:#CFB.
899889bd8404 #UI_ENHANCEMENT by cg
Claus Gittinger <cg@exept.de>
parents: 1649
diff changeset
   712
    cbc initializationVector:iv.
899889bd8404 #UI_ENHANCEMENT by cg
Claus Gittinger <cg@exept.de>
parents: 1649
diff changeset
   713
    crypted := cbc encrypt:plaintext.
899889bd8404 #UI_ENHANCEMENT by cg
Claus Gittinger <cg@exept.de>
parents: 1649
diff changeset
   714
    hx := crypted hexPrintString asLowercase.
899889bd8404 #UI_ENHANCEMENT by cg
Claus Gittinger <cg@exept.de>
parents: 1649
diff changeset
   715
    self assert:(hx 
899889bd8404 #UI_ENHANCEMENT by cg
Claus Gittinger <cg@exept.de>
parents: 1649
diff changeset
   716
                = 'dc7e84bfda79164b7ecd8486985d386039ffed143b28b1c832113c6331e5407bdf10132415e54b92a13ed0a8267ae2f975a385741ab9cef82031623d55b1e471').
899889bd8404 #UI_ENHANCEMENT by cg
Claus Gittinger <cg@exept.de>
parents: 1649
diff changeset
   717
    cbc initializationVector:iv.
899889bd8404 #UI_ENHANCEMENT by cg
Claus Gittinger <cg@exept.de>
parents: 1649
diff changeset
   718
    self assert:(cbc decrypt:crypted) = plaintext.
899889bd8404 #UI_ENHANCEMENT by cg
Claus Gittinger <cg@exept.de>
parents: 1649
diff changeset
   719
     
899889bd8404 #UI_ENHANCEMENT by cg
Claus Gittinger <cg@exept.de>
parents: 1649
diff changeset
   720
    "/ OFB-AES-128
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
    key := ('2b7e151628aed2a6abf7158809cf4f3c' 
899889bd8404 #UI_ENHANCEMENT by cg
Claus Gittinger <cg@exept.de>
parents: 1649
diff changeset
   723
            pairWiseCollect:[:b1 :b2 | 
899889bd8404 #UI_ENHANCEMENT by cg
Claus Gittinger <cg@exept.de>
parents: 1649
diff changeset
   724
                Character value:(Integer readFrom:(b1 asString , b2) radix:16).
899889bd8404 #UI_ENHANCEMENT by cg
Claus Gittinger <cg@exept.de>
parents: 1649
diff changeset
   725
            ]) 
899889bd8404 #UI_ENHANCEMENT by cg
Claus Gittinger <cg@exept.de>
parents: 1649
diff changeset
   726
                asByteArray.
899889bd8404 #UI_ENHANCEMENT by cg
Claus Gittinger <cg@exept.de>
parents: 1649
diff changeset
   727
    plaintext := ('6bc1bee22e409f96e93d7e117393172aae2d8a571e03ac9c9eb76fac45af8e5130c81c46a35ce411e5fbc1191a0a52eff69f2445df4f9b17ad2b417be66c3710' 
899889bd8404 #UI_ENHANCEMENT by cg
Claus Gittinger <cg@exept.de>
parents: 1649
diff changeset
   728
            pairWiseCollect:[:b1 :b2 | 
899889bd8404 #UI_ENHANCEMENT by cg
Claus Gittinger <cg@exept.de>
parents: 1649
diff changeset
   729
                Character value:(Integer readFrom:(b1 asString , b2) radix:16).
899889bd8404 #UI_ENHANCEMENT by cg
Claus Gittinger <cg@exept.de>
parents: 1649
diff changeset
   730
            ]) 
899889bd8404 #UI_ENHANCEMENT by cg
Claus Gittinger <cg@exept.de>
parents: 1649
diff changeset
   731
                asByteArray.
899889bd8404 #UI_ENHANCEMENT by cg
Claus Gittinger <cg@exept.de>
parents: 1649
diff changeset
   732
    iv := ('000102030405060708090a0b0c0d0e0f' 
899889bd8404 #UI_ENHANCEMENT by cg
Claus Gittinger <cg@exept.de>
parents: 1649
diff changeset
   733
            pairWiseCollect:[:b1 :b2 | 
899889bd8404 #UI_ENHANCEMENT by cg
Claus Gittinger <cg@exept.de>
parents: 1649
diff changeset
   734
                Character value:(Integer readFrom:(b1 asString , b2) radix:16).
899889bd8404 #UI_ENHANCEMENT by cg
Claus Gittinger <cg@exept.de>
parents: 1649
diff changeset
   735
            ]) 
899889bd8404 #UI_ENHANCEMENT by cg
Claus Gittinger <cg@exept.de>
parents: 1649
diff changeset
   736
                asByteArray.
899889bd8404 #UI_ENHANCEMENT by cg
Claus Gittinger <cg@exept.de>
parents: 1649
diff changeset
   737
    ofb := RijndaelCipher new key:key mode:#OFB.
899889bd8404 #UI_ENHANCEMENT by cg
Claus Gittinger <cg@exept.de>
parents: 1649
diff changeset
   738
    ofb initializationVector:iv.
899889bd8404 #UI_ENHANCEMENT by cg
Claus Gittinger <cg@exept.de>
parents: 1649
diff changeset
   739
    crypted := ofb encrypt:plaintext.
899889bd8404 #UI_ENHANCEMENT by cg
Claus Gittinger <cg@exept.de>
parents: 1649
diff changeset
   740
    hx := crypted hexPrintString asLowercase.
899889bd8404 #UI_ENHANCEMENT by cg
Claus Gittinger <cg@exept.de>
parents: 1649
diff changeset
   741
    self assert:(hx 
899889bd8404 #UI_ENHANCEMENT by cg
Claus Gittinger <cg@exept.de>
parents: 1649
diff changeset
   742
                = '3b3fd92eb72dad20333449f8e83cfb4a7789508d16918f03f53c52dac54ed8259740051e9c5fecf64344f7a82260edcc304c6528f659c77866a510d9c1d6ae5e').
899889bd8404 #UI_ENHANCEMENT by cg
Claus Gittinger <cg@exept.de>
parents: 1649
diff changeset
   743
    ofb initializationVector:iv.
899889bd8404 #UI_ENHANCEMENT by cg
Claus Gittinger <cg@exept.de>
parents: 1649
diff changeset
   744
    self assert:(ofb decrypt:crypted) = plaintext.
899889bd8404 #UI_ENHANCEMENT by cg
Claus Gittinger <cg@exept.de>
parents: 1649
diff changeset
   745
     
899889bd8404 #UI_ENHANCEMENT by cg
Claus Gittinger <cg@exept.de>
parents: 1649
diff changeset
   746
    "/ OFB-AES-192
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
    key := ('8e73b0f7da0e6452c810f32b809079e562f8ead2522c6b7b' 
899889bd8404 #UI_ENHANCEMENT by cg
Claus Gittinger <cg@exept.de>
parents: 1649
diff changeset
   749
            pairWiseCollect:[:b1 :b2 | 
899889bd8404 #UI_ENHANCEMENT by cg
Claus Gittinger <cg@exept.de>
parents: 1649
diff changeset
   750
                Character value:(Integer readFrom:(b1 asString , b2) radix:16).
899889bd8404 #UI_ENHANCEMENT by cg
Claus Gittinger <cg@exept.de>
parents: 1649
diff changeset
   751
            ]) 
899889bd8404 #UI_ENHANCEMENT by cg
Claus Gittinger <cg@exept.de>
parents: 1649
diff changeset
   752
                asByteArray.
899889bd8404 #UI_ENHANCEMENT by cg
Claus Gittinger <cg@exept.de>
parents: 1649
diff changeset
   753
    plaintext := ('6bc1bee22e409f96e93d7e117393172aae2d8a571e03ac9c9eb76fac45af8e5130c81c46a35ce411e5fbc1191a0a52eff69f2445df4f9b17ad2b417be66c3710' 
899889bd8404 #UI_ENHANCEMENT by cg
Claus Gittinger <cg@exept.de>
parents: 1649
diff changeset
   754
            pairWiseCollect:[:b1 :b2 | 
899889bd8404 #UI_ENHANCEMENT by cg
Claus Gittinger <cg@exept.de>
parents: 1649
diff changeset
   755
                Character value:(Integer readFrom:(b1 asString , b2) radix:16).
899889bd8404 #UI_ENHANCEMENT by cg
Claus Gittinger <cg@exept.de>
parents: 1649
diff changeset
   756
            ]) 
899889bd8404 #UI_ENHANCEMENT by cg
Claus Gittinger <cg@exept.de>
parents: 1649
diff changeset
   757
                asByteArray.
899889bd8404 #UI_ENHANCEMENT by cg
Claus Gittinger <cg@exept.de>
parents: 1649
diff changeset
   758
    iv := ('000102030405060708090a0b0c0d0e0f' 
899889bd8404 #UI_ENHANCEMENT by cg
Claus Gittinger <cg@exept.de>
parents: 1649
diff changeset
   759
            pairWiseCollect:[:b1 :b2 | 
899889bd8404 #UI_ENHANCEMENT by cg
Claus Gittinger <cg@exept.de>
parents: 1649
diff changeset
   760
                Character value:(Integer readFrom:(b1 asString , b2) radix:16).
899889bd8404 #UI_ENHANCEMENT by cg
Claus Gittinger <cg@exept.de>
parents: 1649
diff changeset
   761
            ]) 
899889bd8404 #UI_ENHANCEMENT by cg
Claus Gittinger <cg@exept.de>
parents: 1649
diff changeset
   762
                asByteArray.
899889bd8404 #UI_ENHANCEMENT by cg
Claus Gittinger <cg@exept.de>
parents: 1649
diff changeset
   763
    ofb := RijndaelCipher new key:key mode:#OFB.
899889bd8404 #UI_ENHANCEMENT by cg
Claus Gittinger <cg@exept.de>
parents: 1649
diff changeset
   764
    ofb initializationVector:iv.
899889bd8404 #UI_ENHANCEMENT by cg
Claus Gittinger <cg@exept.de>
parents: 1649
diff changeset
   765
    crypted := ofb encrypt:plaintext.
899889bd8404 #UI_ENHANCEMENT by cg
Claus Gittinger <cg@exept.de>
parents: 1649
diff changeset
   766
    hx := crypted hexPrintString asLowercase.
899889bd8404 #UI_ENHANCEMENT by cg
Claus Gittinger <cg@exept.de>
parents: 1649
diff changeset
   767
    self assert:(hx 
899889bd8404 #UI_ENHANCEMENT by cg
Claus Gittinger <cg@exept.de>
parents: 1649
diff changeset
   768
                = 'cdc80d6fddf18cab34c25909c99a4174fcc28b8d4c63837c09e81700c11004018d9a9aeac0f6596f559c6d4daf59a5f26d9f200857ca6c3e9cac524bd9acc92a').
899889bd8404 #UI_ENHANCEMENT by cg
Claus Gittinger <cg@exept.de>
parents: 1649
diff changeset
   769
    ofb initializationVector:iv.
899889bd8404 #UI_ENHANCEMENT by cg
Claus Gittinger <cg@exept.de>
parents: 1649
diff changeset
   770
    self assert:(ofb decrypt:crypted) = plaintext.
899889bd8404 #UI_ENHANCEMENT by cg
Claus Gittinger <cg@exept.de>
parents: 1649
diff changeset
   771
     
899889bd8404 #UI_ENHANCEMENT by cg
Claus Gittinger <cg@exept.de>
parents: 1649
diff changeset
   772
    "/ OFB-AES-256
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
    key := ('603deb1015ca71be2b73aef0857d77811f352c073b6108d72d9810a30914dff4' 
899889bd8404 #UI_ENHANCEMENT by cg
Claus Gittinger <cg@exept.de>
parents: 1649
diff changeset
   775
            pairWiseCollect:[:b1 :b2 | 
899889bd8404 #UI_ENHANCEMENT by cg
Claus Gittinger <cg@exept.de>
parents: 1649
diff changeset
   776
                Character value:(Integer readFrom:(b1 asString , b2) radix:16).
899889bd8404 #UI_ENHANCEMENT by cg
Claus Gittinger <cg@exept.de>
parents: 1649
diff changeset
   777
            ]) 
899889bd8404 #UI_ENHANCEMENT by cg
Claus Gittinger <cg@exept.de>
parents: 1649
diff changeset
   778
                asByteArray.
899889bd8404 #UI_ENHANCEMENT by cg
Claus Gittinger <cg@exept.de>
parents: 1649
diff changeset
   779
    plaintext := ('6bc1bee22e409f96e93d7e117393172aae2d8a571e03ac9c9eb76fac45af8e5130c81c46a35ce411e5fbc1191a0a52eff69f2445df4f9b17ad2b417be66c3710' 
899889bd8404 #UI_ENHANCEMENT by cg
Claus Gittinger <cg@exept.de>
parents: 1649
diff changeset
   780
            pairWiseCollect:[:b1 :b2 | 
899889bd8404 #UI_ENHANCEMENT by cg
Claus Gittinger <cg@exept.de>
parents: 1649
diff changeset
   781
                Character value:(Integer readFrom:(b1 asString , b2) radix:16).
899889bd8404 #UI_ENHANCEMENT by cg
Claus Gittinger <cg@exept.de>
parents: 1649
diff changeset
   782
            ]) 
899889bd8404 #UI_ENHANCEMENT by cg
Claus Gittinger <cg@exept.de>
parents: 1649
diff changeset
   783
                asByteArray.
899889bd8404 #UI_ENHANCEMENT by cg
Claus Gittinger <cg@exept.de>
parents: 1649
diff changeset
   784
    iv := ('000102030405060708090a0b0c0d0e0f' 
899889bd8404 #UI_ENHANCEMENT by cg
Claus Gittinger <cg@exept.de>
parents: 1649
diff changeset
   785
            pairWiseCollect:[:b1 :b2 | 
899889bd8404 #UI_ENHANCEMENT by cg
Claus Gittinger <cg@exept.de>
parents: 1649
diff changeset
   786
                Character value:(Integer readFrom:(b1 asString , b2) radix:16).
899889bd8404 #UI_ENHANCEMENT by cg
Claus Gittinger <cg@exept.de>
parents: 1649
diff changeset
   787
            ]) 
899889bd8404 #UI_ENHANCEMENT by cg
Claus Gittinger <cg@exept.de>
parents: 1649
diff changeset
   788
                asByteArray.
899889bd8404 #UI_ENHANCEMENT by cg
Claus Gittinger <cg@exept.de>
parents: 1649
diff changeset
   789
    ofb := RijndaelCipher new key:key mode:#OFB.
899889bd8404 #UI_ENHANCEMENT by cg
Claus Gittinger <cg@exept.de>
parents: 1649
diff changeset
   790
    ofb initializationVector:iv.
899889bd8404 #UI_ENHANCEMENT by cg
Claus Gittinger <cg@exept.de>
parents: 1649
diff changeset
   791
    crypted := ofb encrypt:plaintext.
899889bd8404 #UI_ENHANCEMENT by cg
Claus Gittinger <cg@exept.de>
parents: 1649
diff changeset
   792
    hx := crypted hexPrintString asLowercase.
899889bd8404 #UI_ENHANCEMENT by cg
Claus Gittinger <cg@exept.de>
parents: 1649
diff changeset
   793
    self assert:(hx 
899889bd8404 #UI_ENHANCEMENT by cg
Claus Gittinger <cg@exept.de>
parents: 1649
diff changeset
   794
                = 'dc7e84bfda79164b7ecd8486985d38604febdc6740d20b3ac88f6ad82a4fb08d71ab47a086e86eedf39d1c5bba97c4080126141d67f37be8538f5a8be740e484').
899889bd8404 #UI_ENHANCEMENT by cg
Claus Gittinger <cg@exept.de>
parents: 1649
diff changeset
   795
    ofb initializationVector:iv.
899889bd8404 #UI_ENHANCEMENT by cg
Claus Gittinger <cg@exept.de>
parents: 1649
diff changeset
   796
    self assert:(ofb decrypt:crypted) = plaintext.
899889bd8404 #UI_ENHANCEMENT by cg
Claus Gittinger <cg@exept.de>
parents: 1649
diff changeset
   797
     
899889bd8404 #UI_ENHANCEMENT by cg
Claus Gittinger <cg@exept.de>
parents: 1649
diff changeset
   798
    "/ CTR-AES-128
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
    key := ByteArray fromHexString:'2b7e151628aed2a6abf7158809cf4f3c'.
899889bd8404 #UI_ENHANCEMENT by cg
Claus Gittinger <cg@exept.de>
parents: 1649
diff changeset
   801
    plaintext := ByteArray 
899889bd8404 #UI_ENHANCEMENT by cg
Claus Gittinger <cg@exept.de>
parents: 1649
diff changeset
   802
            fromHexString:'6bc1bee22e409f96e93d7e117393172aae2d8a571e03ac9c9eb76fac45af8e5130c81c46a35ce411e5fbc1191a0a52eff69f2445df4f9b17ad2b417be66c3710'.
899889bd8404 #UI_ENHANCEMENT by cg
Claus Gittinger <cg@exept.de>
parents: 1649
diff changeset
   803
    iv := ByteArray fromHexString:'f0f1f2f3f4f5f6f7f8f9fafbfcfdfeff'.
899889bd8404 #UI_ENHANCEMENT by cg
Claus Gittinger <cg@exept.de>
parents: 1649
diff changeset
   804
    ctr := RijndaelCipher new key:key mode:#CTR.
899889bd8404 #UI_ENHANCEMENT by cg
Claus Gittinger <cg@exept.de>
parents: 1649
diff changeset
   805
    ctr initializationVector:iv.
899889bd8404 #UI_ENHANCEMENT by cg
Claus Gittinger <cg@exept.de>
parents: 1649
diff changeset
   806
    crypted := ctr encrypt:plaintext.
899889bd8404 #UI_ENHANCEMENT by cg
Claus Gittinger <cg@exept.de>
parents: 1649
diff changeset
   807
    hx := crypted hexPrintString asLowercase.
899889bd8404 #UI_ENHANCEMENT by cg
Claus Gittinger <cg@exept.de>
parents: 1649
diff changeset
   808
    self assert:(hx 
899889bd8404 #UI_ENHANCEMENT by cg
Claus Gittinger <cg@exept.de>
parents: 1649
diff changeset
   809
                = '874d6191b620e3261bef6864990db6ce9806f66b7970fdff8617187bb9fffdff5ae4df3edbd5d35e5b4f09020db03eab1e031dda2fbe03d1792170a0f3009cee').
899889bd8404 #UI_ENHANCEMENT by cg
Claus Gittinger <cg@exept.de>
parents: 1649
diff changeset
   810
    ctr initializationVector:iv.
899889bd8404 #UI_ENHANCEMENT by cg
Claus Gittinger <cg@exept.de>
parents: 1649
diff changeset
   811
    self assert:(ctr decrypt:crypted) = plaintext.
899889bd8404 #UI_ENHANCEMENT by cg
Claus Gittinger <cg@exept.de>
parents: 1649
diff changeset
   812
     
899889bd8404 #UI_ENHANCEMENT by cg
Claus Gittinger <cg@exept.de>
parents: 1649
diff changeset
   813
    "/ CTR-AES-192
899889bd8404 #UI_ENHANCEMENT by cg
Claus Gittinger <cg@exept.de>
parents: 1649
diff changeset
   814
    
899889bd8404 #UI_ENHANCEMENT by cg
Claus Gittinger <cg@exept.de>
parents: 1649
diff changeset
   815
    key := ('8e73b0f7da0e6452c810f32b809079e562f8ead2522c6b7b' 
899889bd8404 #UI_ENHANCEMENT by cg
Claus Gittinger <cg@exept.de>
parents: 1649
diff changeset
   816
            pairWiseCollect:[:b1 :b2 | 
899889bd8404 #UI_ENHANCEMENT by cg
Claus Gittinger <cg@exept.de>
parents: 1649
diff changeset
   817
                Character value:(Integer readFrom:(b1 asString , b2) radix:16).
899889bd8404 #UI_ENHANCEMENT by cg
Claus Gittinger <cg@exept.de>
parents: 1649
diff changeset
   818
            ]) 
899889bd8404 #UI_ENHANCEMENT by cg
Claus Gittinger <cg@exept.de>
parents: 1649
diff changeset
   819
                asByteArray.
899889bd8404 #UI_ENHANCEMENT by cg
Claus Gittinger <cg@exept.de>
parents: 1649
diff changeset
   820
    plaintext := ('6bc1bee22e409f96e93d7e117393172aae2d8a571e03ac9c9eb76fac45af8e5130c81c46a35ce411e5fbc1191a0a52eff69f2445df4f9b17ad2b417be66c3710' 
899889bd8404 #UI_ENHANCEMENT by cg
Claus Gittinger <cg@exept.de>
parents: 1649
diff changeset
   821
            pairWiseCollect:[:b1 :b2 | 
899889bd8404 #UI_ENHANCEMENT by cg
Claus Gittinger <cg@exept.de>
parents: 1649
diff changeset
   822
                Character value:(Integer readFrom:(b1 asString , b2) radix:16).
899889bd8404 #UI_ENHANCEMENT by cg
Claus Gittinger <cg@exept.de>
parents: 1649
diff changeset
   823
            ]) 
899889bd8404 #UI_ENHANCEMENT by cg
Claus Gittinger <cg@exept.de>
parents: 1649
diff changeset
   824
                asByteArray.
899889bd8404 #UI_ENHANCEMENT by cg
Claus Gittinger <cg@exept.de>
parents: 1649
diff changeset
   825
    iv := ('f0f1f2f3f4f5f6f7f8f9fafbfcfdfeff' 
899889bd8404 #UI_ENHANCEMENT by cg
Claus Gittinger <cg@exept.de>
parents: 1649
diff changeset
   826
            pairWiseCollect:[:b1 :b2 | 
899889bd8404 #UI_ENHANCEMENT by cg
Claus Gittinger <cg@exept.de>
parents: 1649
diff changeset
   827
                Character value:(Integer readFrom:(b1 asString , b2) radix:16).
899889bd8404 #UI_ENHANCEMENT by cg
Claus Gittinger <cg@exept.de>
parents: 1649
diff changeset
   828
            ]) 
899889bd8404 #UI_ENHANCEMENT by cg
Claus Gittinger <cg@exept.de>
parents: 1649
diff changeset
   829
                asByteArray.
899889bd8404 #UI_ENHANCEMENT by cg
Claus Gittinger <cg@exept.de>
parents: 1649
diff changeset
   830
    ctr := RijndaelCipher new key:key mode:#CTR.
899889bd8404 #UI_ENHANCEMENT by cg
Claus Gittinger <cg@exept.de>
parents: 1649
diff changeset
   831
    ctr initializationVector:iv.
899889bd8404 #UI_ENHANCEMENT by cg
Claus Gittinger <cg@exept.de>
parents: 1649
diff changeset
   832
    crypted := ctr encrypt:plaintext.
899889bd8404 #UI_ENHANCEMENT by cg
Claus Gittinger <cg@exept.de>
parents: 1649
diff changeset
   833
    hx := crypted hexPrintString asLowercase.
899889bd8404 #UI_ENHANCEMENT by cg
Claus Gittinger <cg@exept.de>
parents: 1649
diff changeset
   834
    self assert:(hx 
899889bd8404 #UI_ENHANCEMENT by cg
Claus Gittinger <cg@exept.de>
parents: 1649
diff changeset
   835
                = '1abc932417521ca24f2b0459fe7e6e0b090339ec0aa6faefd5ccc2c6f4ce8e941e36b26bd1ebc670d1bd1d665620abf74f78a7f6d29809585a97daec58c6b050').
899889bd8404 #UI_ENHANCEMENT by cg
Claus Gittinger <cg@exept.de>
parents: 1649
diff changeset
   836
    ctr initializationVector:iv.
899889bd8404 #UI_ENHANCEMENT by cg
Claus Gittinger <cg@exept.de>
parents: 1649
diff changeset
   837
    self assert:(ctr decrypt:crypted) = plaintext.
899889bd8404 #UI_ENHANCEMENT by cg
Claus Gittinger <cg@exept.de>
parents: 1649
diff changeset
   838
     
899889bd8404 #UI_ENHANCEMENT by cg
Claus Gittinger <cg@exept.de>
parents: 1649
diff changeset
   839
    "/ CTR-AES-256
899889bd8404 #UI_ENHANCEMENT by cg
Claus Gittinger <cg@exept.de>
parents: 1649
diff changeset
   840
    
899889bd8404 #UI_ENHANCEMENT by cg
Claus Gittinger <cg@exept.de>
parents: 1649
diff changeset
   841
    key := ByteArray 
899889bd8404 #UI_ENHANCEMENT by cg
Claus Gittinger <cg@exept.de>
parents: 1649
diff changeset
   842
            fromHexString:'603deb1015ca71be2b73aef0857d77811f352c073b6108d72d9810a30914dff4'.
899889bd8404 #UI_ENHANCEMENT by cg
Claus Gittinger <cg@exept.de>
parents: 1649
diff changeset
   843
    plaintext := ByteArray 
899889bd8404 #UI_ENHANCEMENT by cg
Claus Gittinger <cg@exept.de>
parents: 1649
diff changeset
   844
            fromHexString:'6bc1bee22e409f96e93d7e117393172aae2d8a571e03ac9c9eb76fac45af8e5130c81c46a35ce411e5fbc1191a0a52eff69f2445df4f9b17ad2b417be66c3710'.
899889bd8404 #UI_ENHANCEMENT by cg
Claus Gittinger <cg@exept.de>
parents: 1649
diff changeset
   845
    iv := ByteArray fromHexString:'f0f1f2f3f4f5f6f7f8f9fafbfcfdfeff'.
899889bd8404 #UI_ENHANCEMENT by cg
Claus Gittinger <cg@exept.de>
parents: 1649
diff changeset
   846
    ctr := RijndaelCipher new key:key mode:#CTR.
899889bd8404 #UI_ENHANCEMENT by cg
Claus Gittinger <cg@exept.de>
parents: 1649
diff changeset
   847
    ctr initializationVector:iv.
899889bd8404 #UI_ENHANCEMENT by cg
Claus Gittinger <cg@exept.de>
parents: 1649
diff changeset
   848
    crypted := ctr encrypt:plaintext.
899889bd8404 #UI_ENHANCEMENT by cg
Claus Gittinger <cg@exept.de>
parents: 1649
diff changeset
   849
    hx := crypted hexPrintString asLowercase.
899889bd8404 #UI_ENHANCEMENT by cg
Claus Gittinger <cg@exept.de>
parents: 1649
diff changeset
   850
    self assert:(hx 
899889bd8404 #UI_ENHANCEMENT by cg
Claus Gittinger <cg@exept.de>
parents: 1649
diff changeset
   851
                = '601ec313775789a5b7a7f504bbf3d228f443e3ca4d62b59aca84e990cacaf5c52b0930daa23de94ce87017ba2d84988ddfc9c58db67aada613c2dd08457941a6').
899889bd8404 #UI_ENHANCEMENT by cg
Claus Gittinger <cg@exept.de>
parents: 1649
diff changeset
   852
    ctr initializationVector:iv.
899889bd8404 #UI_ENHANCEMENT by cg
Claus Gittinger <cg@exept.de>
parents: 1649
diff changeset
   853
    self assert:(ctr decrypt:crypted) = plaintext.
899889bd8404 #UI_ENHANCEMENT by cg
Claus Gittinger <cg@exept.de>
parents: 1649
diff changeset
   854
899889bd8404 #UI_ENHANCEMENT by cg
Claus Gittinger <cg@exept.de>
parents: 1649
diff changeset
   855
    "
899889bd8404 #UI_ENHANCEMENT by cg
Claus Gittinger <cg@exept.de>
parents: 1649
diff changeset
   856
     self run:#test12_aesRijndael
899889bd8404 #UI_ENHANCEMENT by cg
Claus Gittinger <cg@exept.de>
parents: 1649
diff changeset
   857
     self new test12_aesRijndael"
899889bd8404 #UI_ENHANCEMENT by cg
Claus Gittinger <cg@exept.de>
parents: 1649
diff changeset
   858
899889bd8404 #UI_ENHANCEMENT by cg
Claus Gittinger <cg@exept.de>
parents: 1649
diff changeset
   859
    "Created: / 26-07-2017 / 09:09:22 / cg"
899889bd8404 #UI_ENHANCEMENT by cg
Claus Gittinger <cg@exept.de>
parents: 1649
diff changeset
   860
    "Modified (format): / 23-08-2017 / 15:51:45 / cg"
805
93f37c5c8c6b *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   861
! !
93f37c5c8c6b *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   862
93f37c5c8c6b *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   863
!CryptTests class methodsFor:'documentation'!
93f37c5c8c6b *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   864
93f37c5c8c6b *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   865
version
93f37c5c8c6b *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   866
    ^ '$Header$'
93f37c5c8c6b *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   867
!
93f37c5c8c6b *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   868
93f37c5c8c6b *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   869
version_CVS
93f37c5c8c6b *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   870
    ^ '$Header$'
93f37c5c8c6b *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   871
! !
93f37c5c8c6b *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   872
1100
1991bf9454ab Load exept:libcrypt if not already loaded.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 1038
diff changeset
   873
1991bf9454ab Load exept:libcrypt if not already loaded.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 1038
diff changeset
   874
CryptTests initialize!