@pulse-compute/crypto 1.0.0-beta.4 → 1.0.0-beta.6

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.
Files changed (95) hide show
  1. package/README.md +89 -8
  2. package/as/digest-text.as.ts +34 -0
  3. package/as/pulse-hmac-as.ts +7 -1
  4. package/conformance/digest-text.json +38 -0
  5. package/conformance/hs256.json +85 -0
  6. package/dist/contracts.d.ts +34 -12
  7. package/dist/contracts.d.ts.map +1 -1
  8. package/dist/contracts.js +9 -3
  9. package/dist/contracts.js.map +1 -1
  10. package/dist/digest.d.ts +14 -0
  11. package/dist/digest.d.ts.map +1 -0
  12. package/dist/digest.js +17 -0
  13. package/dist/digest.js.map +1 -0
  14. package/dist/index.d.ts +6 -0
  15. package/dist/index.d.ts.map +1 -1
  16. package/dist/index.js +20 -0
  17. package/dist/index.js.map +1 -1
  18. package/dist/internal/rsa.d.ts +58 -0
  19. package/dist/internal/rsa.d.ts.map +1 -0
  20. package/dist/internal/rsa.js +185 -0
  21. package/dist/internal/rsa.js.map +1 -0
  22. package/dist/internal/verification.d.ts +3 -3
  23. package/dist/internal/verification.d.ts.map +1 -1
  24. package/dist/internal/verification.js +2 -2
  25. package/dist/internal/verification.js.map +1 -1
  26. package/guests/es256-rustcrypto/README.md +43 -0
  27. package/guests/es256-rustcrypto/build.cjs +297 -0
  28. package/guests/es256-rustcrypto/prebuilt/es256-verifier.unoptimized.wasm +0 -0
  29. package/guests/es256-rustcrypto/prebuilt/es256-verifier.wasm +0 -0
  30. package/guests/es256-rustcrypto/probe/.cargo/config.toml +18 -0
  31. package/guests/es256-rustcrypto/probe/Cargo.lock +238 -0
  32. package/guests/es256-rustcrypto/probe/Cargo.toml +26 -0
  33. package/guests/es256-rustcrypto/probe/README.md +35 -0
  34. package/guests/es256-rustcrypto/probe/rust-toolchain.toml +5 -0
  35. package/guests/es256-rustcrypto/probe/src/lib.rs +108 -0
  36. package/guests/es256-rustcrypto/pulse.guest-unit.json +119 -0
  37. package/guests/es256-rustcrypto/source/.cargo/config.toml +18 -0
  38. package/guests/es256-rustcrypto/source/Cargo.lock +265 -0
  39. package/guests/es256-rustcrypto/source/Cargo.toml +23 -0
  40. package/guests/es256-rustcrypto/source/README.md +26 -0
  41. package/guests/es256-rustcrypto/source/bearssl/LICENSE.txt +21 -0
  42. package/guests/es256-rustcrypto/source/bearssl/UPSTREAM.json +49 -0
  43. package/guests/es256-rustcrypto/source/bearssl/inc/bearssl.h +170 -0
  44. package/guests/es256-rustcrypto/source/bearssl/inc/bearssl_aead.h +1059 -0
  45. package/guests/es256-rustcrypto/source/bearssl/inc/bearssl_block.h +2618 -0
  46. package/guests/es256-rustcrypto/source/bearssl/inc/bearssl_ec.h +883 -0
  47. package/guests/es256-rustcrypto/source/bearssl/inc/bearssl_hash.h +1346 -0
  48. package/guests/es256-rustcrypto/source/bearssl/inc/bearssl_hmac.h +241 -0
  49. package/guests/es256-rustcrypto/source/bearssl/inc/bearssl_kdf.h +185 -0
  50. package/guests/es256-rustcrypto/source/bearssl/inc/bearssl_pem.h +294 -0
  51. package/guests/es256-rustcrypto/source/bearssl/inc/bearssl_prf.h +150 -0
  52. package/guests/es256-rustcrypto/source/bearssl/inc/bearssl_rand.h +397 -0
  53. package/guests/es256-rustcrypto/source/bearssl/inc/bearssl_rsa.h +1366 -0
  54. package/guests/es256-rustcrypto/source/bearssl/inc/bearssl_ssl.h +4296 -0
  55. package/guests/es256-rustcrypto/source/bearssl/inc/bearssl_x509.h +1397 -0
  56. package/guests/es256-rustcrypto/source/bearssl/src/codec/ccopy.c +44 -0
  57. package/guests/es256-rustcrypto/source/bearssl/src/codec/dec32be.c +38 -0
  58. package/guests/es256-rustcrypto/source/bearssl/src/codec/enc32be.c +38 -0
  59. package/guests/es256-rustcrypto/source/bearssl/src/config.h +229 -0
  60. package/guests/es256-rustcrypto/source/bearssl/src/inner.h +2532 -0
  61. package/guests/es256-rustcrypto/source/bearssl/src/int/i31_add.c +46 -0
  62. package/guests/es256-rustcrypto/source/bearssl/src/int/i31_bitlen.c +44 -0
  63. package/guests/es256-rustcrypto/source/bearssl/src/int/i31_decmod.c +124 -0
  64. package/guests/es256-rustcrypto/source/bearssl/src/int/i31_decode.c +57 -0
  65. package/guests/es256-rustcrypto/source/bearssl/src/int/i31_decred.c +103 -0
  66. package/guests/es256-rustcrypto/source/bearssl/src/int/i31_encode.c +79 -0
  67. package/guests/es256-rustcrypto/source/bearssl/src/int/i31_fmont.c +60 -0
  68. package/guests/es256-rustcrypto/source/bearssl/src/int/i31_iszero.c +39 -0
  69. package/guests/es256-rustcrypto/source/bearssl/src/int/i31_moddiv.c +488 -0
  70. package/guests/es256-rustcrypto/source/bearssl/src/int/i31_modpow.c +65 -0
  71. package/guests/es256-rustcrypto/source/bearssl/src/int/i31_modpow2.c +160 -0
  72. package/guests/es256-rustcrypto/source/bearssl/src/int/i31_montmul.c +93 -0
  73. package/guests/es256-rustcrypto/source/bearssl/src/int/i31_mulacc.c +61 -0
  74. package/guests/es256-rustcrypto/source/bearssl/src/int/i31_muladd.c +157 -0
  75. package/guests/es256-rustcrypto/source/bearssl/src/int/i31_ninv31.c +39 -0
  76. package/guests/es256-rustcrypto/source/bearssl/src/int/i31_reduce.c +66 -0
  77. package/guests/es256-rustcrypto/source/bearssl/src/int/i31_rshift.c +47 -0
  78. package/guests/es256-rustcrypto/source/bearssl/src/int/i31_sub.c +46 -0
  79. package/guests/es256-rustcrypto/source/bearssl/src/int/i31_tmont.c +36 -0
  80. package/guests/es256-rustcrypto/source/bearssl/src/int/i32_div32.c +56 -0
  81. package/guests/es256-rustcrypto/source/bearssl/src/rsa/rsa_i31_priv.c +203 -0
  82. package/guests/es256-rustcrypto/source/bearssl/src/rsa/rsa_i31_pub.c +106 -0
  83. package/guests/es256-rustcrypto/source/bearssl/src/rsa/rsa_pkcs1_sig_pad.c +100 -0
  84. package/guests/es256-rustcrypto/source/build.rs +38 -0
  85. package/guests/es256-rustcrypto/source/freestanding/string.h +8 -0
  86. package/guests/es256-rustcrypto/source/rs256.c +103 -0
  87. package/guests/es256-rustcrypto/source/rust-toolchain.toml +5 -0
  88. package/guests/es256-rustcrypto/source/src/lib.rs +308 -0
  89. package/package.json +22 -4
  90. package/pulse.package.json +64 -0
  91. package/pulsewasm.compiler.cjs +89 -0
  92. package/pulsewasm.manifest.cjs +15 -0
  93. package/pulsewasm.native.cjs +79 -7
  94. package/src/provider.cjs +141 -2
  95. package/src/provider.d.cts +6 -0
