Skip to content

Commit

Permalink
Add initialization, regenerate bindings, bump version (#1)
Browse files Browse the repository at this point in the history
* default inits

* Update bindings/dep versions

* bump version
  • Loading branch information
quinnj authored Jul 13, 2024
1 parent 1db1332 commit c05a74e
Show file tree
Hide file tree
Showing 17 changed files with 677 additions and 163 deletions.
4 changes: 2 additions & 2 deletions Project.toml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
name = "LibAwsCal"
uuid = "ef519ef6-af43-41a0-8ac4-eb81328190af"
version = "1.0.0"
version = "1.1.0"

[deps]
CEnum = "fa961155-64e5-5f13-b03f-caf6b980ea82"
Expand All @@ -11,7 +11,7 @@ aws_c_cal_jll = "70f11efc-bab2-57f1-b0f3-22aad4e67c4b"
Aqua = "0.7"
CEnum = "0.5"
LibAwsCommon = "1.0.0"
aws_c_cal_jll = "=0.6.12"
aws_c_cal_jll = "=0.7.1"
julia = "1.6"

[extras]
Expand Down
33 changes: 17 additions & 16 deletions gen/Manifest.toml
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
# This file is machine-generated - editing it directly is not advised

julia_version = "1.10.2"
julia_version = "1.10.4"
manifest_format = "2.0"
project_hash = "87f1dbe46e607de248cd4fed8bb3f83ba32a51ea"
project_hash = "a5163d0c9808df96fbcb781d2c039c2f786b0262"

[[deps.ArgTools]]
uuid = "0dad84c5-d112-42e6-8d28-ef12dabb789f"
Expand Down Expand Up @@ -42,9 +42,9 @@ version = "1.6.0"

[[deps.Expat_jll]]
deps = ["Artifacts", "JLLWrappers", "Libdl"]
git-tree-sha1 = "4558ab818dcceaab612d1bb8c19cee87eda2b83c"
git-tree-sha1 = "1c6317308b9dc757616f0b5cb379db10494443a7"
uuid = "2e619515-83b5-522b-bb60-26c02a35a201"
version = "2.5.0+0"
version = "2.6.2+0"

[[deps.FileWatching]]
uuid = "7b1f6079-737a-58dc-b8bc-7a2ca5c1b5ee"
Expand All @@ -62,19 +62,20 @@ uuid = "f8c6e375-362e-5223-8a59-34ff63f689eb"
version = "2.44.0+2"

[[deps.HistoricalStdlibVersions]]
git-tree-sha1 = "c8b04a26eaa706b4da6968dfc27ae2d030547cba"
deps = ["Pkg"]
git-tree-sha1 = "d50c73e4abd8f7c58eb76a8884dfd531fa8dac81"
uuid = "6df8b67a-e8a0-4029-b4b7-ac196fe72102"
version = "1.2.2"
version = "2.0.0"

[[deps.InteractiveUtils]]
deps = ["Markdown"]
uuid = "b77e0a4c-d291-57a0-90e8-8db25a27a240"

[[deps.JLLPrefixes]]
deps = ["Artifacts", "Git", "HistoricalStdlibVersions", "Pkg", "Preferences", "SHA", "Scratch"]
git-tree-sha1 = "c43b83a688b86b33f5b6d8f48d70a41526d845f8"
git-tree-sha1 = "282d4920f56cb8c39f0a0baa5a834db2e78cc991"
uuid = "afc68a34-7891-4c5a-9da1-1c62935e7b0d"
version = "0.3.5"
version = "0.3.11"

[[deps.JLLWrappers]]
deps = ["Artifacts", "Preferences"]
Expand All @@ -84,9 +85,9 @@ version = "1.5.0"

[[deps.LibAwsCommon]]
deps = ["CEnum", "aws_c_common_jll"]
git-tree-sha1 = "d8705f05415a487369d5bbfb2ca149c72ffb5609"
git-tree-sha1 = "17d34406ecd3c3f16d1ec298b6abf0a110eb88dc"
uuid = "c6e421ba-b5f8-4792-a1c4-42948de3ed9d"
version = "1.0.0"
version = "1.2.0"

[[deps.LibCURL]]
deps = ["LibCURL_jll", "MozillaCACerts_jll"]
Expand Down Expand Up @@ -143,9 +144,9 @@ version = "1.2.0"

[[deps.OpenSSL_jll]]
deps = ["Artifacts", "JLLWrappers", "Libdl"]
git-tree-sha1 = "3da7367955dcc5c54c1ba4d402ccdc09a1a3e046"
git-tree-sha1 = "a028ee3cb5641cccc4c24e90c36b0a4f7707bdf5"
uuid = "458c3c95-2e84-50aa-8efc-19380b2a3a95"
version = "3.0.13+1"
version = "3.0.14+0"

[[deps.PCRE2_jll]]
deps = ["Artifacts", "Libdl"]
Expand Down Expand Up @@ -215,15 +216,15 @@ version = "1.2.13+1"

[[deps.aws_c_cal_jll]]
deps = ["Artifacts", "JLLWrappers", "Libdl", "aws_c_common_jll"]
git-tree-sha1 = "3c554279cdb445fbebdab0b9f9fcc470c6d488b0"
git-tree-sha1 = "71373d35b383c07412eab3e7dabb8901e47e38b3"
uuid = "70f11efc-bab2-57f1-b0f3-22aad4e67c4b"
version = "0.6.12+0"
version = "0.7.1+0"

[[deps.aws_c_common_jll]]
deps = ["Artifacts", "JLLWrappers", "Libdl"]
git-tree-sha1 = "586a1aa2fdda172c45587b52f5329fedde14f44c"
git-tree-sha1 = "68d3a903076819904e9e27d077b59b95fcca44e0"
uuid = "73048d1d-b8c4-5092-a58d-866c5e8d1e50"
version = "0.9.14+0"
version = "0.9.23+0"

[[deps.libLLVM_jll]]
deps = ["Artifacts", "Libdl"]
Expand Down
4 changes: 2 additions & 2 deletions gen/Project.toml
Original file line number Diff line number Diff line change
Expand Up @@ -9,5 +9,5 @@ aws_c_common_jll = "73048d1d-b8c4-5092-a58d-866c5e8d1e50"
Clang = "0.18.3"
JLLPrefixes = "0.3"
LibAwsCommon = "1.0.0"
aws_c_cal_jll = "=0.6.12"
aws_c_common_jll = "=0.9.14"
aws_c_cal_jll = "=0.7.1"
aws_c_common_jll = "=0.9.23"
61 changes: 50 additions & 11 deletions lib/aarch64-apple-darwin20.jl
Original file line number Diff line number Diff line change
Expand Up @@ -932,7 +932,7 @@ Documentation not found.
"""
const aws_aes_ctr_256_new_fn = Cvoid

# typedef struct aws_symmetric_cipher * ( aws_aes_gcm_256_new_fn ) ( struct aws_allocator * allocator , const struct aws_byte_cursor * key , const struct aws_byte_cursor * iv , const struct aws_byte_cursor * aad , const struct aws_byte_cursor * decryption_tag )
# typedef struct aws_symmetric_cipher * ( aws_aes_gcm_256_new_fn ) ( struct aws_allocator * allocator , const struct aws_byte_cursor * key , const struct aws_byte_cursor * iv , const struct aws_byte_cursor * aad )
"""
Documentation not found.
"""
Expand All @@ -944,6 +944,17 @@ Documentation not found.
"""
const aws_aes_keywrap_256_new_fn = Cvoid

"""
aws_symmetric_cipher_state
Documentation not found.
"""
@cenum aws_symmetric_cipher_state::UInt32 begin
AWS_SYMMETRIC_CIPHER_READY = 0
AWS_SYMMETRIC_CIPHER_FINALIZED = 1
AWS_SYMMETRIC_CIPHER_ERROR = 2
end

"""
aws_aes_cbc_256_new(allocator, key, iv)
Expand Down Expand Up @@ -989,31 +1000,29 @@ function aws_aes_ctr_256_new(allocator, key, iv)
end

"""
aws_aes_gcm_256_new(allocator, key, iv, aad, decryption_tag)
aws_aes_gcm_256_new(allocator, key, iv, aad)
Creates an instance of AES GCM with 256-bit key. If key, iv are NULL, they will be generated internally. You can get the generated key and iv back by calling:
[`aws_symmetric_cipher_get_key`](@ref)() and [`aws_symmetric_cipher_get_initialization_vector`](@ref)()
respectively.
If they are set, that key and iv will be copied internally and used by the cipher.
If tag and aad are set they will be copied internally and used by the cipher. decryption\\_tag would most likely be used for a decrypt operation to detect tampering or corruption. The Tag for the most recent encrypt operation will be available in:
If aad is set it will be copied and applied to the cipher.
[`aws_symmetric_cipher_get_tag`](@ref)()
If they are set, that key and iv will be copied internally and used by the cipher.
If aad is set it will be copied and applied to the cipher.
For decryption purposes tag can be provided via [`aws_symmetric_cipher_set_tag`](@ref) method. Note: for decrypt operations, tag must be provided before first decrypt is called. (this is a windows bcrypt limitations, but for consistency sake same limitation is extended to other platforms) Tag generated during encryption can be retrieved using [`aws_symmetric_cipher_get_tag`](@ref) method after finalize is called.
Returns NULL on failure. You can check aws\\_last\\_error() to get the error code indicating the failure cause.
### Prototype
```c
struct aws_symmetric_cipher *aws_aes_gcm_256_new( struct aws_allocator *allocator, const struct aws_byte_cursor *key, const struct aws_byte_cursor *iv, const struct aws_byte_cursor *aad, const struct aws_byte_cursor *decryption_tag);
struct aws_symmetric_cipher *aws_aes_gcm_256_new( struct aws_allocator *allocator, const struct aws_byte_cursor *key, const struct aws_byte_cursor *iv, const struct aws_byte_cursor *aad);
```
"""
function aws_aes_gcm_256_new(allocator, key, iv, aad, decryption_tag)
ccall((:aws_aes_gcm_256_new, libaws_c_cal), Ptr{aws_symmetric_cipher}, (Ptr{aws_allocator}, Ptr{aws_byte_cursor}, Ptr{aws_byte_cursor}, Ptr{aws_byte_cursor}, Ptr{aws_byte_cursor}), allocator, key, iv, aad, decryption_tag)
function aws_aes_gcm_256_new(allocator, key, iv, aad)
ccall((:aws_aes_gcm_256_new, libaws_c_cal), Ptr{aws_symmetric_cipher}, (Ptr{aws_allocator}, Ptr{aws_byte_cursor}, Ptr{aws_byte_cursor}, Ptr{aws_byte_cursor}), allocator, key, iv, aad)
end

"""
Expand Down Expand Up @@ -1121,7 +1130,9 @@ end
"""
aws_symmetric_cipher_reset(cipher)
Resets the cipher state for starting a new encrypt or decrypt operation. Note encrypt/decrypt cannot be mixed on the same cipher without a call to reset in between them. However, this leaves the key, iv etc... materials setup for immediate reuse.
Resets the cipher state for starting a new encrypt or decrypt operation. Note encrypt/decrypt cannot be mixed on the same cipher without a call to reset in between them. However, this leaves the key, iv etc... materials setup for immediate reuse. Note: GCM tag is not preserved between operations. If you intend to do encrypt followed directly by decrypt, make sure to make a copy of tag before reseting the cipher and pass that copy for decryption.
Warning: In most cases it's a really bad idea to reset a cipher and perform another operation using that cipher. Key and IV should not be reused for different operations. Instead of reseting the cipher, destroy the cipher and create new one with a new key/iv pair. Use reset at your own risk, and only after careful consideration.
returns AWS\\_OP\\_SUCCESS on success. Call aws\\_last\\_error() to determine the failure cause if it returns AWS\\_OP\\_ERR;
Expand Down Expand Up @@ -1150,6 +1161,20 @@ function aws_symmetric_cipher_get_tag(cipher)
ccall((:aws_symmetric_cipher_get_tag, libaws_c_cal), aws_byte_cursor, (Ptr{aws_symmetric_cipher},), cipher)
end

"""
aws_symmetric_cipher_set_tag(cipher, tag)
Sets the GMAC tag on the cipher. Does nothing for ciphers that do not support tag.
### Prototype
```c
void aws_symmetric_cipher_set_tag(struct aws_symmetric_cipher *cipher, struct aws_byte_cursor tag);
```
"""
function aws_symmetric_cipher_set_tag(cipher, tag)
ccall((:aws_symmetric_cipher_set_tag, libaws_c_cal), Cvoid, (Ptr{aws_symmetric_cipher}, aws_byte_cursor), cipher, tag)
end

"""
aws_symmetric_cipher_get_initialization_vector(cipher)
Expand Down Expand Up @@ -1200,6 +1225,20 @@ function aws_symmetric_cipher_is_good(cipher)
ccall((:aws_symmetric_cipher_is_good, libaws_c_cal), Bool, (Ptr{aws_symmetric_cipher},), cipher)
end

"""
aws_symmetric_cipher_get_state(cipher)
Retuns the current state of the cipher. Ther state of the cipher can be ready for use, finalized, or has encountered an error. if the cipher is in a finished or error state, it must be reset before further use.
### Prototype
```c
enum aws_symmetric_cipher_state aws_symmetric_cipher_get_state(const struct aws_symmetric_cipher *cipher);
```
"""
function aws_symmetric_cipher_get_state(cipher)
ccall((:aws_symmetric_cipher_get_state, libaws_c_cal), aws_symmetric_cipher_state, (Ptr{aws_symmetric_cipher},), cipher)
end

"""
Documentation not found.
"""
Expand Down
61 changes: 50 additions & 11 deletions lib/aarch64-linux-gnu.jl
Original file line number Diff line number Diff line change
Expand Up @@ -932,7 +932,7 @@ Documentation not found.
"""
const aws_aes_ctr_256_new_fn = Cvoid

# typedef struct aws_symmetric_cipher * ( aws_aes_gcm_256_new_fn ) ( struct aws_allocator * allocator , const struct aws_byte_cursor * key , const struct aws_byte_cursor * iv , const struct aws_byte_cursor * aad , const struct aws_byte_cursor * decryption_tag )
# typedef struct aws_symmetric_cipher * ( aws_aes_gcm_256_new_fn ) ( struct aws_allocator * allocator , const struct aws_byte_cursor * key , const struct aws_byte_cursor * iv , const struct aws_byte_cursor * aad )
"""
Documentation not found.
"""
Expand All @@ -944,6 +944,17 @@ Documentation not found.
"""
const aws_aes_keywrap_256_new_fn = Cvoid

"""
aws_symmetric_cipher_state
Documentation not found.
"""
@cenum aws_symmetric_cipher_state::UInt32 begin
AWS_SYMMETRIC_CIPHER_READY = 0
AWS_SYMMETRIC_CIPHER_FINALIZED = 1
AWS_SYMMETRIC_CIPHER_ERROR = 2
end

"""
aws_aes_cbc_256_new(allocator, key, iv)
Expand Down Expand Up @@ -989,31 +1000,29 @@ function aws_aes_ctr_256_new(allocator, key, iv)
end

"""
aws_aes_gcm_256_new(allocator, key, iv, aad, decryption_tag)
aws_aes_gcm_256_new(allocator, key, iv, aad)
Creates an instance of AES GCM with 256-bit key. If key, iv are NULL, they will be generated internally. You can get the generated key and iv back by calling:
[`aws_symmetric_cipher_get_key`](@ref)() and [`aws_symmetric_cipher_get_initialization_vector`](@ref)()
respectively.
If they are set, that key and iv will be copied internally and used by the cipher.
If tag and aad are set they will be copied internally and used by the cipher. decryption\\_tag would most likely be used for a decrypt operation to detect tampering or corruption. The Tag for the most recent encrypt operation will be available in:
If aad is set it will be copied and applied to the cipher.
[`aws_symmetric_cipher_get_tag`](@ref)()
If they are set, that key and iv will be copied internally and used by the cipher.
If aad is set it will be copied and applied to the cipher.
For decryption purposes tag can be provided via [`aws_symmetric_cipher_set_tag`](@ref) method. Note: for decrypt operations, tag must be provided before first decrypt is called. (this is a windows bcrypt limitations, but for consistency sake same limitation is extended to other platforms) Tag generated during encryption can be retrieved using [`aws_symmetric_cipher_get_tag`](@ref) method after finalize is called.
Returns NULL on failure. You can check aws\\_last\\_error() to get the error code indicating the failure cause.
### Prototype
```c
struct aws_symmetric_cipher *aws_aes_gcm_256_new( struct aws_allocator *allocator, const struct aws_byte_cursor *key, const struct aws_byte_cursor *iv, const struct aws_byte_cursor *aad, const struct aws_byte_cursor *decryption_tag);
struct aws_symmetric_cipher *aws_aes_gcm_256_new( struct aws_allocator *allocator, const struct aws_byte_cursor *key, const struct aws_byte_cursor *iv, const struct aws_byte_cursor *aad);
```
"""
function aws_aes_gcm_256_new(allocator, key, iv, aad, decryption_tag)
ccall((:aws_aes_gcm_256_new, libaws_c_cal), Ptr{aws_symmetric_cipher}, (Ptr{aws_allocator}, Ptr{aws_byte_cursor}, Ptr{aws_byte_cursor}, Ptr{aws_byte_cursor}, Ptr{aws_byte_cursor}), allocator, key, iv, aad, decryption_tag)
function aws_aes_gcm_256_new(allocator, key, iv, aad)
ccall((:aws_aes_gcm_256_new, libaws_c_cal), Ptr{aws_symmetric_cipher}, (Ptr{aws_allocator}, Ptr{aws_byte_cursor}, Ptr{aws_byte_cursor}, Ptr{aws_byte_cursor}), allocator, key, iv, aad)
end

"""
Expand Down Expand Up @@ -1121,7 +1130,9 @@ end
"""
aws_symmetric_cipher_reset(cipher)
Resets the cipher state for starting a new encrypt or decrypt operation. Note encrypt/decrypt cannot be mixed on the same cipher without a call to reset in between them. However, this leaves the key, iv etc... materials setup for immediate reuse.
Resets the cipher state for starting a new encrypt or decrypt operation. Note encrypt/decrypt cannot be mixed on the same cipher without a call to reset in between them. However, this leaves the key, iv etc... materials setup for immediate reuse. Note: GCM tag is not preserved between operations. If you intend to do encrypt followed directly by decrypt, make sure to make a copy of tag before reseting the cipher and pass that copy for decryption.
Warning: In most cases it's a really bad idea to reset a cipher and perform another operation using that cipher. Key and IV should not be reused for different operations. Instead of reseting the cipher, destroy the cipher and create new one with a new key/iv pair. Use reset at your own risk, and only after careful consideration.
returns AWS\\_OP\\_SUCCESS on success. Call aws\\_last\\_error() to determine the failure cause if it returns AWS\\_OP\\_ERR;
Expand Down Expand Up @@ -1150,6 +1161,20 @@ function aws_symmetric_cipher_get_tag(cipher)
ccall((:aws_symmetric_cipher_get_tag, libaws_c_cal), aws_byte_cursor, (Ptr{aws_symmetric_cipher},), cipher)
end

"""
aws_symmetric_cipher_set_tag(cipher, tag)
Sets the GMAC tag on the cipher. Does nothing for ciphers that do not support tag.
### Prototype
```c
void aws_symmetric_cipher_set_tag(struct aws_symmetric_cipher *cipher, struct aws_byte_cursor tag);
```
"""
function aws_symmetric_cipher_set_tag(cipher, tag)
ccall((:aws_symmetric_cipher_set_tag, libaws_c_cal), Cvoid, (Ptr{aws_symmetric_cipher}, aws_byte_cursor), cipher, tag)
end

"""
aws_symmetric_cipher_get_initialization_vector(cipher)
Expand Down Expand Up @@ -1200,6 +1225,20 @@ function aws_symmetric_cipher_is_good(cipher)
ccall((:aws_symmetric_cipher_is_good, libaws_c_cal), Bool, (Ptr{aws_symmetric_cipher},), cipher)
end

"""
aws_symmetric_cipher_get_state(cipher)
Retuns the current state of the cipher. Ther state of the cipher can be ready for use, finalized, or has encountered an error. if the cipher is in a finished or error state, it must be reset before further use.
### Prototype
```c
enum aws_symmetric_cipher_state aws_symmetric_cipher_get_state(const struct aws_symmetric_cipher *cipher);
```
"""
function aws_symmetric_cipher_get_state(cipher)
ccall((:aws_symmetric_cipher_get_state, libaws_c_cal), aws_symmetric_cipher_state, (Ptr{aws_symmetric_cipher},), cipher)
end

"""
Documentation not found.
"""
Expand Down
Loading

2 comments on commit c05a74e

@quinnj
Copy link
Member Author

@quinnj quinnj commented on c05a74e Jul 13, 2024

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@JuliaRegistrator register()

@JuliaRegistrator
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Registration pull request created: JuliaRegistries/General/111030

Tip: Release Notes

Did you know you can add release notes too? Just add markdown formatted text underneath the comment after the text
"Release notes:" and it will be added to the registry PR, and if TagBot is installed it will also be added to the
release that TagBot creates. i.e.

@JuliaRegistrator register

Release notes:

## Breaking changes

- blah

To add them here just re-invoke and the PR will be updated.

Tagging

After the above pull request is merged, it is recommended that a tag is created on this repository for the registered package version.

This will be done automatically if the Julia TagBot GitHub Action is installed, or can be done manually through the github interface, or via:

git tag -a v1.1.0 -m "<description of version>" c05a74e15dbdeae9a1acdc6d118033b70fdd16bb
git push origin v1.1.0

Please sign in to comment.