Many hyperlinks are disabled.
Use anonymous login
to enable hyperlinks.
Overview
Comment: | Pickup updated 'shathree' extension from SQLite trunk again. |
---|---|
Downloads: | Tarball | ZIP archive |
Timelines: | family | ancestors | descendants | both | trunk |
Files: | files | file ages | folders |
SHA1: |
d90f7278476baa62b1d77a4c5556f117 |
User & Date: | mistachkin 2024-08-15 18:32:05.582 |
Context
2024-08-15
| ||
18:38 | Update Eagle in externals to the beta 55 release. check-in: a5cd0b0321 user: mistachkin tags: trunk | |
18:32 | Pickup updated 'shathree' extension from SQLite trunk again. check-in: d90f727847 user: mistachkin tags: trunk | |
2024-08-13
| ||
22:39 | Pickup updated 'shathree' extension from SQLite trunk. check-in: 3f1d88a125 user: mistachkin tags: trunk | |
Changes
Changes to SQLite.Interop/src/ext/shathree.c.
︙ | ︙ | |||
11 12 13 14 15 16 17 | ****************************************************************************** ** ** This SQLite extension implements functions that compute SHA3 hashes ** in the way described by the (U.S.) NIST FIPS 202 SHA-3 Standard. ** Two SQL functions are implemented: ** ** sha3(X,SIZE) | > | | > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > | 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 | ****************************************************************************** ** ** This SQLite extension implements functions that compute SHA3 hashes ** in the way described by the (U.S.) NIST FIPS 202 SHA-3 Standard. ** Two SQL functions are implemented: ** ** sha3(X,SIZE) ** sha3_agg(Y,SIZE) ** sha3_query(Z,SIZE) ** ** The sha3(X) function computes the SHA3 hash of the input X, or NULL if ** X is NULL. If inputs X is text, the UTF-8 rendering of that text is ** used to compute the hash. If X is a BLOB, then the binary data of the ** blob is used to compute the hash. If X is an integer or real number, ** then that number if converted into UTF-8 text and the hash is computed ** over the text. ** ** The sha3_agg(Y) function computes the SHA3 hash of all Y inputs. Since ** order is important for the hash, it is recommended that the Y expression ** by followed by an ORDER BY clause to guarantee that the inputs occur ** in the desired order. ** ** The sha3_query(Y) function evaluates all queries in the SQL statements of Y ** and returns a hash of their results. ** ** The SIZE argument is optional. If omitted, the SHA3-256 hash algorithm ** is used. If SIZE is included it must be one of the integers 224, 256, ** 384, or 512, to determine SHA3 hash variant that is computed. ** ** Because the sha3_agg() and sha3_query() functions compute a hash over ** multiple values, the values are encode to use include type information. ** ** In sha3_agg(), the sequence of bytes that gets hashed for each input ** Y depends on the datatype of Y: ** ** typeof(Y)='null' A single "N" is hashed. (One byte) ** ** typeof(Y)='integer' The data hash is the character "I" followed ** by an 8-byte big-endian binary of the ** 64-bit signed integer. (Nine bytes total.) ** ** typeof(Y)='real' The character "F" followed by an 8-byte ** big-ending binary of the double. (Nine ** bytes total.) ** ** typeof(Y)='text' The hash is over prefix "Tnnn:" followed ** by the UTF8 encoding of the text. The "nnn" ** in the prefix is the minimum-length decimal ** representation of the octet_length of the text. ** Notice the ":" at the end of the prefix, which ** is needed to separate the prefix from the ** content in cases where the content starts ** with a digit. ** ** typeof(Y)='blob' The hash is taken over prefix "Bnnn:" followed ** by the binary content of the blob. The "nnn" ** in the prefix is the mimimum-length decimal ** representation of the byte-length of the blob. ** ** According to the rules above, all of the following SELECT statements ** should return TRUE: ** ** SELECT sha3(1) = sha3('1'); ** ** SELECT sha3('hello') = sha3(x'68656c6c6f'); ** ** WITH a(x) AS (VALUES('xyzzy')) ** SELECT sha3_agg(x) = sha3('T5:xyzzy') FROM a; ** ** WITH a(x) AS (VALUES(x'010203')) ** SELECT sha3_agg(x) = sha3(x'42333a010203') FROM a; ** ** WITH a(x) AS (VALUES(0x123456)) ** SELECT sha3_agg(x) = sha3(x'490000000000123456') FROM a; ** ** WITH a(x) AS (VALUES(100.015625)) ** SELECT sha3_agg(x) = sha3(x'464059010000000000') FROM a; ** ** WITH a(x) AS (VALUES(NULL)) ** SELECT sha3_agg(x) = sha3('N') FROM a; ** ** ** In sha3_query(), individual column values are encoded as with ** sha3_agg(), but with the addition that a single "R" character is ** inserted at the start of each row. ** ** Note that sha3_agg() hashes rows for which Y is NULL. Add a FILTER ** clause if NULL rows should be excluded: ** ** SELECT sha3_agg(x ORDER BY rowid) FILTER(WHERE x NOT NULL) FROM t1; */ #include "sqlite3ext.h" SQLITE_EXTENSION_INIT1 #include <assert.h> #include <string.h> #include <stdarg.h> |
︙ | ︙ |