afterpresets 0.1.0 → 0.3.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +6 -4
- package/native-runtime/CMakeLists.txt +82 -0
- package/native-runtime/README.md +40 -0
- package/native-runtime/THIRD_PARTY_NOTICES.md +14 -0
- package/native-runtime/include/ap_native.h +223 -0
- package/native-runtime/src/apply.cpp +199 -0
- package/native-runtime/src/crypto.cpp +225 -0
- package/native-runtime/src/crypto.hpp +51 -0
- package/native-runtime/src/dialog.cpp +62 -0
- package/native-runtime/src/dialog.hpp +35 -0
- package/native-runtime/src/engine.cpp +909 -0
- package/native-runtime/src/engine.hpp +232 -0
- package/native-runtime/src/fsutil.cpp +291 -0
- package/native-runtime/src/fsutil.hpp +57 -0
- package/native-runtime/src/json.cpp +326 -0
- package/native-runtime/src/json.hpp +70 -0
- package/native-runtime/src/platform.hpp +83 -0
- package/native-runtime/src/platform_common.cpp +60 -0
- package/native-runtime/src/platform_mac.mm +314 -0
- package/native-runtime/src/platform_win.cpp +277 -0
- package/native-runtime/src/runtime.cpp +473 -0
- package/native-runtime/src/util.cpp +169 -0
- package/native-runtime/src/util.hpp +32 -0
- package/native-runtime/src/zip.cpp +243 -0
- package/native-runtime/src/zip.hpp +58 -0
- package/native-runtime/third_party/monocypher/LICENCE.md +167 -0
- package/native-runtime/third_party/monocypher/monocypher-ed25519.c +500 -0
- package/native-runtime/third_party/monocypher/monocypher-ed25519.h +140 -0
- package/native-runtime/third_party/monocypher/monocypher.c +2956 -0
- package/native-runtime/third_party/monocypher/monocypher.h +321 -0
- package/native-runtime/third_party/tinf/LICENSE +22 -0
- package/native-runtime/third_party/tinf/crc32.c +57 -0
- package/native-runtime/third_party/tinf/tinf.h +140 -0
- package/native-runtime/third_party/tinf/tinflate.c +636 -0
- package/native-runtime/vendor-files.json +39 -0
- package/package.json +6 -3
- package/runtime/docs/cep/host-after-effects.md +57 -0
- package/runtime/docs/cep/host-premiere.md +84 -0
- package/runtime/docs/{host.md → cep/host.md} +42 -16
- package/runtime/docs/{README.md → common/README.md} +10 -8
- package/runtime/docs/{assets.md → common/assets.md} +16 -2
- package/runtime/docs/{licensing.md → common/licensing.md} +1 -1
- package/runtime/docs/{panels.md → common/panels.md} +5 -5
- package/runtime/docs/{storage.md → common/storage.md} +5 -5
- package/runtime/docs/{updates.md → common/updates.md} +1 -1
- package/runtime/docs/native/README.md +44 -0
- package/runtime/docs/native/debugging.md +140 -0
- package/runtime/docs/native/rules.md +402 -0
- package/runtime/docs/native/testing.md +154 -0
- package/runtime/package.json +1 -1
- package/runtime/scripts/ae-sdk-docs/config.js +102 -0
- package/runtime/scripts/ae-sdk-docs/convert.js +430 -0
- package/runtime/scripts/ae-sdk-docs/index.js +314 -0
- package/runtime/scripts/ae-sdk-docs/source.js +205 -0
- package/runtime/scripts/ae-sdk-docs/split.js +170 -0
- package/runtime/scripts/ae-sdk-docs.js +72 -0
- package/runtime/src/host.js +1 -1
- package/runtime/src/updates.js +1 -1
- package/src/api/error-messages.js +1 -1
- package/src/build/build.js +7 -7
- package/src/build/html.js +1 -1
- package/src/build/jsx.js +2 -2
- package/src/build/runtime.js +3 -3
- package/src/check/check.js +3 -3
- package/src/check/native.js +14 -0
- package/src/check/pricing.js +1 -1
- package/src/check/types.js +2 -2
- package/src/cli.js +5 -5
- package/src/commands/add.js +8 -3
- package/src/commands/build.js +8 -2
- package/src/commands/check.js +11 -3
- package/src/commands/dev.js +9 -2
- package/src/commands/docs.js +5 -1
- package/src/commands/init.js +15 -3
- package/src/commands/push.js +5 -2
- package/src/commands/sdk.js +14 -0
- package/src/commands/testers.js +1 -1
- package/src/commands/upgrade.js +2 -2
- package/src/commands/whoami.js +1 -1
- package/src/config.js +1 -1
- package/src/dev/bridge.js +8 -0
- package/src/dev/cep-link.js +1 -1
- package/src/dev/debug-file.js +5 -5
- package/src/dev/native.js +3 -0
- package/src/dev/session.js +4 -3
- package/src/mcp/extendscript.js +10 -7
- package/src/mcp/host-target.js +1 -0
- package/src/mcp/panels.js +1 -1
- package/src/mcp/png.js +1 -0
- package/src/mcp/server.js +2 -2
- package/src/mcp/tools/capture.js +3 -0
- package/src/mcp/tools/host.js +1 -1
- package/src/mcp/tools/native.js +6 -0
- package/src/mcp/tools/panel.js +4 -4
- package/src/mcp/tools/project.js +47 -31
- package/src/mcp/tools/releases.js +23 -20
- package/src/native/build.js +27 -0
- package/src/native/cmake/CMakeLists.txt +88 -0
- package/src/native/cmake/zig-windows.cmake +19 -0
- package/src/native/effect.js +3 -0
- package/src/native/install.js +8 -0
- package/src/native/installers.js +4 -0
- package/src/native/pipl.js +20 -0
- package/src/native/restart.js +2 -0
- package/src/native/sdk.js +8 -0
- package/src/project/add-panel.js +1 -1
- package/src/project/docs.js +3 -1
- package/src/project/manifest.js +3 -2
- package/src/project/project.js +2 -2
- package/src/project/template.js +5 -1
- package/src/prompt.js +1 -1
- package/src/release/installers.js +4 -4
- package/src/release/native.js +3 -0
- package/src/release/package.js +1 -1
- package/src/release/publish.js +1 -1
- package/src/system/run-command.js +1 -1
- package/src/targets.js +1 -0
- package/src/user-config.js +2 -2
- package/template/cep/AGENTS.md +104 -0
- package/template/{README.md → cep/README.md} +16 -11
- package/template/cep/docs/code_guide.md +67 -0
- package/template/cep/docs/initial_setup.md +115 -0
- package/template/cep/docs/release_checklist.md +24 -0
- package/template/{src → cep/src}/features/home/home.html +4 -4
- package/template/{src → cep/src}/features/home/home.js +10 -11
- package/template/{src → cep/src}/shared/lib/host-theme.js +3 -3
- package/template/{src → cep/src}/shared/lib/view.js +1 -1
- package/template/{src → cep/src}/shared/ui/tokens.css +1 -1
- package/template/hosts/AGENTS.two-apps.md +12 -0
- package/template/hosts/aeft/AGENTS.host.md +10 -0
- package/template/hosts/aeft/jsx/aeft/home.jsx +16 -0
- package/template/hosts/ppro/AGENTS.host.md +15 -0
- package/template/hosts/ppro/jsx/ppro/home.jsx +20 -0
- package/template/native/.mcp.json +8 -0
- package/template/native/AGENTS.md +105 -0
- package/template/native/README.md +71 -0
- package/template/native/docs/code_guide.md +72 -0
- package/template/native/docs/initial_setup.md +179 -0
- package/template/native/docs/release_checklist.md +24 -0
- package/template/native/effect.json +16 -0
- package/template/native/gitignore +8 -0
- package/template/native/package.json +14 -0
- package/template/native/src/Effect.cpp +224 -0
- package/template/native/src/License.cpp +95 -0
- package/template/native/src/License.h +29 -0
- package/template/native/src/Render.h +68 -0
- package/vendor/afterpresets-additions/AfterEffects.d.ts +291 -0
- package/vendor/afterpresets-additions/Premiere.d.ts +179 -0
- package/vendor/types-for-adobe/Premiere/24.0/index.d.ts +2567 -0
- package/vendor/types-for-adobe/README.md +8 -4
- package/template/AGENTS.md +0 -168
- package/template/docs/initial_setup.md +0 -69
- package/template/jsx/home.jsx +0 -17
- /package/runtime/docs/{boot.md → common/boot.md} +0 -0
- /package/template/{.mcp.json → cep/.mcp.json} +0 -0
- /package/template/{gitignore → cep/gitignore} +0 -0
- /package/template/{package.json → cep/package.json} +0 -0
- /package/template/{src → cep/src}/features/home/home.css +0 -0
- /package/template/{src → cep/src}/features/license-screen/license-screen.css +0 -0
- /package/template/{src → cep/src}/features/license-screen/license-screen.html +0 -0
- /package/template/{src → cep/src}/features/license-screen/license-screen.js +0 -0
- /package/template/{src → cep/src}/features/update-screen/update-screen.css +0 -0
- /package/template/{src → cep/src}/features/update-screen/update-screen.html +0 -0
- /package/template/{src → cep/src}/features/update-screen/update-screen.js +0 -0
- /package/template/{src → cep/src}/panels/main/index.html +0 -0
- /package/template/{src → cep/src}/panels/main/main.js +0 -0
- /package/template/{src → cep/src}/shared/lib/dom.js +0 -0
- /package/template/{src → cep/src}/shared/lib/markdown.js +0 -0
- /package/template/{src → cep/src}/shared/ui/base.css +0 -0
- /package/template/{src → cep/src}/shared/ui/button.css +0 -0
- /package/template/{src → cep/src}/shared/ui/card.css +0 -0
- /package/template/{src → cep/src}/shared/ui/field.css +0 -0
- /package/template/{src → cep/src}/shared/ui/index.css +0 -0
|
@@ -0,0 +1,321 @@
|
|
|
1
|
+
// Monocypher version 4.0.2
|
|
2
|
+
//
|
|
3
|
+
// This file is dual-licensed. Choose whichever licence you want from
|
|
4
|
+
// the two licences listed below.
|
|
5
|
+
//
|
|
6
|
+
// The first licence is a regular 2-clause BSD licence. The second licence
|
|
7
|
+
// is the CC-0 from Creative Commons. It is intended to release Monocypher
|
|
8
|
+
// to the public domain. The BSD licence serves as a fallback option.
|
|
9
|
+
//
|
|
10
|
+
// SPDX-License-Identifier: BSD-2-Clause OR CC0-1.0
|
|
11
|
+
//
|
|
12
|
+
// ------------------------------------------------------------------------
|
|
13
|
+
//
|
|
14
|
+
// Copyright (c) 2017-2019, Loup Vaillant
|
|
15
|
+
// All rights reserved.
|
|
16
|
+
//
|
|
17
|
+
//
|
|
18
|
+
// Redistribution and use in source and binary forms, with or without
|
|
19
|
+
// modification, are permitted provided that the following conditions are
|
|
20
|
+
// met:
|
|
21
|
+
//
|
|
22
|
+
// 1. Redistributions of source code must retain the above copyright
|
|
23
|
+
// notice, this list of conditions and the following disclaimer.
|
|
24
|
+
//
|
|
25
|
+
// 2. Redistributions in binary form must reproduce the above copyright
|
|
26
|
+
// notice, this list of conditions and the following disclaimer in the
|
|
27
|
+
// documentation and/or other materials provided with the
|
|
28
|
+
// distribution.
|
|
29
|
+
//
|
|
30
|
+
// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
|
|
31
|
+
// "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
|
|
32
|
+
// LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
|
|
33
|
+
// A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
|
|
34
|
+
// HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
|
|
35
|
+
// SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
|
|
36
|
+
// LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
|
|
37
|
+
// DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
|
|
38
|
+
// THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
|
|
39
|
+
// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
|
|
40
|
+
// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
|
41
|
+
//
|
|
42
|
+
// ------------------------------------------------------------------------
|
|
43
|
+
//
|
|
44
|
+
// Written in 2017-2019 by Loup Vaillant
|
|
45
|
+
//
|
|
46
|
+
// To the extent possible under law, the author(s) have dedicated all copyright
|
|
47
|
+
// and related neighboring rights to this software to the public domain
|
|
48
|
+
// worldwide. This software is distributed without any warranty.
|
|
49
|
+
//
|
|
50
|
+
// You should have received a copy of the CC0 Public Domain Dedication along
|
|
51
|
+
// with this software. If not, see
|
|
52
|
+
// <https://creativecommons.org/publicdomain/zero/1.0/>
|
|
53
|
+
|
|
54
|
+
#ifndef MONOCYPHER_H
|
|
55
|
+
#define MONOCYPHER_H
|
|
56
|
+
|
|
57
|
+
#include <stddef.h>
|
|
58
|
+
#include <stdint.h>
|
|
59
|
+
|
|
60
|
+
#ifdef MONOCYPHER_CPP_NAMESPACE
|
|
61
|
+
namespace MONOCYPHER_CPP_NAMESPACE {
|
|
62
|
+
#elif defined(__cplusplus)
|
|
63
|
+
extern "C" {
|
|
64
|
+
#endif
|
|
65
|
+
|
|
66
|
+
// Constant time comparisons
|
|
67
|
+
// -------------------------
|
|
68
|
+
|
|
69
|
+
// Return 0 if a and b are equal, -1 otherwise
|
|
70
|
+
int crypto_verify16(const uint8_t a[16], const uint8_t b[16]);
|
|
71
|
+
int crypto_verify32(const uint8_t a[32], const uint8_t b[32]);
|
|
72
|
+
int crypto_verify64(const uint8_t a[64], const uint8_t b[64]);
|
|
73
|
+
|
|
74
|
+
|
|
75
|
+
// Erase sensitive data
|
|
76
|
+
// --------------------
|
|
77
|
+
void crypto_wipe(void *secret, size_t size);
|
|
78
|
+
|
|
79
|
+
|
|
80
|
+
// Authenticated encryption
|
|
81
|
+
// ------------------------
|
|
82
|
+
void crypto_aead_lock(uint8_t *cipher_text,
|
|
83
|
+
uint8_t mac [16],
|
|
84
|
+
const uint8_t key [32],
|
|
85
|
+
const uint8_t nonce[24],
|
|
86
|
+
const uint8_t *ad, size_t ad_size,
|
|
87
|
+
const uint8_t *plain_text, size_t text_size);
|
|
88
|
+
int crypto_aead_unlock(uint8_t *plain_text,
|
|
89
|
+
const uint8_t mac [16],
|
|
90
|
+
const uint8_t key [32],
|
|
91
|
+
const uint8_t nonce[24],
|
|
92
|
+
const uint8_t *ad, size_t ad_size,
|
|
93
|
+
const uint8_t *cipher_text, size_t text_size);
|
|
94
|
+
|
|
95
|
+
// Authenticated stream
|
|
96
|
+
// --------------------
|
|
97
|
+
typedef struct {
|
|
98
|
+
uint64_t counter;
|
|
99
|
+
uint8_t key[32];
|
|
100
|
+
uint8_t nonce[8];
|
|
101
|
+
} crypto_aead_ctx;
|
|
102
|
+
|
|
103
|
+
void crypto_aead_init_x(crypto_aead_ctx *ctx,
|
|
104
|
+
const uint8_t key[32], const uint8_t nonce[24]);
|
|
105
|
+
void crypto_aead_init_djb(crypto_aead_ctx *ctx,
|
|
106
|
+
const uint8_t key[32], const uint8_t nonce[8]);
|
|
107
|
+
void crypto_aead_init_ietf(crypto_aead_ctx *ctx,
|
|
108
|
+
const uint8_t key[32], const uint8_t nonce[12]);
|
|
109
|
+
|
|
110
|
+
void crypto_aead_write(crypto_aead_ctx *ctx,
|
|
111
|
+
uint8_t *cipher_text,
|
|
112
|
+
uint8_t mac[16],
|
|
113
|
+
const uint8_t *ad , size_t ad_size,
|
|
114
|
+
const uint8_t *plain_text, size_t text_size);
|
|
115
|
+
int crypto_aead_read(crypto_aead_ctx *ctx,
|
|
116
|
+
uint8_t *plain_text,
|
|
117
|
+
const uint8_t mac[16],
|
|
118
|
+
const uint8_t *ad , size_t ad_size,
|
|
119
|
+
const uint8_t *cipher_text, size_t text_size);
|
|
120
|
+
|
|
121
|
+
|
|
122
|
+
// General purpose hash (BLAKE2b)
|
|
123
|
+
// ------------------------------
|
|
124
|
+
|
|
125
|
+
// Direct interface
|
|
126
|
+
void crypto_blake2b(uint8_t *hash, size_t hash_size,
|
|
127
|
+
const uint8_t *message, size_t message_size);
|
|
128
|
+
|
|
129
|
+
void crypto_blake2b_keyed(uint8_t *hash, size_t hash_size,
|
|
130
|
+
const uint8_t *key, size_t key_size,
|
|
131
|
+
const uint8_t *message, size_t message_size);
|
|
132
|
+
|
|
133
|
+
// Incremental interface
|
|
134
|
+
typedef struct {
|
|
135
|
+
// Do not rely on the size or contents of this type,
|
|
136
|
+
// for they may change without notice.
|
|
137
|
+
uint64_t hash[8];
|
|
138
|
+
uint64_t input_offset[2];
|
|
139
|
+
uint64_t input[16];
|
|
140
|
+
size_t input_idx;
|
|
141
|
+
size_t hash_size;
|
|
142
|
+
} crypto_blake2b_ctx;
|
|
143
|
+
|
|
144
|
+
void crypto_blake2b_init(crypto_blake2b_ctx *ctx, size_t hash_size);
|
|
145
|
+
void crypto_blake2b_keyed_init(crypto_blake2b_ctx *ctx, size_t hash_size,
|
|
146
|
+
const uint8_t *key, size_t key_size);
|
|
147
|
+
void crypto_blake2b_update(crypto_blake2b_ctx *ctx,
|
|
148
|
+
const uint8_t *message, size_t message_size);
|
|
149
|
+
void crypto_blake2b_final(crypto_blake2b_ctx *ctx, uint8_t *hash);
|
|
150
|
+
|
|
151
|
+
|
|
152
|
+
// Password key derivation (Argon2)
|
|
153
|
+
// --------------------------------
|
|
154
|
+
#define CRYPTO_ARGON2_D 0
|
|
155
|
+
#define CRYPTO_ARGON2_I 1
|
|
156
|
+
#define CRYPTO_ARGON2_ID 2
|
|
157
|
+
|
|
158
|
+
typedef struct {
|
|
159
|
+
uint32_t algorithm; // Argon2d, Argon2i, Argon2id
|
|
160
|
+
uint32_t nb_blocks; // memory hardness, >= 8 * nb_lanes
|
|
161
|
+
uint32_t nb_passes; // CPU hardness, >= 1 (>= 3 recommended for Argon2i)
|
|
162
|
+
uint32_t nb_lanes; // parallelism level (single threaded anyway)
|
|
163
|
+
} crypto_argon2_config;
|
|
164
|
+
|
|
165
|
+
typedef struct {
|
|
166
|
+
const uint8_t *pass;
|
|
167
|
+
const uint8_t *salt;
|
|
168
|
+
uint32_t pass_size;
|
|
169
|
+
uint32_t salt_size; // 16 bytes recommended
|
|
170
|
+
} crypto_argon2_inputs;
|
|
171
|
+
|
|
172
|
+
typedef struct {
|
|
173
|
+
const uint8_t *key; // may be NULL if no key
|
|
174
|
+
const uint8_t *ad; // may be NULL if no additional data
|
|
175
|
+
uint32_t key_size; // 0 if no key (32 bytes recommended otherwise)
|
|
176
|
+
uint32_t ad_size; // 0 if no additional data
|
|
177
|
+
} crypto_argon2_extras;
|
|
178
|
+
|
|
179
|
+
extern const crypto_argon2_extras crypto_argon2_no_extras;
|
|
180
|
+
|
|
181
|
+
void crypto_argon2(uint8_t *hash, uint32_t hash_size, void *work_area,
|
|
182
|
+
crypto_argon2_config config,
|
|
183
|
+
crypto_argon2_inputs inputs,
|
|
184
|
+
crypto_argon2_extras extras);
|
|
185
|
+
|
|
186
|
+
|
|
187
|
+
// Key exchange (X-25519)
|
|
188
|
+
// ----------------------
|
|
189
|
+
|
|
190
|
+
// Shared secrets are not quite random.
|
|
191
|
+
// Hash them to derive an actual shared key.
|
|
192
|
+
void crypto_x25519_public_key(uint8_t public_key[32],
|
|
193
|
+
const uint8_t secret_key[32]);
|
|
194
|
+
void crypto_x25519(uint8_t raw_shared_secret[32],
|
|
195
|
+
const uint8_t your_secret_key [32],
|
|
196
|
+
const uint8_t their_public_key [32]);
|
|
197
|
+
|
|
198
|
+
// Conversion to EdDSA
|
|
199
|
+
void crypto_x25519_to_eddsa(uint8_t eddsa[32], const uint8_t x25519[32]);
|
|
200
|
+
|
|
201
|
+
// scalar "division"
|
|
202
|
+
// Used for OPRF. Be aware that exponential blinding is less secure
|
|
203
|
+
// than Diffie-Hellman key exchange.
|
|
204
|
+
void crypto_x25519_inverse(uint8_t blind_salt [32],
|
|
205
|
+
const uint8_t private_key[32],
|
|
206
|
+
const uint8_t curve_point[32]);
|
|
207
|
+
|
|
208
|
+
// "Dirty" versions of x25519_public_key().
|
|
209
|
+
// Use with crypto_elligator_rev().
|
|
210
|
+
// Leaks 3 bits of the private key.
|
|
211
|
+
void crypto_x25519_dirty_small(uint8_t pk[32], const uint8_t sk[32]);
|
|
212
|
+
void crypto_x25519_dirty_fast (uint8_t pk[32], const uint8_t sk[32]);
|
|
213
|
+
|
|
214
|
+
|
|
215
|
+
// Signatures
|
|
216
|
+
// ----------
|
|
217
|
+
|
|
218
|
+
// EdDSA with curve25519 + BLAKE2b
|
|
219
|
+
void crypto_eddsa_key_pair(uint8_t secret_key[64],
|
|
220
|
+
uint8_t public_key[32],
|
|
221
|
+
uint8_t seed[32]);
|
|
222
|
+
void crypto_eddsa_sign(uint8_t signature [64],
|
|
223
|
+
const uint8_t secret_key[64],
|
|
224
|
+
const uint8_t *message, size_t message_size);
|
|
225
|
+
int crypto_eddsa_check(const uint8_t signature [64],
|
|
226
|
+
const uint8_t public_key[32],
|
|
227
|
+
const uint8_t *message, size_t message_size);
|
|
228
|
+
|
|
229
|
+
// Conversion to X25519
|
|
230
|
+
void crypto_eddsa_to_x25519(uint8_t x25519[32], const uint8_t eddsa[32]);
|
|
231
|
+
|
|
232
|
+
// EdDSA building blocks
|
|
233
|
+
void crypto_eddsa_trim_scalar(uint8_t out[32], const uint8_t in[32]);
|
|
234
|
+
void crypto_eddsa_reduce(uint8_t reduced[32], const uint8_t expanded[64]);
|
|
235
|
+
void crypto_eddsa_mul_add(uint8_t r[32],
|
|
236
|
+
const uint8_t a[32],
|
|
237
|
+
const uint8_t b[32],
|
|
238
|
+
const uint8_t c[32]);
|
|
239
|
+
void crypto_eddsa_scalarbase(uint8_t point[32], const uint8_t scalar[32]);
|
|
240
|
+
int crypto_eddsa_check_equation(const uint8_t signature[64],
|
|
241
|
+
const uint8_t public_key[32],
|
|
242
|
+
const uint8_t h_ram[32]);
|
|
243
|
+
|
|
244
|
+
|
|
245
|
+
// Chacha20
|
|
246
|
+
// --------
|
|
247
|
+
|
|
248
|
+
// Specialised hash.
|
|
249
|
+
// Used to hash X25519 shared secrets.
|
|
250
|
+
void crypto_chacha20_h(uint8_t out[32],
|
|
251
|
+
const uint8_t key[32],
|
|
252
|
+
const uint8_t in [16]);
|
|
253
|
+
|
|
254
|
+
// Unauthenticated stream cipher.
|
|
255
|
+
// Don't forget to add authentication.
|
|
256
|
+
uint64_t crypto_chacha20_djb(uint8_t *cipher_text,
|
|
257
|
+
const uint8_t *plain_text,
|
|
258
|
+
size_t text_size,
|
|
259
|
+
const uint8_t key[32],
|
|
260
|
+
const uint8_t nonce[8],
|
|
261
|
+
uint64_t ctr);
|
|
262
|
+
uint32_t crypto_chacha20_ietf(uint8_t *cipher_text,
|
|
263
|
+
const uint8_t *plain_text,
|
|
264
|
+
size_t text_size,
|
|
265
|
+
const uint8_t key[32],
|
|
266
|
+
const uint8_t nonce[12],
|
|
267
|
+
uint32_t ctr);
|
|
268
|
+
uint64_t crypto_chacha20_x(uint8_t *cipher_text,
|
|
269
|
+
const uint8_t *plain_text,
|
|
270
|
+
size_t text_size,
|
|
271
|
+
const uint8_t key[32],
|
|
272
|
+
const uint8_t nonce[24],
|
|
273
|
+
uint64_t ctr);
|
|
274
|
+
|
|
275
|
+
|
|
276
|
+
// Poly 1305
|
|
277
|
+
// ---------
|
|
278
|
+
|
|
279
|
+
// This is a *one time* authenticator.
|
|
280
|
+
// Disclosing the mac reveals the key.
|
|
281
|
+
// See crypto_lock() on how to use it properly.
|
|
282
|
+
|
|
283
|
+
// Direct interface
|
|
284
|
+
void crypto_poly1305(uint8_t mac[16],
|
|
285
|
+
const uint8_t *message, size_t message_size,
|
|
286
|
+
const uint8_t key[32]);
|
|
287
|
+
|
|
288
|
+
// Incremental interface
|
|
289
|
+
typedef struct {
|
|
290
|
+
// Do not rely on the size or contents of this type,
|
|
291
|
+
// for they may change without notice.
|
|
292
|
+
uint8_t c[16]; // chunk of the message
|
|
293
|
+
size_t c_idx; // How many bytes are there in the chunk.
|
|
294
|
+
uint32_t r [4]; // constant multiplier (from the secret key)
|
|
295
|
+
uint32_t pad[4]; // random number added at the end (from the secret key)
|
|
296
|
+
uint32_t h [5]; // accumulated hash
|
|
297
|
+
} crypto_poly1305_ctx;
|
|
298
|
+
|
|
299
|
+
void crypto_poly1305_init (crypto_poly1305_ctx *ctx, const uint8_t key[32]);
|
|
300
|
+
void crypto_poly1305_update(crypto_poly1305_ctx *ctx,
|
|
301
|
+
const uint8_t *message, size_t message_size);
|
|
302
|
+
void crypto_poly1305_final (crypto_poly1305_ctx *ctx, uint8_t mac[16]);
|
|
303
|
+
|
|
304
|
+
|
|
305
|
+
// Elligator 2
|
|
306
|
+
// -----------
|
|
307
|
+
|
|
308
|
+
// Elligator mappings proper
|
|
309
|
+
void crypto_elligator_map(uint8_t curve [32], const uint8_t hidden[32]);
|
|
310
|
+
int crypto_elligator_rev(uint8_t hidden[32], const uint8_t curve [32],
|
|
311
|
+
uint8_t tweak);
|
|
312
|
+
|
|
313
|
+
// Easy to use key pair generation
|
|
314
|
+
void crypto_elligator_key_pair(uint8_t hidden[32], uint8_t secret_key[32],
|
|
315
|
+
uint8_t seed[32]);
|
|
316
|
+
|
|
317
|
+
#ifdef __cplusplus
|
|
318
|
+
}
|
|
319
|
+
#endif
|
|
320
|
+
|
|
321
|
+
#endif // MONOCYPHER_H
|
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
The zlib License (Zlib)
|
|
2
|
+
|
|
3
|
+
Copyright (c) 2003-2019 Joergen Ibsen
|
|
4
|
+
|
|
5
|
+
This software is provided 'as-is', without any express or implied
|
|
6
|
+
warranty. In no event will the authors be held liable for any damages
|
|
7
|
+
arising from the use of this software.
|
|
8
|
+
|
|
9
|
+
Permission is granted to anyone to use this software for any purpose,
|
|
10
|
+
including commercial applications, and to alter it and redistribute it
|
|
11
|
+
freely, subject to the following restrictions:
|
|
12
|
+
|
|
13
|
+
1. The origin of this software must not be misrepresented; you must
|
|
14
|
+
not claim that you wrote the original software. If you use this
|
|
15
|
+
software in a product, an acknowledgment in the product
|
|
16
|
+
documentation would be appreciated but is not required.
|
|
17
|
+
|
|
18
|
+
2. Altered source versions must be plainly marked as such, and must
|
|
19
|
+
not be misrepresented as being the original software.
|
|
20
|
+
|
|
21
|
+
3. This notice may not be removed or altered from any source
|
|
22
|
+
distribution.
|
|
@@ -0,0 +1,57 @@
|
|
|
1
|
+
/*
|
|
2
|
+
* CRC32 checksum
|
|
3
|
+
*
|
|
4
|
+
* Copyright (c) 1998-2019 Joergen Ibsen
|
|
5
|
+
*
|
|
6
|
+
* This software is provided 'as-is', without any express or implied
|
|
7
|
+
* warranty. In no event will the authors be held liable for any damages
|
|
8
|
+
* arising from the use of this software.
|
|
9
|
+
*
|
|
10
|
+
* Permission is granted to anyone to use this software for any purpose,
|
|
11
|
+
* including commercial applications, and to alter it and redistribute it
|
|
12
|
+
* freely, subject to the following restrictions:
|
|
13
|
+
*
|
|
14
|
+
* 1. The origin of this software must not be misrepresented; you must
|
|
15
|
+
* not claim that you wrote the original software. If you use this
|
|
16
|
+
* software in a product, an acknowledgment in the product
|
|
17
|
+
* documentation would be appreciated but is not required.
|
|
18
|
+
*
|
|
19
|
+
* 2. Altered source versions must be plainly marked as such, and must
|
|
20
|
+
* not be misrepresented as being the original software.
|
|
21
|
+
*
|
|
22
|
+
* 3. This notice may not be removed or altered from any source
|
|
23
|
+
* distribution.
|
|
24
|
+
*/
|
|
25
|
+
|
|
26
|
+
/*
|
|
27
|
+
* CRC32 algorithm taken from the zlib source, which is
|
|
28
|
+
* Copyright (C) 1995-1998 Jean-loup Gailly and Mark Adler
|
|
29
|
+
*/
|
|
30
|
+
|
|
31
|
+
#include "tinf.h"
|
|
32
|
+
|
|
33
|
+
static const unsigned int tinf_crc32tab[16] = {
|
|
34
|
+
0x00000000, 0x1DB71064, 0x3B6E20C8, 0x26D930AC, 0x76DC4190,
|
|
35
|
+
0x6B6B51F4, 0x4DB26158, 0x5005713C, 0xEDB88320, 0xF00F9344,
|
|
36
|
+
0xD6D6A3E8, 0xCB61B38C, 0x9B64C2B0, 0x86D3D2D4, 0xA00AE278,
|
|
37
|
+
0xBDBDF21C
|
|
38
|
+
};
|
|
39
|
+
|
|
40
|
+
unsigned int tinf_crc32(const void *data, unsigned int length)
|
|
41
|
+
{
|
|
42
|
+
const unsigned char *buf = (const unsigned char *) data;
|
|
43
|
+
unsigned int crc = 0xFFFFFFFF;
|
|
44
|
+
unsigned int i;
|
|
45
|
+
|
|
46
|
+
if (length == 0) {
|
|
47
|
+
return 0;
|
|
48
|
+
}
|
|
49
|
+
|
|
50
|
+
for (i = 0; i < length; ++i) {
|
|
51
|
+
crc ^= buf[i];
|
|
52
|
+
crc = tinf_crc32tab[crc & 0x0F] ^ (crc >> 4);
|
|
53
|
+
crc = tinf_crc32tab[crc & 0x0F] ^ (crc >> 4);
|
|
54
|
+
}
|
|
55
|
+
|
|
56
|
+
return crc ^ 0xFFFFFFFF;
|
|
57
|
+
}
|
|
@@ -0,0 +1,140 @@
|
|
|
1
|
+
/*
|
|
2
|
+
* tinf - tiny inflate library (inflate, gzip, zlib)
|
|
3
|
+
*
|
|
4
|
+
* Copyright (c) 2003-2019 Joergen Ibsen
|
|
5
|
+
*
|
|
6
|
+
* This software is provided 'as-is', without any express or implied
|
|
7
|
+
* warranty. In no event will the authors be held liable for any damages
|
|
8
|
+
* arising from the use of this software.
|
|
9
|
+
*
|
|
10
|
+
* Permission is granted to anyone to use this software for any purpose,
|
|
11
|
+
* including commercial applications, and to alter it and redistribute it
|
|
12
|
+
* freely, subject to the following restrictions:
|
|
13
|
+
*
|
|
14
|
+
* 1. The origin of this software must not be misrepresented; you must
|
|
15
|
+
* not claim that you wrote the original software. If you use this
|
|
16
|
+
* software in a product, an acknowledgment in the product
|
|
17
|
+
* documentation would be appreciated but is not required.
|
|
18
|
+
*
|
|
19
|
+
* 2. Altered source versions must be plainly marked as such, and must
|
|
20
|
+
* not be misrepresented as being the original software.
|
|
21
|
+
*
|
|
22
|
+
* 3. This notice may not be removed or altered from any source
|
|
23
|
+
* distribution.
|
|
24
|
+
*/
|
|
25
|
+
|
|
26
|
+
#ifndef TINF_H_INCLUDED
|
|
27
|
+
#define TINF_H_INCLUDED
|
|
28
|
+
|
|
29
|
+
#ifdef __cplusplus
|
|
30
|
+
extern "C" {
|
|
31
|
+
#endif
|
|
32
|
+
|
|
33
|
+
#define TINF_VER_MAJOR 1 /**< Major version number */
|
|
34
|
+
#define TINF_VER_MINOR 2 /**< Minor version number */
|
|
35
|
+
#define TINF_VER_PATCH 1 /**< Patch version number */
|
|
36
|
+
#define TINF_VER_STRING "1.2.1" /**< Version number as a string */
|
|
37
|
+
|
|
38
|
+
#ifndef TINFCC
|
|
39
|
+
# ifdef __WATCOMC__
|
|
40
|
+
# define TINFCC __cdecl
|
|
41
|
+
# else
|
|
42
|
+
# define TINFCC
|
|
43
|
+
# endif
|
|
44
|
+
#endif
|
|
45
|
+
|
|
46
|
+
/**
|
|
47
|
+
* Status codes returned.
|
|
48
|
+
*
|
|
49
|
+
* @see tinf_uncompress, tinf_gzip_uncompress, tinf_zlib_uncompress
|
|
50
|
+
*/
|
|
51
|
+
typedef enum {
|
|
52
|
+
TINF_OK = 0, /**< Success */
|
|
53
|
+
TINF_DATA_ERROR = -3, /**< Input error */
|
|
54
|
+
TINF_BUF_ERROR = -5 /**< Not enough room for output */
|
|
55
|
+
} tinf_error_code;
|
|
56
|
+
|
|
57
|
+
/**
|
|
58
|
+
* Initialize global data used by tinf.
|
|
59
|
+
*
|
|
60
|
+
* @deprecated No longer required, may be removed in a future version.
|
|
61
|
+
*/
|
|
62
|
+
void TINFCC tinf_init(void);
|
|
63
|
+
|
|
64
|
+
/**
|
|
65
|
+
* Decompress `sourceLen` bytes of deflate data from `source` to `dest`.
|
|
66
|
+
*
|
|
67
|
+
* The variable `destLen` points to must contain the size of `dest` on entry,
|
|
68
|
+
* and will be set to the size of the decompressed data on success.
|
|
69
|
+
*
|
|
70
|
+
* Reads at most `sourceLen` bytes from `source`.
|
|
71
|
+
* Writes at most `*destLen` bytes to `dest`.
|
|
72
|
+
*
|
|
73
|
+
* @param dest pointer to where to place decompressed data
|
|
74
|
+
* @param destLen pointer to variable containing size of `dest`
|
|
75
|
+
* @param source pointer to compressed data
|
|
76
|
+
* @param sourceLen size of compressed data
|
|
77
|
+
* @return `TINF_OK` on success, error code on error
|
|
78
|
+
*/
|
|
79
|
+
int TINFCC tinf_uncompress(void *dest, unsigned int *destLen,
|
|
80
|
+
const void *source, unsigned int sourceLen);
|
|
81
|
+
|
|
82
|
+
/**
|
|
83
|
+
* Decompress `sourceLen` bytes of gzip data from `source` to `dest`.
|
|
84
|
+
*
|
|
85
|
+
* The variable `destLen` points to must contain the size of `dest` on entry,
|
|
86
|
+
* and will be set to the size of the decompressed data on success.
|
|
87
|
+
*
|
|
88
|
+
* Reads at most `sourceLen` bytes from `source`.
|
|
89
|
+
* Writes at most `*destLen` bytes to `dest`.
|
|
90
|
+
*
|
|
91
|
+
* @param dest pointer to where to place decompressed data
|
|
92
|
+
* @param destLen pointer to variable containing size of `dest`
|
|
93
|
+
* @param source pointer to compressed data
|
|
94
|
+
* @param sourceLen size of compressed data
|
|
95
|
+
* @return `TINF_OK` on success, error code on error
|
|
96
|
+
*/
|
|
97
|
+
int TINFCC tinf_gzip_uncompress(void *dest, unsigned int *destLen,
|
|
98
|
+
const void *source, unsigned int sourceLen);
|
|
99
|
+
|
|
100
|
+
/**
|
|
101
|
+
* Decompress `sourceLen` bytes of zlib data from `source` to `dest`.
|
|
102
|
+
*
|
|
103
|
+
* The variable `destLen` points to must contain the size of `dest` on entry,
|
|
104
|
+
* and will be set to the size of the decompressed data on success.
|
|
105
|
+
*
|
|
106
|
+
* Reads at most `sourceLen` bytes from `source`.
|
|
107
|
+
* Writes at most `*destLen` bytes to `dest`.
|
|
108
|
+
*
|
|
109
|
+
* @param dest pointer to where to place decompressed data
|
|
110
|
+
* @param destLen pointer to variable containing size of `dest`
|
|
111
|
+
* @param source pointer to compressed data
|
|
112
|
+
* @param sourceLen size of compressed data
|
|
113
|
+
* @return `TINF_OK` on success, error code on error
|
|
114
|
+
*/
|
|
115
|
+
int TINFCC tinf_zlib_uncompress(void *dest, unsigned int *destLen,
|
|
116
|
+
const void *source, unsigned int sourceLen);
|
|
117
|
+
|
|
118
|
+
/**
|
|
119
|
+
* Compute Adler-32 checksum of `length` bytes starting at `data`.
|
|
120
|
+
*
|
|
121
|
+
* @param data pointer to data
|
|
122
|
+
* @param length size of data
|
|
123
|
+
* @return Adler-32 checksum
|
|
124
|
+
*/
|
|
125
|
+
unsigned int TINFCC tinf_adler32(const void *data, unsigned int length);
|
|
126
|
+
|
|
127
|
+
/**
|
|
128
|
+
* Compute CRC32 checksum of `length` bytes starting at `data`.
|
|
129
|
+
*
|
|
130
|
+
* @param data pointer to data
|
|
131
|
+
* @param length size of data
|
|
132
|
+
* @return CRC32 checksum
|
|
133
|
+
*/
|
|
134
|
+
unsigned int TINFCC tinf_crc32(const void *data, unsigned int length);
|
|
135
|
+
|
|
136
|
+
#ifdef __cplusplus
|
|
137
|
+
} /* extern "C" */
|
|
138
|
+
#endif
|
|
139
|
+
|
|
140
|
+
#endif /* TINF_H_INCLUDED */
|