-
Notifications
You must be signed in to change notification settings - Fork 1
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Refactor bits/bytes conversion #45
Conversation
3b4282e
to
2b3ed69
Compare
2b3ed69
to
4c72387
Compare
4c72387
to
fc4f3d6
Compare
@@ -86,7 +86,7 @@ func (akgp *AESKeyGenParams) GenerateKey( | |||
key.Type = SecretCryptoKeyType | |||
key.Algorithm = AESKeyAlgorithm{ | |||
Algorithm: akgp.Algorithm, | |||
Length: akgp.Length, | |||
Length: int64(akgp.Length), |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Can we change that Length
field as well?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
To the best of my knowledge, unfortunately not. The reason is that as soon as you use bitLength
as a type for the Length
attribute the AesKeyAlgorithm
type, then its value is treated as an object
by Goja, not a number
, which leads the test suite to fail. I have noticed this behavior before, hence some of the type mappings that exist are actual type aliases type mytype = string
. However, in that case, we can't really do that, as we wouldn't be able to have methods on type aliases.
fc4f3d6
to
b96901b
Compare
This PR address #36 and introduces two new type aliases:
bitLength
andbyteLength
helping make conversion from bytes length to bits and vice versa, more explicit, readable, and less error prone.closes #36