@@ -0,0 +1,170 @@
1
+ /*
2
+ * Copyright (c) 2016 Thomas Pornin <pornin@bolet.org>
3
+ *
4
+ * Permission is hereby granted, free of charge, to any person obtaining
5
+ * a copy of this software and associated documentation files (the
6
+ * "Software"), to deal in the Software without restriction, including
7
+ * without limitation the rights to use, copy, modify, merge, publish,
8
+ * distribute, sublicense, and/or sell copies of the Software, and to
9
+ * permit persons to whom the Software is furnished to do so, subject to
10
+ * the following conditions:
11
+ *
12
+ * The above copyright notice and this permission notice shall be
13
+ * included in all copies or substantial portions of the Software.
14
+ *
15
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
16
+ * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
17
+ * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
18
+ * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS
19
+ * BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN
20
+ * ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
21
+ * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
22
+ * SOFTWARE.
23
+ */
24
+
25
+ #ifndef BR_BEARSSL_H__
26
+ #define BR_BEARSSL_H__
27
+
28
+ #include <stddef.h>
29
+ #include <stdint.h>
30
+
31
+ /** \mainpage BearSSL API
32
+ *
33
+ * # API Layout
34
+ *
35
+ * The functions and structures defined by the BearSSL API are located
36
+ * in various header files:
37
+ *
38
+ * | Header file | Elements |
39
+ * | :-------------- | :------------------------------------------------ |
40
+ * | bearssl_hash.h | Hash functions |
41
+ * | bearssl_hmac.h | HMAC |
42
+ * | bearssl_kdf.h | Key Derivation Functions |
43
+ * | bearssl_rand.h | Pseudorandom byte generators |
44
+ * | bearssl_prf.h | PRF implementations (for SSL/TLS) |
45
+ * | bearssl_block.h | Symmetric encryption |
46
+ * | bearssl_aead.h | AEAD algorithms (combined encryption + MAC) |
47
+ * | bearssl_rsa.h | RSA encryption and signatures |
48
+ * | bearssl_ec.h | Elliptic curves support (including ECDSA) |
49
+ * | bearssl_ssl.h | SSL/TLS engine interface |
50
+ * | bearssl_x509.h | X.509 certificate decoding and validation |
51
+ * | bearssl_pem.h | Base64/PEM decoding support functions |
52
+ *
53
+ * Applications using BearSSL are supposed to simply include `bearssl.h`
54
+ * as follows:
55
+ *
56
+ * #include <bearssl.h>
57
+ *
58
+ * The `bearssl.h` file itself includes all the other header files. It is
59
+ * possible to include specific header files, but it has no practical
60
+ * advantage for the application. The API is separated into separate
61
+ * header files only for documentation convenience.
62
+ *
63
+ *
64
+ * # Conventions
65
+ *
66
+ * ## MUST and SHALL
67
+ *
68
+ * In all descriptions, the usual "MUST", "SHALL", "MAY",... terminology
69
+ * is used. Failure to meet requirements expressed with a "MUST" or
70
+ * "SHALL" implies undefined behaviour, which means that segmentation
71
+ * faults, buffer overflows, and other similar adverse events, may occur.
72
+ *
73
+ * In general, BearSSL is not very forgiving of programming errors, and
74
+ * does not include much failsafes or error reporting when the problem
75
+ * does not arise from external transient conditions, and can be fixed
76
+ * only in the application code. This is done so in order to make the
77
+ * total code footprint lighter.
78
+ *
79
+ *
80
+ * ## `NULL` values
81
+ *
82
+ * Function parameters with a pointer type shall not be `NULL` unless
83
+ * explicitly authorised by the documentation. As an exception, when
84
+ * the pointer aims at a sequence of bytes and is accompanied with
85
+ * a length parameter, and the length is zero (meaning that there is
86
+ * no byte at all to retrieve), then the pointer may be `NULL` even if
87
+ * not explicitly allowed.
88
+ *
89
+ *
90
+ * ## Memory Allocation
91
+ *
92
+ * BearSSL does not perform dynamic memory allocation. This implies that
93
+ * for any functionality that requires a non-transient state, the caller
94
+ * is responsible for allocating the relevant context structure. Such
95
+ * allocation can be done in any appropriate area, including static data
96
+ * segments, the heap, and the stack, provided that proper alignment is
97
+ * respected. The header files define these context structures
98
+ * (including size and contents), so the C compiler should handle
99
+ * alignment automatically.
100
+ *
101
+ * Since there is no dynamic resource allocation, there is also nothing to
102
+ * release. When the calling code is done with a BearSSL feature, it
103
+ * may simple release the context structures it allocated itself, with
104
+ * no "close function" to call. If the context structures were allocated
105
+ * on the stack (as local variables), then even that release operation is
106
+ * implicit.
107
+ *
108
+ *
109
+ * ## Structure Contents
110
+ *
111
+ * Except when explicitly indicated, structure contents are opaque: they
112
+ * are included in the header files so that calling code may know the
113
+ * structure sizes and alignment requirements, but callers SHALL NOT
114
+ * access individual fields directly. For fields that are supposed to
115
+ * be read from or written to, the API defines accessor functions (the
116
+ * simplest of these accessor functions are defined as `static inline`
117
+ * functions, and the C compiler will optimise them away).
118
+ *
119
+ *
120
+ * # API Usage
121
+ *
122
+ * BearSSL usage for running a SSL/TLS client or server is described
123
+ * on the [BearSSL Web site](https://www.bearssl.org/api1.html). The
124
+ * BearSSL source archive also comes with sample code.
125
+ */
126
+
127
+ #include "bearssl_hash.h"
128
+ #include "bearssl_hmac.h"
129
+ #include "bearssl_kdf.h"
130
+ #include "bearssl_rand.h"
131
+ #include "bearssl_prf.h"
132
+ #include "bearssl_block.h"
133
+ #include "bearssl_aead.h"
134
+ #include "bearssl_rsa.h"
135
+ #include "bearssl_ec.h"
136
+ #include "bearssl_ssl.h"
137
+ #include "bearssl_x509.h"
138
+ #include "bearssl_pem.h"
139
+
140
+ /** \brief Type for a configuration option.
141
+ *
142
+ * A "configuration option" is a value that is selected when the BearSSL
143
+ * library itself is compiled. Most options are boolean; their value is
144
+ * then either 1 (option is enabled) or 0 (option is disabled). Some
145
+ * values have other integer values. Option names correspond to macro
146
+ * names. Some of the options can be explicitly set in the internal
147
+ * `"config.h"` file.
148
+ */
149
+ typedef struct {
150
+ /** \brief Configurable option name. */
151
+ const char *name;
152
+ /** \brief Configurable option value. */
153
+ long value;
154
+ } br_config_option;
155
+
156
+ /** \brief Get configuration report.
157
+ *
158
+ * This function returns compiled configuration options, each as a
159
+ * 'long' value. Names match internal macro names, in particular those
160
+ * that can be set in the `"config.h"` inner file. For boolean options,
161
+ * the numerical value is 1 if enabled, 0 if disabled. For maximum
162
+ * key sizes, values are expressed in bits.
163
+ *
164
+ * The returned array is terminated by an entry whose `name` is `NULL`.
165
+ *
166
+ * \return the configuration report.
167
+ */
168
+ const br_config_option *br_get_config(void);
169
+
170
+ #endif