[squeak-dev] The Inbox: CryptoCoreTests-rww.2.mcz

commits at source.squeak.org commits at source.squeak.org
Thu Sep 23 08:24:13 UTC 2010


A new version of CryptoCoreTests was added to project The Inbox:
http://source.squeak.org/inbox/CryptoCoreTests-rww.2.mcz

==================== Summary ====================

Name: CryptoCoreTests-rww.2
Author: rww
Time: 23 September 2010, 4:23:23.624 am
UUID: ecf58792-976c-8c48-944f-9b8f53f4b347
Ancestors: CryptoCoreTests-rww.1

fixed RSA signing and moved ASN1 and PKCS11 into Core

=============== Diff against CryptoCoreTests-rww.1 ===============

Item was added:
+ Object subclass: #ASN1TestModel
+ 	instanceVariableNames: 'testSlot1 testSlot2'
+ 	classVariableNames: ''
+ 	poolDictionaries: ''
+ 	category: 'CryptoCoreTests'!

Item was added:
+ ----- Method: ASN1TestModel>>testSlot1 (in category 'accessing') -----
+ testSlot1
+ 	"Answer the value of testSlot1"
+ 
+ 	^ testSlot1!

Item was added:
+ ----- Method: ASN1TestModel>>testSlot1: (in category 'accessing') -----
+ testSlot1: anObject
+ 	"Set the value of testSlot1"
+ 
+ 	testSlot1 := anObject!

Item was added:
+ ----- Method: ASN1TestModel>>testSlot2 (in category 'accessing') -----
+ testSlot2
+ 	"Answer the value of testSlot2"
+ 
+ 	^ testSlot2!

Item was added:
+ ----- Method: ASN1TestModel>>testSlot2: (in category 'accessing') -----
+ testSlot2: anObject
+ 	"Set the value of testSlot2"
+ 
+ 	testSlot2 := anObject!

Item was added:
+ TestCase subclass: #CryptoASN1Test
+ 	instanceVariableNames: ''
+ 	classVariableNames: ''
+ 	poolDictionaries: ''
+ 	category: 'CryptoCoreTests'!

Item was added:
+ ----- Method: CryptoASN1Test>>testBMPString (in category 'tests - base') -----
+ testBMPString
+ 
+ 	| bytes obj newBytes testObj |
+ 	bytes := #(30 11 104 101 108 108 111 32 119 111 114 108 100).
+ 	testObj := 'hello world'.
+ 	obj := ASN1Stream decodeBytes: bytes.
+ 	self assert: (obj = testObj).
+ 	newBytes := ASN1Stream encode: obj.
+ 	self assert: (bytes asByteArray = newBytes).
+ !

