-
Notifications
You must be signed in to change notification settings - Fork 3.8k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
105654: builtins: implement encrypt and decrypt pgcrypto functions r=rafiss a=andyyang890 This patch implements `encrypt`, `encrypt_iv`, `decrypt`, and `decrypt_iv` from pgcrypto. These functions require an enterprise license on a CCL distribution. Informs #21001 Release note (enterprise change): The pgcrypto functions `encrypt`, `encrypt_iv`, `decrypt`, and `decrypt_iv` are now implemented. These functions require an enterprise license on a CCL distribution. 109782: server,sql: add status server endpoint to request profiler details r=dt a=adityamaru This change introduces a new status server endpoint to request job profiler details. This endpoint will redirect the request to the current coordinator node of the job in question. This will be useful because in a followup we will load the resumer from the coordinator node's job registry and trigger its specific job profiler detail collection logic. This is the first step of a few to move to a "fetch model" rather than have each resumer dump their execution details at some arbitrary cadence. The core logic involved in collecting profiler details has not changed, it has been moved in its entirety from pkg/sql to pkg/server. The `crdb_internal.request_job_execution_details` builtin now resolves the job's coordinator ID and calls the new status server endpoint. Informs: #109671 Release note: None Co-authored-by: Andy Yang <[email protected]> Co-authored-by: adityamaru <[email protected]>
- Loading branch information
Showing
55 changed files
with
1,409 additions
and
190 deletions.
There are no files selected for viewing
Validating CODEOWNERS rules …
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
136 changes: 136 additions & 0 deletions
136
pkg/ccl/logictestccl/testdata/logic_test/pgcrypto_builtins
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,136 @@ | ||
subtest encrypt_decrypt_aes_128 | ||
|
||
query T | ||
SELECT encrypt('abc', '16_byte_long_key', 'aes')::STRING | ||
---- | ||
\x0026cd6206cfd92140883b75c098d613 | ||
|
||
query T | ||
SELECT decrypt('\x0026cd6206cfd92140883b75c098d613', '16_byte_long_key', 'aes') | ||
---- | ||
abc | ||
|
||
subtest end | ||
|
||
subtest encrypt_decrypt_aes_192 | ||
|
||
query T | ||
SELECT encrypt('abc', '24_byte_looooooooong_key', 'aes')::STRING | ||
---- | ||
\x6c42e2269a65d605ecd98b2aeb8eb4e9 | ||
|
||
query T | ||
SELECT decrypt('\x6c42e2269a65d605ecd98b2aeb8eb4e9', '24_byte_looooooooong_key', 'aes') | ||
---- | ||
abc | ||
|
||
subtest end | ||
|
||
subtest encrypt_decrypt_aes_256 | ||
|
||
query T | ||
SELECT encrypt('abc', '32_byte_looooooooooooooooong_key', 'aes')::STRING | ||
---- | ||
\xb368f7d6adcd73633dc37696b068cfda | ||
|
||
query T | ||
SELECT decrypt('\xb368f7d6adcd73633dc37696b068cfda', '32_byte_looooooooooooooooong_key', 'aes') | ||
---- | ||
abc | ||
|
||
subtest end | ||
|
||
subtest encrypt_decrypt_aes_multi_block_data | ||
|
||
query T | ||
SELECT encrypt('abcdefghijklmnopqrstuvwxyz', 'key', 'aes')::STRING | ||
---- | ||
\x4649e8618af65b2b50aa73ec9cfc102c95fcbbaf04cb8a82333e493dc97060f3 | ||
|
||
query T | ||
SELECT decrypt('\x4649e8618af65b2b50aa73ec9cfc102c95fcbbaf04cb8a82333e493dc97060f3', 'key', 'aes') | ||
---- | ||
abcdefghijklmnopqrstuvwxyz | ||
|
||
subtest end | ||
|
||
subtest encrypt_decrypt_aes_no_padding | ||
|
||
query T | ||
SELECT encrypt('16byte_long_data', 'key', 'aes/pad:none')::STRING | ||
---- | ||
\x043db9c657e2a2cd693b4239a3d8a1cb | ||
|
||
query T | ||
SELECT decrypt('\x043db9c657e2a2cd693b4239a3d8a1cb', 'key', 'aes/pad:none') | ||
---- | ||
16byte_long_data | ||
|
||
subtest end | ||
|
||
subtest encrypt_decrypt_iv_aes | ||
|
||
query T | ||
SELECT encrypt_iv('abc', 'key', '123', 'aes')::STRING | ||
---- | ||
\x91b4ef63852013c8da53829da662b871 | ||
|
||
query T | ||
SELECT decrypt_iv('\x91b4ef63852013c8da53829da662b871', 'key', '123', 'aes') | ||
---- | ||
abc | ||
|
||
subtest end | ||
|
||
subtest encrypt_error | ||
|
||
query error pgcode 0A000 Blowfish is insecure and not supported | ||
SELECT encrypt('abc', 'key', 'bf') | ||
|
||
query error pgcode 0A000 ECB mode is insecure and not supported | ||
SELECT encrypt('abc', 'key', 'aes-ecb') | ||
|
||
query error pgcode 22023 cipher method has wrong format: "aes/pad=pkcs" | ||
SELECT encrypt('abc', 'key', 'aes/pad=pkcs') | ||
|
||
query error pgcode 22023 cipher method has invalid algorithm: "fakealgo" | ||
SELECT encrypt('abc', 'key', 'fakealgo') | ||
|
||
query error pgcode 22023 cipher method has invalid mode: "ctr" | ||
SELECT encrypt('abc', 'key', 'aes-ctr') | ||
|
||
query error pgcode 22023 cipher method has invalid padding: "zero" | ||
SELECT encrypt('abc', 'key', 'aes/pad:zero') | ||
|
||
query error pgcode 22023 data has length 3, which is not a multiple of block size 16 | ||
SELECT encrypt('abc', 'key', 'aes/pad:none') | ||
|
||
subtest end | ||
|
||
subtest decrypt_error | ||
|
||
query error pgcode 0A000 Blowfish is insecure and not supported | ||
SELECT decrypt('abc', 'key', 'bf') | ||
|
||
query error pgcode 0A000 ECB mode is insecure and not supported | ||
SELECT decrypt('abc', 'key', 'aes-ecb') | ||
|
||
query error pgcode 22023 cipher method has wrong format: "aes/pad=pkcs" | ||
SELECT decrypt('abc', 'key', 'aes/pad=pkcs') | ||
|
||
query error pgcode 22023 cipher method has invalid algorithm: "fakealgo" | ||
SELECT decrypt('abc', 'key', 'fakealgo') | ||
|
||
query error pgcode 22023 cipher method has invalid mode: "ctr" | ||
SELECT decrypt('abc', 'key', 'aes-ctr') | ||
|
||
query error pgcode 22023 cipher method has invalid padding: "zero" | ||
SELECT decrypt('abc', 'key', 'aes/pad:zero') | ||
|
||
query error pgcode 22023 data has length 3, which is not a multiple of block size 16 | ||
SELECT decrypt('abc', 'key', 'aes') | ||
|
||
query error pgcode 22023 data has length 3, which is not a multiple of block size 16 | ||
SELECT decrypt('abc', 'key', 'aes/pad:none') | ||
|
||
subtest end |
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
7 changes: 7 additions & 0 deletions
7
pkg/ccl/logictestccl/tests/fakedist-vec-off/generated_test.go
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
7 changes: 7 additions & 0 deletions
7
pkg/ccl/logictestccl/tests/local-legacy-schema-changer/generated_test.go
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
Oops, something went wrong.