Skip to content

Commit

Permalink
Extract BCryptLibrary to separate package and improve hash wrappers
Browse files Browse the repository at this point in the history
  • Loading branch information
blairmcg committed Dec 14, 2024
1 parent 3654ebe commit b2462c0
Show file tree
Hide file tree
Showing 16 changed files with 1,351 additions and 370 deletions.
14 changes: 12 additions & 2 deletions Core/Object Arts/Dolphin/Base/Core.LargeInteger.cls
Original file line number Diff line number Diff line change
Expand Up @@ -575,9 +575,18 @@ uint32AtOffset:put:!accessing!primitives!private! !

!Core.LargeInteger class methodsFor!

fromBigEndianBytes: aByteObject
"Answer an instance of the receiver instantiated from the byte object argument, which is assumed to contain a big-endian positive Integer magnitude."

| offset answer size |
answer := self basicNew: ((size := aByteObject size) roundUpTo: 4) + 4.
offset := size + 1.
1 to: size do: [:i | answer basicAt: offset - i put: (aByteObject at: i)].
answer isImmutable: true.
^answer normalize!

fromBytes: bytes
"Answer an instance of the receiver instantiated from the byte object, bytes,
which is assumed to contain a positive Integer magnitude."
"Answer an instance of the receiver instantiated from the byte object, bytes, which is assumed to contain a little-endian positive Integer magnitude."

| size answer |
size := bytes size.
Expand Down Expand Up @@ -609,6 +618,7 @@ new64
^self basicNew: 8! !

!Core.LargeInteger class categoriesForMethods!
fromBigEndianBytes:!instance creation!public! !
fromBytes:!instance creation!public! !
fromSmallInteger:!instance creation!private! !
new:!instance creation!private! !
Expand Down
80 changes: 3 additions & 77 deletions Core/Object Arts/Dolphin/DolphinSure/DolphinSure.pax
Original file line number Diff line number Diff line change
Expand Up @@ -24,8 +24,6 @@ package basicScriptAt: #postinstall put: '"To allow loading of old format STB''d
do: [:each | ClassLocator addAlias: each unqualifiedName forClass: each value]'.

package setClassNames: #(
#{OS.BCryptConstants}
#{OS.BCryptLibrary}
#{Security}
#{Security.DigitalSignatureAlgorithm}
#{Security.DolphinSureCertificate}
Expand All @@ -51,21 +49,14 @@ package setMethodNames: #(
#(#{Kernel.SourceManager} #secureFileItIn:)
).

package setVariableNames: #(
#{OS.BCrypt}
).

package setBinaryVariableNames: #(
#{OS.BCrypt}
).