Item was added:
+ ----- Method: CryptoASN1Test>>testBaseExplicitType (in category 'tests - defined types') -----
+ testBaseExplicitType
+ 
+ 	| bytes obj newBytes type |
+ 	(ASN1Module name: #test) explicit: #TestExplicit type: #ASN1IntegerType tag: 0.
+ 
+ 	type := (ASN1Module name: #test) find: #TestExplicit.
+ 	bytes := #(160 4 2 2 3 21).
+ 	obj := ASN1Stream decodeBytes: bytes withType: type.
+ 	self assert: (obj = 789).
+ 	newBytes := ASN1Stream encode: obj withType: type.
+ 	self assert: (bytes asByteArray = newBytes).
+ !

Item was added:
+ ----- Method: CryptoASN1Test>>testBaseImplicitConstructedType (in category 'tests - defined types') -----
+ testBaseImplicitConstructedType
+ 
+ 	| bytes obj newBytes type |
+ 	(ASN1Module name: #test) implicit: #TestImplicit type: #ASN1SequenceType tag: 0.
+ 
+ 	type := (ASN1Module name: #test) find: #TestImplicit.
+ 	bytes := #(160 4 2 2 3 21).
+ 	obj := ASN1Stream decodeBytes: bytes withType: type.
+ 	self assert: (obj = (OrderedCollection with: 789)).
+ 	newBytes := ASN1Stream encode: obj withType: type.
+ 	self assert: (bytes asByteArray = newBytes).
+ !

Item was added:
+ ----- Method: CryptoASN1Test>>testBaseImplicitPrimitiveType (in category 'tests - defined types') -----
+ testBaseImplicitPrimitiveType
+ 
+ 	| bytes obj newBytes type |
+ 	(ASN1Module name: #test) implicit: #TestImplicit type: #ASN1IntegerType tag: 0.
+ 
+ 	type := (ASN1Module name: #test) find: #TestImplicit.
+ 	bytes := #(128 2 3 21).
+ 	obj := ASN1Stream decodeBytes: bytes withType: type.
+ 	self assert: (obj = 789).
+ 	newBytes := ASN1Stream encode: obj withType: type.
+ 	self assert: (bytes asByteArray = newBytes).
+ !

Item was added:
+ ----- Method: CryptoASN1Test>>testBitString (in category 'tests - base') -----
+ testBitString
+ 
+ 	| bytes obj newBytes testObj |
+ 	bytes := #(3 3 3 168 121).
+ 	testObj := ASN1BitString new 
+ 		bytes: #(168 121); 
+ 		bitsPadding: 3; 
+ 		yourself.
+ 	obj := ASN1Stream decodeBytes: bytes.
+ 	self assert: (obj = testObj).
+ 	newBytes := ASN1Stream encode: obj.
+ 	self assert: (bytes asByteArray = newBytes).
+ !

Item was added:
+ ----- Method: CryptoASN1Test>>testBoolean (in category 'tests - base') -----
+ testBoolean
+ 
+ 	| bytes obj newBytes testObj |
+ 	bytes := #(1 1 255).
+ 	testObj := true.
+ 	obj := ASN1Stream decodeBytes: bytes.
+ 	self assert: (obj = testObj).
+ 	newBytes := ASN1Stream encode: obj.
+ 	self assert: (bytes asByteArray = newBytes).
+ !

Item was added:
+ ----- Method: CryptoASN1Test>>testByteArray (in category 'tests - base') -----
+ testByteArray
+ 
+ 	| bytes obj newBytes testObj |
+ 	bytes := #(4 5 3 21 55 43 76).
+ 	testObj := #(3 21 55 43 76) asByteArray.
+ 	obj := ASN1Stream decodeBytes: bytes.
+ 	self assert: (obj = testObj).
+ 	newBytes := ASN1Stream encode: obj.
+ 	self assert: (bytes asByteArray = newBytes).
+ !

Item was added:
+ ----- Method: CryptoASN1Test>>testConstructedBMPString (in category 'tests - BER') -----
+ testConstructedBMPString
+ 
+ 	| bytes obj testObj |
+ 	bytes := #(62 15 30 5 84 101 115 116 32 30 6 85 115 101 114 32 49).
+ 	testObj := 'Test User 1'.
+ 	obj := ASN1Stream decodeBytes: bytes.
+ 	self assert: (obj = testObj).
+ !

Item was added:
+ ----- Method: CryptoASN1Test>>testConstructedBitString (in category 'tests - BER') -----
+ testConstructedBitString
+ 
+ 	| bytes obj testObj |
+ 	bytes := #(35 9 3 3 0 110 93 3 2 6 192).
+ 	testObj := ASN1BitString new
+ 		bytes: #(110 93 192) asByteArray;
+ 		bitsPadding: 6;
+ 		yourself.
+ 	obj := ASN1Stream decodeBytes: bytes.
+ 	self assert: (obj = testObj).
+ !

Item was added:
+ ----- Method: CryptoASN1Test>>testConstructedByteArray (in category 'tests - BER') -----
+ testConstructedByteArray
+ 
+ 	| bytes obj testObj |
+ 	bytes := #(36 12 4 4 1 35 69 103 4 4 137 171 205 239).
+ 	testObj :=#(1 35 69 103 137 171 205 239) asByteArray.
+ 	obj := ASN1Stream decodeBytes: bytes.
+ 	self assert: (obj = testObj).
+ !

Item was added:
+ ----- Method: CryptoASN1Test>>testConstructedIA5String (in category 'tests - BER') -----
+ testConstructedIA5String
+ 
+ 	| bytes obj testObj |
+ 	bytes := #(54 15 22 5 84 101 115 116 32 22 6 85 115 101 114 32 49).
+ 	testObj := 'Test User 1'.
+ 	obj := ASN1Stream decodeBytes: bytes.
+ 	self assert: (obj = testObj).
+ !

Item was added:
+ ----- Method: CryptoASN1Test>>testConstructedPrintableString (in category 'tests - BER') -----
+ testConstructedPrintableString
+ 
+ 	| bytes obj testObj |
+ 	bytes := #(51 15 19 5 84 101 115 116 32 19 6 85 115 101 114 32 49).
+ 	testObj := 'Test User 1'.
+ 	obj := ASN1Stream decodeBytes: bytes.
+ 	self assert: (obj = testObj).
+ !

Item was added:
+ ----- Method: CryptoASN1Test>>testConstructedTeletexString (in category 'tests - BER') -----
+ testConstructedTeletexString
+ 
+ 	| bytes obj testObj |
+ 	bytes := #(52 15 20 5 84 101 115 116 32 20 6 85 115 101 114 32 49).
+ 	testObj := 'Test User 1'.
+ 	obj := ASN1Stream decodeBytes: bytes.
+ 	self assert: (obj = testObj).
+ !

Item was added:
+ ----- Method: CryptoASN1Test>>testConstructedUTF8String (in category 'tests - BER') -----
+ testConstructedUTF8String
+ 
+ 	| bytes obj testObj |
+ 	bytes := #(44 15 12 5 84 101 115 116 32 12 6 85 115 101 114 32 49).
+ 	testObj := 'Test User 1'.
+ 	obj := ASN1Stream decodeBytes: bytes.
+ 	self assert: (obj = testObj).
+ !

Item was added:
+ ----- Method: CryptoASN1Test>>testConstructedUniversalString (in category 'tests - BER') -----
+ testConstructedUniversalString
+ 
+ 	| bytes obj testObj |
+ 	bytes := #(60 15 28 5 84 101 115 116 32 28 6 85 115 101 114 32 49).
+ 	testObj := 'Test User 1'.
+ 	obj := ASN1Stream decodeBytes: bytes.
+ 	self assert: (obj = testObj).
+ !

Item was added:
+ ----- Method: CryptoASN1Test>>testDefinedAnyDefinedByType (in category 'tests - defined types') -----
+ testDefinedAnyDefinedByType
+ 
+ 	| bytes obj newBytes type |
+ 	((ASN1Module name: #test) sequence: #TestSequence mapping: ASN1TestModel)
+ 		add: #testSlot1 type: #ASN1ObjectIdentifierType;
+ 		add: #testSlot2 type: #TestAnyDefinedBy;
+ 		yourself.
+ 	((ASN1Module name: #test) any: #TestAnyDefinedBy definedBy: #testSlot1)
+ 		at: (ASN1ObjectId fromString: '1.1') put: #ASN1BooleanType;
+ 		at: (ASN1ObjectId fromString: '1.2') put: #ASN1IntegerType;
+ 		yourself.
+ 
+ 	type := (ASN1Module name: #test) find: #TestSequence.
+ 
+ 	bytes := #(48 6 6 1 41 1 1 255).
+ 	obj := ASN1Stream decodeBytes: bytes withType: type.
+ 	self assert: (obj isKindOf: ASN1TestModel).
+ 	self assert: (obj testSlot1 = (ASN1ObjectId fromString: '1.1')).
+ 	self assert: (obj testSlot2 = true).
+ 	newBytes := ASN1Stream encode: obj withType: type.
+ 	self assert: (bytes asByteArray = newBytes).
+ 
+ 	bytes := #(48 7 6 1 42 2 2 3 21).
+ 	obj := ASN1Stream decodeBytes: bytes withType: type.
+ 	self assert: (obj isKindOf: ASN1TestModel).
+ 	self assert: (obj testSlot1 = (ASN1ObjectId fromString: '1.2')).
+ 	self assert: (obj testSlot2 = 789).
+ 	newBytes := ASN1Stream encode: obj withType: type.
+ 	self assert: (bytes asByteArray = newBytes).
+ !

Item was added:
+ ----- Method: CryptoASN1Test>>testDefinedAnyType (in category 'tests - defined types') -----
+ testDefinedAnyType
+ 
+ 	| bytes obj newBytes type |
+ 	((ASN1Module name: #test) sequence: #TestSequence mapping: ASN1TestModel)
+ 		add: #testSlot1 type: #ASN1AnyType;
+ 		yourself.
+ 
+ 	type := (ASN1Module name: #test) find: #TestSequence.
+ 
+ 	bytes := #(48 3 1 1 255).
+ 	obj := ASN1Stream decodeBytes: bytes withType: type.
+ 	self assert: (obj isKindOf: ASN1TestModel).
+ 	self assert: (obj testSlot1 = true).
+ 	newBytes := ASN1Stream encode: obj withType: type.
+ 	self assert: (bytes asByteArray = newBytes).
+ 
+ 	bytes := #(48 4 2 2 3 21).
+ 	obj := ASN1Stream decodeBytes: bytes withType: type.
+ 	self assert: (obj isKindOf: ASN1TestModel).
+ 	self assert: (obj testSlot1 = 789).
+ 	newBytes := ASN1Stream encode: obj withType: type.
+ 	self assert: (bytes asByteArray = newBytes).
+ !

Item was added:
+ ----- Method: CryptoASN1Test>>testDefinedChoiceType (in category 'tests - defined types') -----
+ testDefinedChoiceType
+ 
+ 	| bytes obj newBytes type |
+ 	((ASN1Module name: #test) sequence: #TestSequence mapping: ASN1TestModel)
+ 		add: #testSlot1 type: #TestChoice;
+ 		yourself.
+ 	((ASN1Module name: #test) choice: #TestChoice)
+ 		add: #boolean type: #ASN1BooleanType;
+ 		add: #integer type: #ASN1IntegerType;
+ 		yourself.
+ 
+ 	type := (ASN1Module name: #test) find: #TestSequence.
+ 
+ 	bytes := #(48 3 1 1 255).
+ 	obj := ASN1Stream decodeBytes: bytes withType: type.
+ 	self assert: (obj isKindOf: ASN1TestModel).
+ 	self assert: (obj testSlot1 = true).
+ 	newBytes := ASN1Stream encode: obj withType: type.
+ 	self assert: (bytes asByteArray = newBytes).
+ 
+ 	bytes := #(48 4 2 2 3 21).
+ 	obj := ASN1Stream decodeBytes: bytes withType: type.
+ 	self assert: (obj isKindOf: ASN1TestModel).
+ 	self assert: (obj testSlot1 = 789).
+ 	newBytes := ASN1Stream encode: obj withType: type.
+ 	self assert: (bytes asByteArray = newBytes).
+ !

Item was added:
+ ----- Method: CryptoASN1Test>>testDefinedExplicitType (in category 'tests - defined types') -----
+ testDefinedExplicitType
+ 
+ 	| bytes obj newBytes type |
+ 	((ASN1Module name: #test) sequence: #TestSequence mapping: ASN1TestModel)
+ 		add: #testSlot1 type: #ASN1IntegerType explicitTag: 0;
+ 		yourself.
+ 
+ 	type := (ASN1Module name: #test) find: #TestSequence.
+ 	bytes := #(48 6 160 4 2 2 3 21).
+ 	obj := ASN1Stream decodeBytes: bytes withType: type.
+ 	self assert: (obj isKindOf: ASN1TestModel).
+ 	self assert: (obj testSlot1 = 789).
+ 	newBytes := ASN1Stream encode: obj withType: type.
+ 	self assert: (bytes asByteArray = newBytes).
+ !

Item was added:
+ ----- Method: CryptoASN1Test>>testDefinedImplicitConstructedType (in category 'tests - defined types') -----
+ testDefinedImplicitConstructedType
+ 
+ 	| bytes obj newBytes type |
+ 	((ASN1Module name: #test) sequence: #TestSequence mapping: ASN1TestModel)
+ 		add: #testSlot1 type: #ASN1SequenceType implicitTag: 0;
+ 		yourself.
+ 
+ 	type := (ASN1Module name: #test) find: #TestSequence.
+ 	bytes := #(48 6 160 4 2 2 3 21).
+ 	obj := ASN1Stream decodeBytes: bytes withType: type.
+ 	self assert: (obj isKindOf: ASN1TestModel).
+ 	self assert: (obj testSlot1 = (OrderedCollection with: 789)).
+ 	newBytes := ASN1Stream encode: obj withType: type.
+ 	self assert: (bytes asByteArray = newBytes).
+ !

Item was added:
+ ----- Method: CryptoASN1Test>>testDefinedImplicitPrimitiveType (in category 'tests - defined types') -----
+ testDefinedImplicitPrimitiveType
+ 
+ 	| bytes obj newBytes type |
+ 	((ASN1Module name: #test) sequence: #TestSequence mapping: ASN1TestModel)
+ 		add: #testSlot1 type: #ASN1IntegerType implicitTag: 0;
+ 		yourself.
+ 
+ 	type := (ASN1Module name: #test) find: #TestSequence.
+ 	bytes := #(48 4 128 2 3 21).
+ 	obj := ASN1Stream decodeBytes: bytes withType: type.
+ 	self assert: (obj isKindOf: ASN1TestModel).
+ 	self assert: (obj testSlot1 = 789).
+ 	newBytes := ASN1Stream encode: obj withType: type.
+ 	self assert: (bytes asByteArray = newBytes).
+ !

Item was added:
+ ----- Method: CryptoASN1Test>>testDefinedMappedBMPStringType (in category 'tests - mapped') -----
+ testDefinedMappedBMPStringType
+ 
+ 	| bytes obj newBytes type |
+ 	((ASN1Module name: #test) mapped: #TestMapped)
+ 		mapping: ASN1TestModel mappingSymbol: #testSlot1 type: #ASN1BMPStringType.
+ 	type := (ASN1Module name: #test) find: #TestMapped.
+ 
+ 	bytes := #(30 11 104 101 108 108 111 32 119 111 114 108 100).
+ 	obj := ASN1Stream decodeBytes: bytes withType: type.
+ 	self assert: (obj isKindOf: ASN1TestModel).
+ 	self assert: (obj testSlot1 = 'hello world').
+ 	newBytes := ASN1Stream encode: obj withType: type.
+ 	self assert: (bytes asByteArray = newBytes).
+ !

Item was added:
+ ----- Method: CryptoASN1Test>>testDefinedMappedBooleanType (in category 'tests - mapped') -----
+ testDefinedMappedBooleanType
+ 
+ 	| bytes obj newBytes type |
+ 	((ASN1Module name: #test) mapped: #TestMapped)
+ 		mapping: ASN1TestModel mappingSymbol: #testSlot1 type: #ASN1BooleanType.
+ 	type := (ASN1Module name: #test) find: #TestMapped.
+ 
+ 	bytes := #(1 1 255).
+ 	obj := ASN1Stream decodeBytes: bytes withType: type.
+ 	self assert: (obj isKindOf: ASN1TestModel).
+ 	self assert: (obj testSlot1 = true).
+ 	newBytes := ASN1Stream encode: obj withType: type.
+ 	self assert: (bytes asByteArray = newBytes).
+ !

Item was added:
+ ----- Method: CryptoASN1Test>>testDefinedMappedIntegerType (in category 'tests - mapped') -----
+ testDefinedMappedIntegerType
+ 
+ 	| bytes obj newBytes type |
+ 	((ASN1Module name: #test) mapped: #TestMapped)
+ 		mapping: ASN1TestModel mappingSymbol: #testSlot1 type: #ASN1IntegerType.
+ 	type := (ASN1Module name: #test) find: #TestMapped.
+ 
+ 	bytes := #(2 2 3 21).
+ 	obj := ASN1Stream decodeBytes: bytes withType: type.
+ 	self assert: (obj isKindOf: ASN1TestModel).
+ 	self assert: (obj testSlot1 = 789).
+ 	newBytes := ASN1Stream encode: obj withType: type.
+ 	self assert: (bytes asByteArray = newBytes).
+ !

Item was added:
+ ----- Method: CryptoASN1Test>>testDefinedMappedSequenceType (in category 'tests - mapped') -----
+ testDefinedMappedSequenceType
+ 
+ 	| bytes obj newBytes type |
+ 	((ASN1Module name: #test) mapped: #TestMapped)
+ 		mapping: ASN1TestModel mappingSymbol: #testSlot1 type: #TestSequence.
+ 	((ASN1Module name: #test) sequence: #TestSequence mapping: ASN1TestModel)
+ 		add: #testSlot1 type: #ASN1BooleanType.
+ 	type := (ASN1Module name: #test) find: #TestMapped.
+ 
+ 	bytes := #(48 3 1 1 255).
+ 	obj := ASN1Stream decodeBytes: bytes withType: type.
+ 	self assert: (obj isKindOf: ASN1TestModel).
+ 	self assert: (obj testSlot1 isKindOf: ASN1TestModel).
+ 	self assert: (obj testSlot1 testSlot1 = true).
+ 	newBytes := ASN1Stream encode: obj withType: type.
+ 	self assert: (bytes asByteArray = newBytes).
+ !

Item was added:
+ ----- Method: CryptoASN1Test>>testDefinedMappedUTF8StringType (in category 'tests - mapped') -----
+ testDefinedMappedUTF8StringType
+ 
+ 	| bytes obj newBytes type |
+ 	((ASN1Module name: #test) mapped: #TestMapped)
+ 		mapping: ASN1TestModel mappingSymbol: #testSlot1 type: #ASN1StringType.
+ 	type := (ASN1Module name: #test) find: #TestMapped.
+ 
+ 	bytes := #(12 11 104 101 108 108 111 32 119 111 114 108 100).
+ 	obj := ASN1Stream decodeBytes: bytes withType: type.
+ 	self assert: (obj isKindOf: ASN1TestModel).
+ 	self assert: (obj testSlot1 = 'hello world').
+ 	newBytes := ASN1Stream encode: obj withType: type.
+ 	self assert: (bytes asByteArray = newBytes).
+ !

Item was added:
+ ----- Method: CryptoASN1Test>>testDefinedSequenceOfType (in category 'tests - defined types') -----
+ testDefinedSequenceOfType
+ 
+ 	| bytes obj newBytes type |
+ 	(ASN1Module name: #test) sequence: #TestSequence of: #ASN1BooleanType.
+ 
+ 	type := (ASN1Module name: #test) find: #TestSequence.
+ 	bytes := #(48 3 1 1 255).
+ 	obj := ASN1Stream decodeBytes: bytes withType: type.
+ 	self assert: (obj isKindOf: OrderedCollection).
+ 	self assert: (obj first = true).
+ 	newBytes := ASN1Stream encode: obj withType: type.
+ 	self assert: (bytes asByteArray = newBytes).
+ !

Item was added:
+ ----- Method: CryptoASN1Test>>testDefinedSequenceType (in category 'tests - defined types') -----
+ testDefinedSequenceType
+ 
+ 	| bytes obj newBytes type |
+ 	((ASN1Module name: #test) sequence: #TestSequence mapping: ASN1TestModel)
+ 		add: #testSlot1 type: #ASN1BooleanType;
+ 		yourself.
+ 
+ 	type := (ASN1Module name: #test) find: #TestSequence.
+ 	bytes := #(48 3 1 1 255).
+ 	obj := ASN1Stream decodeBytes: bytes withType: type.
+ 	self assert: (obj isKindOf: ASN1TestModel).
+ 	self assert: (obj testSlot1 = true).
+ 	newBytes := ASN1Stream encode: obj withType: type.
+ 	self assert: (bytes asByteArray = newBytes).
+ !

Item was added:
+ ----- Method: CryptoASN1Test>>testDefinedSequenceTypeDefault (in category 'tests - defined types') -----
+ testDefinedSequenceTypeDefault
+ 
+ 	| bytes obj newBytes type |
+ 	((ASN1Module name: #test) sequence: #TestSequence mapping: ASN1TestModel)
+ 		add: #testSlot1 type: #ASN1BooleanType default: false;
+ 		yourself.
+ 
+ 	type := (ASN1Module name: #test) find: #TestSequence.
+ 	bytes := #(48 0).
+ 	obj := ASN1Stream decodeBytes: bytes withType: type.
+ 	self assert: (obj isKindOf: ASN1TestModel).
+ 	self assert: (obj testSlot1 = false).
+ 	newBytes := ASN1Stream encode: obj withType: type.
+ 	self assert: (bytes asByteArray = newBytes).
+ !

Item was added:
+ ----- Method: CryptoASN1Test>>testDefinedSequenceTypeOptional (in category 'tests - defined types') -----
+ testDefinedSequenceTypeOptional
+ 
+ 	| bytes obj newBytes type |
+ 	((ASN1Module name: #test) sequence: #TestSequence mapping: ASN1TestModel)
+ 		addOptional: #testSlot1 type: #ASN1BooleanType;
+ 		yourself.
+ 
+ 	type := (ASN1Module name: #test) find: #TestSequence.
+ 	bytes := #(48 0).
+ 	obj := ASN1Stream decodeBytes: bytes withType: type.
+ 	self assert: (obj isKindOf: ASN1TestModel).
+ 	newBytes := ASN1Stream encode: obj withType: type.
+ 	self assert: (bytes asByteArray = newBytes).
+ !

Item was added:
+ ----- Method: CryptoASN1Test>>testDefinedSequenceTypeOptionalDefault (in category 'tests - defined types') -----
+ testDefinedSequenceTypeOptionalDefault
+ 
+ 	| bytes obj newBytes type |
+ 	((ASN1Module name: #test) sequence: #TestSequence mapping: ASN1TestModel)
+ 		addOptional: #testSlot1 type: #ASN1BooleanType default: false;
+ 		yourself.
+ 
+ 	type := (ASN1Module name: #test) find: #TestSequence.
+ 	bytes := #(48 0).
+ 	obj := ASN1Stream decodeBytes: bytes withType: type.
+ 	self assert: (obj isKindOf: ASN1TestModel).
+ 	self assert: (obj testSlot1 = false).
+ 	newBytes := ASN1Stream encode: obj withType: type.
+ 	self assert: (bytes asByteArray = newBytes).
+ !

Item was added:
+ ----- Method: CryptoASN1Test>>testDefinedSetType (in category 'tests - defined types') -----
+ testDefinedSetType
+ 
+ 	| bytes obj newBytes type |
+ 	((ASN1Module name: #test) set: #TestSet mapping: ASN1TestModel)
+ 		add: #testSlot1 type: #ASN1BooleanType;
+ 		yourself.
+ 
+ 	type := (ASN1Module name: #test) find: #TestSet.
+ 	bytes := #(49 3 1 1 255).
+ 	obj := ASN1Stream decodeBytes: bytes withType: type.
+ 	self assert: (obj isKindOf: ASN1TestModel).
+ 	self assert: (obj testSlot1 = true).
+ 	newBytes := ASN1Stream encode: obj withType: type.
+ 	self assert: (bytes asByteArray = newBytes).
+ !

Item was added:
+ ----- Method: CryptoASN1Test>>testDefinedUnmappedSequenceType (in category 'tests - defined types') -----
+ testDefinedUnmappedSequenceType
+ 
+ 	| bytes obj newBytes type |
+ 	(ASN1Module name: #test) sequence: #TestSequence.
+ 
+ 	type := (ASN1Module name: #test) find: #TestSequence.
+ 	bytes := #(48 3 1 1 255).
+ 	obj := ASN1Stream decodeBytes: bytes withType: type.
+ 	self assert: (obj isKindOf: OrderedCollection).
+ 	self assert: (obj first = true).
+ 	newBytes := ASN1Stream encode: obj withType: type.
+ 	self assert: (bytes asByteArray = newBytes).
+ !

Item was added:
+ ----- Method: CryptoASN1Test>>testDefinedUnmappedSetType (in category 'tests - defined types') -----
+ testDefinedUnmappedSetType
+ 
+ 	| bytes obj newBytes type |
+ 	(ASN1Module name: #test) set: #TestSet.
+ 
+ 	type := (ASN1Module name: #test) find: #TestSet.
+ 	bytes := #(49 3 1 1 255).
+ 	obj := ASN1Stream decodeBytes: bytes withType: type.
+ 	self assert: (obj isKindOf: OrderedSet).
+ 	self assert: (obj includes: true).
+ 	newBytes := ASN1Stream encode: obj withType: type.
+ 	self assert: (bytes asByteArray = newBytes).
+ !

Item was added:
+ ----- Method: CryptoASN1Test>>testEqualsChecksType (in category 'tests - base') -----
+ testEqualsChecksType
+ 
+ 	self deny: (ASN1ObjectId fromString: '1.3.6.1.5.5.7.8.5') = Object new
+ !

Item was added:
+ ----- Method: CryptoASN1Test>>testIA5String (in category 'tests - base') -----
+ testIA5String
+ 
+ 	| bytes obj newBytes testObj |
+ 	bytes := #(22 11 104 101 108 108 111 32 119 111 114 108 100).
+ 	testObj := 'hello world'.
+ 	obj := ASN1Stream decodeBytes: bytes.
+ 	self assert: (obj = testObj).
+ 	newBytes := ASN1Stream encode: obj.
+ 	self assert: (bytes asByteArray = newBytes).
+ !

Item was added:
+ ----- Method: CryptoASN1Test>>testIndefiniteLengthSequence (in category 'tests - BER') -----
+ testIndefiniteLengthSequence
+ 
+ 	| bytes obj testObj |
+ 	bytes := #(48 128 1 1 255 2 2 3 21 4 2 108 100 0 0).
+ 	testObj := OrderedCollection new
+ 		add: true;
+ 		add: 789;
+ 		add: #(108 100) asByteArray;
+ 		yourself.
+ 	obj := ASN1Stream decodeBytes: bytes.
+ 	self assert: (obj = testObj).
+ !

Item was added:
+ ----- Method: CryptoASN1Test>>testInteger (in category 'tests - base') -----
+ testInteger
+ 
+ 	| bytes obj newBytes testObj |
+ 	bytes := #(2 2 3 21).
+ 	testObj := 789.
+ 	obj := ASN1Stream decodeBytes: bytes.
+ 	self assert: (obj = testObj).
+ 	newBytes := ASN1Stream encode: obj.
+ 	self assert: (bytes asByteArray = newBytes).
+ !

Item was added:
+ ----- Method: CryptoASN1Test>>testNull (in category 'tests - base') -----
+ testNull
+ 
+ 	| bytes obj newBytes |
+ 	bytes := #(5 0).
+ 	obj := ASN1Stream decodeBytes: bytes.
+ 	self assert: obj isNil.
+ 	newBytes := ASN1Stream encode: obj.
+ 	self assert: (bytes asByteArray = newBytes).
+ !

Item was added:
+ ----- Method: CryptoASN1Test>>testObjectIdentifier (in category 'tests - base') -----
+ testObjectIdentifier
+ 
+ 	| bytes obj newBytes testObj |
+ 	bytes := #(6 8 43 6 1 5 5 7 8 5).
+ 	testObj := ASN1ObjectId new
+ 		oid: '1.3.6.1.5.5.7.8.5';
+ 		yourself.
+ 	obj := ASN1Stream decodeBytes: bytes.
+ 	self assert: (obj = testObj).
+ 	newBytes := ASN1Stream encode: obj.
+ 	self assert: (bytes asByteArray = newBytes).
+ !

Item was added:
+ ----- Method: CryptoASN1Test>>testPrintableString (in category 'tests - base') -----
+ testPrintableString
+ 
+ 	| bytes obj newBytes testObj |
+ 	bytes := #(19 11 104 101 108 108 111 32 119 111 114 108 100).
+ 	testObj := 'hello world'.
+ 	obj := ASN1Stream decodeBytes: bytes.
+ 	self assert: (obj = testObj).
+ 	newBytes := ASN1Stream encode: obj.
+ 	self assert: (bytes asByteArray = newBytes).
+ !

Item was added:
+ ----- Method: CryptoASN1Test>>testSequence (in category 'tests - base') -----
+ testSequence
+ 
+ 	| bytes obj newBytes testObj |
+ 	bytes := #(48 11 1 1 255 2 2 3 21 4 2 108 100).
+ 	testObj := OrderedCollection new
+ 		add: true;
+ 		add: 789;
+ 		add: #(108 100) asByteArray;
+ 		yourself.
+ 	obj := ASN1Stream decodeBytes: bytes.
+ 	self assert: (obj = testObj).
+ 	newBytes := ASN1Stream encode: obj.
+ 	self assert: (bytes asByteArray = newBytes).
+ !

Item was added:
+ ----- Method: CryptoASN1Test>>testSet (in category 'tests - base') -----
+ testSet
+ 
+ 	| bytes obj newBytes testObj |
+ 	bytes := #(49 11 1 1 255 4 2 108 100 2 2 3 21 ).
+ 	testObj := OrderedSet new
+ 		add: true;
+ 		add: #(108 100) asByteArray;
+ 		add: 789;
+ 		yourself.
+ 	obj := ASN1Stream decodeBytes: bytes.
+ 	self assert: (obj = testObj).
+ 	newBytes := ASN1Stream encode: obj.
+ 	self assert: (bytes asByteArray = newBytes).
+ !

Item was added:
+ ----- Method: CryptoASN1Test>>testString (in category 'tests - base') -----
+ testString
+ 
+ 	| bytes obj newBytes testObj |
+ 	bytes := #(12 11 104 101 108 108 111 32 119 111 114 108 100).
+ 	testObj := 'hello world'.
+ 	obj := ASN1Stream decodeBytes: bytes.
+ 	self assert: (obj = testObj).
+ 	newBytes := ASN1Stream encode: obj.
+ 	self assert: (bytes asByteArray = newBytes).
+ !

Item was added:
+ ----- Method: CryptoASN1Test>>testTeletexString (in category 'tests - base') -----
+ testTeletexString
+ 
+ 	| bytes obj newBytes testObj |
+ 	bytes := #(20 11 104 101 108 108 111 32 119 111 114 108 100).
+ 	testObj := 'hello world'.
+ 	obj := ASN1Stream decodeBytes: bytes.
+ 	self assert: (obj = testObj).
+ 	newBytes := ASN1Stream encode: obj.
+ 	self assert: (bytes asByteArray = newBytes).
+ !

Item was added:
+ ----- Method: CryptoASN1Test>>testUTCTime (in category 'tests - base') -----
+ testUTCTime
+ 
+ 	| bytes obj newBytes testObj |
+ 	bytes := #(23 13 48 55 48 51 50 50 49 53 53 56 49 55 90).
+ 	testObj := DateAndTime fromString: '2007-03-22T15:58:17+00:00'.
+ 	obj := ASN1Stream decodeBytes: bytes.
+ 	self assert: (obj = testObj).
+ 	newBytes := ASN1Stream encode: obj.
+ 	self assert: (bytes asByteArray = newBytes).
+ !

Item was added:
+ ----- Method: CryptoASN1Test>>testUniversalString (in category 'tests - base') -----
+ testUniversalString
+ 
+ 	| bytes obj newBytes testObj |
+ 	bytes := #(28 11 104 101 108 108 111 32 119 111 114 108 100).
+ 	testObj := 'hello world'.
+ 	obj := ASN1Stream decodeBytes: bytes.
+ 	self assert: (obj = testObj).
+ 	newBytes := ASN1Stream encode: obj.
+ 	self assert: (bytes asByteArray = newBytes).
+ !

Item was added:
+ TestCase subclass: #CryptoPKCS12Test
+ 	instanceVariableNames: ''
+ 	classVariableNames: ''
+ 	poolDictionaries: ''
+ 	category: 'CryptoCoreTests'!

Item was added:
+ ----- Method: CryptoPKCS12Test>>test1 (in category 'testing') -----
+ test1
+ 
+ 	| key |
+ 	key := (Pkcs12KeyDerivationFunction new
+ 		derivedKeyWithId: 2 
+ 		fromPassword: 'smeg' 
+ 		salt: #(10 88 207 100 83 13 130 63)
+ 		iterations: 1
+ 		size: 8) hex.
+ 	self assert: key = '79993DFE048D3B76'
+ !

Item was added:
+ ----- Method: CryptoPKCS12Test>>test10 (in category 'testing') -----
+ test10
+ 
+ 	| key |
+ 	key := (Pkcs12KeyDerivationFunction new
+ 		derivedKeyWithId: 1
+ 		fromPassword: 'queeg' 
+ 		salt: #(22 130 192 252 91 63 126 197)
+ 		iterations: 1000
+ 		size: 24) hex.
+ 	self assert: key = '483DD6E919D7DE2E8E648BA8F862F3FBFBDC2BCB2C02957F'
+ !

Item was added:
+ ----- Method: CryptoPKCS12Test>>test2 (in category 'testing') -----
+ test2
+ 
+ 	| key |
+ 	key := (Pkcs12KeyDerivationFunction new
+ 		derivedKeyWithId: 2 
+ 		fromPassword: 'smeg' 
+ 		salt: #(100 43 153 171 68 251 75 31)
+ 		iterations: 1
+ 		size: 8) hex.
+ 	self assert: key = 'C0A38D64A79BEA1D'
+ !

Item was added:
+ ----- Method: CryptoPKCS12Test>>test3 (in category 'testing') -----
+ test3
+ 
+ 	| key |
+ 	key := (Pkcs12KeyDerivationFunction new
+ 		derivedKeyWithId: 2 
+ 		fromPassword: 'queeg' 
+ 		salt: #(5 222 201 89 172 255 114 247)
+ 		iterations: 1000
+ 		size: 8) hex.
+ 	self assert: key = '11DEDAD7758D4860'
+ !

Item was added:
+ ----- Method: CryptoPKCS12Test>>test4 (in category 'testing') -----
+ test4
+ 
+ 	| key |
+ 	key := (Pkcs12KeyDerivationFunction new
+ 		derivedKeyWithId: 2 
+ 		fromPassword: 'queeg' 
+ 		salt: #(22 130 192 252 91 63 126 197)
+ 		iterations: 1000
+ 		size: 8) hex.
+ 	self assert: key = '9D461D1B00355C50'
+ !

Item was added:
+ ----- Method: CryptoPKCS12Test>>test5 (in category 'testing') -----
+ test5
+ 
+ 	| key |
+ 	key := (Pkcs12KeyDerivationFunction new
+ 		derivedKeyWithId: 3 
+ 		fromPassword: 'smeg' 
+ 		salt: #(61 131 192 228 84 106 193 64)
+ 		iterations: 1
+ 		size: 20) hex.
+ 	self assert: key = '8D967D88F6CAA9D714800AB3D48051D63F73A312'
+ !

Item was added:
+ ----- Method: CryptoPKCS12Test>>test6 (in category 'testing') -----
+ test6
+ 
+ 	| key |
+ 	key := (Pkcs12KeyDerivationFunction new
+ 		derivedKeyWithId: 3 
+ 		fromPassword: 'queeg' 
+ 		salt: #(38 50 22 252 194 250 179 28)
+ 		iterations: 1000
+ 		size: 20) hex.
+ 	self assert: key = '5EC4C7A80DF652294C3925B6489A7AB857C83476'
+ !

Item was added:
+ ----- Method: CryptoPKCS12Test>>test7 (in category 'testing') -----
+ test7
+ 
+ 	| key |
+ 	key := (Pkcs12KeyDerivationFunction new
+ 		derivedKeyWithId: 1
+ 		fromPassword: 'smeg' 
+ 		salt: #(10 88 207 100 83 13 130 63)
+ 		iterations: 1
+ 		size: 24) hex.
+ 	self assert: key = '8AAAE6297B6CB04642AB5B077851284EB7128F1A2A7FBCA3'
+ !

Item was added:
+ ----- Method: CryptoPKCS12Test>>test8 (in category 'testing') -----
+ test8
+ 
+ 	| key |
+ 	key := (Pkcs12KeyDerivationFunction new
+ 		derivedKeyWithId: 1
+ 		fromPassword: 'smeg' 
+ 		salt: #(100 43 153 171 68 251 75 31)
+ 		iterations: 1
+ 		size: 24) hex.
+ 	self assert: key = 'F3A95FEC48D7711E985CFE67908C5AB79FA3D7C5CAA5D966'
+ !

Item was added:
+ ----- Method: CryptoPKCS12Test>>test9 (in category 'testing') -----
+ test9
+ 
+ 	| key |
+ 	key := (Pkcs12KeyDerivationFunction new
+ 		derivedKeyWithId: 1
+ 		fromPassword: 'queeg' 
+ 		salt: #(5 222 201 89 172 255 114 247)
+ 		iterations: 1000
+ 		size: 24) hex.
+ 	self assert: key = 'ED2034E36328830FF09DF1E1A07DD357185DAC0D4F9EB3D4'
+ !

Item was changed:
  TestCase subclass: #CryptoRSATest
+ 	instanceVariableNames: 'privateKey publicKey'
- 	instanceVariableNames: ''
  	classVariableNames: ''
  	poolDictionaries: ''
  	category: 'CryptoCoreTests'!

Item was added:
+ ----- Method: CryptoRSATest>>derKeys (in category 'RSA') -----
+ derKeys
+ 
+ 	| key64 |
+ 	key64 := self encodedBase64Keys.
+ 
+ 	^(Base64MimeConverter mimeDecodeToBytes:  key64 readStream ) contents.
+ !

Item was added:
+ ----- Method: CryptoRSATest>>encodedBase64Keys (in category 'RSA') -----
+ encodedBase64Keys
+ 
+ 	^ 'MIICXgIBAAKBgQDkI45GM6mYLlbxrKozE6bXWMoxvtVuIWOIF1KcGLED+4Gipriw
+ Nt0hkosuil513/CMjn9XBSZtaSsiIOLkXLZtbKYhATtvODR1nD/dl0JpFH7BLcD9
+ NGGRKOow0jg8fcPtXhLTy6Dsl7rfmVPJYuc4IlzZImTdErllmhzrTKT3YQIDAQAB
+ AoGBALPQjogomii3hZHQ3QmLGLqtYhjZaBH4wSF3+IXONF+GMcRIklNZuuuGPKt/
+ JjrUOh4fBqFJDuO3u+aXcx45MRMLVHuQIuUbegJXVS+rnxXI3I6I4SLBkoV7Jqn/
+ J9T9biOXrzq/xN8XVJQm7zq/FXaHR6l+Wo50LaBj7llY+CMBAkEA8bfsbySseTbI
+ D7tR/bytEz/DhQ1knKS3nFo83NYwDm7YcdGC+f0rQIUuS30lKApeoygBUiLOSs7K
+ euxEi6wC0QJBAPGePI59Fc5alAivyTkYdV4sbIL+SL5oXEERRyezogEgRqCGJtyd
+ MbnVviwREF4MiGTYQIIOx4aFrM/U4q9DL5ECQH+/QImMzEpTlXAbA74iFSZzMJYE
+ +gN/WjqbxkbAPC2kj2e33ozYLB+xQ0JKJXT/5fw8jFYoZvZKS+CjNabLhcECQQDp
+ bgrrToXGu1PRoKMzeiHKPfkIBUuaSZD3fA3WmYGmvNv/MhxRf70O4SW9xS6e7lTH
+ uPV5sXWqzXLLx8zJrotBAkEAgAoiR+5uOW9CgfWkblJ/YIgGbLiLQoFNZbwxXDfr
+ jcosTQvBjrc//rCnb2Pgm8QRGeN/CXKc9kKoWNqUQSYchQ==
+ MIGfMA0GCSqGSIb3DQEBAQUAA4GNADCBiQKBgQDkI45GM6mYLlbxrKozE6bXWMox
+ vtVuIWOIF1KcGLED+4GipriwNt0hkosuil513/CMjn9XBSZtaSsiIOLkXLZtbKYh
+ ATtvODR1nD/dl0JpFH7BLcD9NGGRKOow0jg8fcPtXhLTy6Dsl7rfmVPJYuc4IlzZ
+ ImTdErllmhzrTKT3YQIDAQAB'.!

Item was changed:
+ ----- Method: CryptoRSATest>>genericRSATest: (in category 'tests') -----
- ----- Method: CryptoRSATest>>genericRSATest: (in category 'RSA') -----
  genericRSATest: bits
  	| generator public private msg c |
  	generator := RSAKeyPairGenerator new bits: bits.
  	public := generator publicKey. "this may take a while"
  	private := generator privateKey.
  
  	msg := 1234567890987654321. "the plaintext"
  	
  c := public crypt: msg. "the ciphertext (print it and take a look)"
  	self assert: (private crypt: c) = msg!

Item was added:
+ ----- Method: CryptoRSATest>>setUp (in category 'running') -----
+ setUp
+ 	| reader |
+ 	super setUp.
+ 	
+ 	reader := RSAPrivateKeyFileReader new.
+ 	reader decryptedBytes: self derKeys.
+ 	privateKey := reader asPrivateKey.
+ 	publicKey := reader asPublicKey.
+ 	!

Item was changed:
+ ----- Method: CryptoRSATest>>testRSA128 (in category 'tests') -----
- ----- Method: CryptoRSATest>>testRSA128 (in category 'RSA') -----
  testRSA128
  	self genericRSATest: 128!

Item was changed:
+ ----- Method: CryptoRSATest>>testRSA64 (in category 'tests') -----
- ----- Method: CryptoRSATest>>testRSA64 (in category 'RSA') -----
  testRSA64
  	self genericRSATest: 64!

Item was added:
+ ----- Method: CryptoRSATest>>testRSASHASignVerification (in category 'tests') -----
+ testRSASHASignVerification
+ 
+ 	| signBytes |
+ 	
+ 	signBytes := privateKey v15SignMessage: 'hello'.  
+ 	
+ 	self assert: (publicKey v15Verify: signBytes isSignatureOf: 'hello')!

Item was added:
+ ----- Method: CryptoRSATest>>testRSASHASigning (in category 'tests') -----
+ testRSASHASigning
+ 
+ 	| signBytes |	
+ 
+ 	signBytes := privateKey v15SignMessage: 'hello'.  
+ 
+ 	self assert: signBytes = 
+ #[217 255 224 189 56 76 46 39 224 98 134 191 90 24 145 47 7 195 143 29 131 44 93 172 118 161 3 217 231 74 82 55 37 193 86 114 7 137 22 207 107 27 26 121 40 155 185 172 20 23 27 27 187 162 97 64 151 41 173 230 53 54 174 53 73 76 252 145 252 215 166 53 37 21 174 21 185 171 201 163 197 43 15 202 40 48 150 9 233 126 34 221 219 27 215 142 161 15 225 230 238 150 82 130 2 51 197 124 242 211 222 60 145 93 145 198 48 122 160 232 31 75 161 244 8 194 143 170]!




More information about the Squeak-dev mailing list