package setPrerequisites: #(
'..\Base\Dolphin'
'..\System\Filer\Dolphin Binary Filer (Old versions)'
'..\Base\Dolphin Legacy Date & Time'
'..\System\Random\Dolphin Random Stream'
'..\Registry\Dolphin Registry Access'
'..\System\Filer\Dolphin Validating Binary Filer'
'..\System\Win32\CNG\Windows Crypto NG'
).
package!
Expand All @@ -80,63 +71,6 @@ Kernel.Namespace
classInstanceVariableNames: ''
classConstants: {}!
Kernel.SharedPool
subclass: #'OS.BCryptConstants'
instanceVariableNames: ''
classVariableNames: ''
imports: #()
classInstanceVariableNames: ''
classConstants: {
'BCRYPT_3DES_112_ALGORITHM' -> '3DES_112'.
'BCRYPT_3DES_ALGORITHM' -> '3DES'.
'BCRYPT_AES_ALGORITHM' -> 'AES'.
'BCRYPT_AES_CMAC_ALGORITHM' -> 'AES-CMAC'.
'BCRYPT_AES_GMAC_ALGORITHM' -> 'AES-GMAC'.
'BCRYPT_ALGORITHM_NAME' -> 'AlgorithmName'.
'BCRYPT_AUTH_TAG_LENGTH' -> 'AuthTagLength'.
'BCRYPT_BLOCK_LENGTH' -> 'BlockLength'.
'BCRYPT_BLOCK_SIZE_LIST' -> 'BlockSizeList'.
'BCRYPT_CHAINING_MODE' -> 'ChainingMode'.
'BCRYPT_DES_ALGORITHM' -> 'DES'.
'BCRYPT_DESX_ALGORITHM' -> 'DESX'.
'BCRYPT_DH_ALGORITHM' -> 'DH'.
'BCRYPT_DSA_ALGORITHM' -> 'DSA'.
'BCRYPT_ECDH_P256_ALGORITHM' -> 'ECDH_P256'.
'BCRYPT_ECDH_P384_ALGORITHM' -> 'ECDH_P384'.
'BCRYPT_ECDH_P521_ALGORITHM' -> 'ECDH_P521'.
'BCRYPT_ECDSA_P256_ALGORITHM' -> 'ECDSA_P256'.
'BCRYPT_ECDSA_P384_ALGORITHM' -> 'ECDSA_P384'.
'BCRYPT_ECDSA_P521_ALGORITHM' -> 'ECDSA_P521'.
'BCRYPT_EFFECTIVE_KEY_LENGTH' -> 'EffectiveKeyLength'.
'BCRYPT_HASH_BLOCK_LENGTH' -> 'HashBlockLength'.
'BCRYPT_HASH_LENGTH' -> 'HashDigestLength'.
'BCRYPT_HASH_OID_LIST' -> 'HashOIDList'.
'BCRYPT_KEY_LENGTH' -> 'KeyLength'.
'BCRYPT_KEY_LENGTHS' -> 'KeyLengths'.
'BCRYPT_KEY_OBJECT_LENGTH' -> 'KeyObjectLength'.
'BCRYPT_KEY_STRENGTH' -> 'KeyStrength'.
'BCRYPT_MD2_ALGORITHM' -> 'MD2'.
'BCRYPT_MD4_ALGORITHM' -> 'MD4'.
'BCRYPT_MD5_ALGORITHM' -> 'MD5'.
'BCRYPT_OBJECT_LENGTH' -> 'ObjectLength'.
'BCRYPT_PADDING_SCHEMES' -> 'PaddingSchemes'.
'BCRYPT_PROVIDER_HANDLE' -> 'ProviderHandle'.
'BCRYPT_RC2_ALGORITHM' -> 'RC2'.
'BCRYPT_RC4_ALGORITHM' -> 'RC4'.
'BCRYPT_RNG_ALGORITHM' -> 'RNG'.
'BCRYPT_RNG_DUAL_EC_ALGORITHM' -> 'DUALECRNG'.
'BCRYPT_RNG_FIPS186_DSA_ALGORITHM' -> 'FIPS186DSARNG'.
'BCRYPT_RSA_ALGORITHM' -> 'RSA'.
'BCRYPT_RSA_SIGN_ALGORITHM' -> 'RSA_SIGN'.
'BCRYPT_SHA1_ALGORITHM' -> 'SHA1'.
'BCRYPT_SHA1_HASH_SIZE' -> 16r14.
'BCRYPT_SHA256_ALGORITHM' -> 'SHA256'.
'BCRYPT_SHA384_ALGORITHM' -> 'SHA384'.
'BCRYPT_SHA512_ALGORITHM' -> 'SHA512'.
'BCRYPT_SIGNATURE_LENGTH' -> 'SignatureLength'.
'BCRYPT_STATUS_UNSUCCESSFUL' -> 16rC0000001
}!
Core.Object
subclass: #'Security.DigitalSignatureAlgorithm'
instanceVariableNames: 'randKey randSeed'
Expand Down Expand Up @@ -190,9 +124,9 @@ Core.Object
subclass: #'Security.SecureHashAlgorithm'
instanceVariableNames: 'context'
classVariableNames: ''
imports: #()
imports: #(#{OS.BCryptLibrary private})
classInstanceVariableNames: ''
classConstants: {}!
classConstants: { 'StreamBlockSize' -> 16r4000 }!
Security.DolphinSureTrustedData
subclass: #'Security.DolphinSureCertificate'
Expand Down Expand Up @@ -242,14 +176,6 @@ Security.DolphinSureCertificationAuthorityCertificate
classInstanceVariableNames: ''
classConstants: {}!
External.DynamicLinkLibrary
subclass: #'OS.BCryptLibrary'
instanceVariableNames: 'shaAlgorithmHandle'
classVariableNames: ''
imports: #(#{OS.BCryptConstants})
classInstanceVariableNames: ''
classConstants: {}!
Core.Error
subclass: #'Security.NotTrustedError'
instanceVariableNames: ''
Expand Down
65 changes: 0 additions & 65 deletions Core/Object Arts/Dolphin/DolphinSure/OS.BCryptConstants.cls

This file was deleted.

Loading

0 comments on commit b2462c0

Please sign in to comment.