Skip to content

Commit 52d26ce

Browse files
committed
Release version 0.2.0
1 parent 740e857 commit 52d26ce

File tree

3 files changed

+41
-5
lines changed

3 files changed

+41
-5
lines changed

README.md

Lines changed: 39 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -6,56 +6,82 @@ Constant-time algorithms written in TypeScript.
66
[![Linux Build Status](https://travis-ci.org/soatok/constant-time-js.svg?branch=master)](https://travis-ci.org/soatok/constant-time-js)
77
[![npm version](https://img.shields.io/npm/v/constant-time-js.svg)](https://npm.im/constant-time-js)
88

9-
**Important**: This Github repository is the companion to [Soatok's Guide to Side-Channel Attacks](https://soatok.blog/2020/08/27/soatoks-guide-to-side-channel-attacks/). Do not use this in production, especially if you don't have the budget for a cryptography audit.
9+
**Important**: This Github repository is the companion to [Soatok's Guide to Side-Channel Attacks](https://soatok.blog/2020/08/27/soatoks-guide-to-side-channel-attacks/).
10+
Do not use this in production, especially if you don't have the budget for a cryptography audit.
1011

1112
![Mind Blowing, right?](https://soatok.files.wordpress.com/2020/08/soatoktelegrams2020-01.png)
1213

1314
## Documentation
1415

16+
This is just a quick outline of what each function does.
17+
1518
* `compare(a, b)` - Compare two `Uint8Array` objects.
19+
* [Explanation](https://soatok.blog/2020/08/27/soatoks-guide-to-side-channel-attacks/#string-inequality)
1620
* Returns `-1` if `a < b`
1721
* Returns `1` if `a > b`
1822
* Returns `0` if `a === b`
1923
* Throws an `Error` if `a.length !== b.length`
2024
* `compare_ints(a, b)` - Compare two integers.
25+
* [Explanation](https://soatok.blog/2020/08/27/soatoks-guide-to-side-channel-attacks/#string-inequality)
2126
* Returns `-1` if `a < b`
2227
* Returns `1` if `a > b`
2328
* Returns `0` if `a === b`
2429
* `equals(a, b)` - Are these `Uint8Array` objects equal?
30+
* [Explanation](https://soatok.blog/2020/08/27/soatoks-guide-to-side-channel-attacks/#string-comparison)
2531
* Returns `true` if they are equal.
2632
* Returns `false` if they are not equal.
2733
* Throws an `Error` if `a.length !== b.length`
2834
* `hmac_equals(a, b)` - Are these `Uint8Array` objects equal? (Using HMAC to compare.)
35+
* [Explanation](https://soatok.blog/2020/08/27/soatoks-guide-to-side-channel-attacks/#double-hmac)
2936
* Returns `true` if they are equal.
3037
* Returns `false` if they are not equal.
3138
* Throws an `Error` if `a.length !== b.length`
3239
* `intdiv(N, D)` - Divide `N` into `D`, discarding remainder.
40+
* [Explanation](https://soatok.blog/2020/08/27/soatoks-guide-to-side-channel-attacks/#integer-division)
3341
* Returns an integer.
3442
* `modulo(N, D)` - Divide `N` into `D`, return the remainder.
43+
* [Explanation](https://soatok.blog/2020/08/27/soatoks-guide-to-side-channel-attacks/#integer-division)
3544
* Returns an integer.
3645
* `resize(buf, size)` - Return a resized `Uint8Array` object (to side-step memory access leakage)
3746
* `select(x, a, b)` - Read it as a ternary. If `x` is true, returns `a`. Otherwise, returns `b`.
47+
* [Explanation](https://soatok.blog/2020/08/27/soatoks-guide-to-side-channel-attacks/#conditional-select)
3848
* `x` must be a `boolean`
3949
* `a` must be a `Uint8Array`
4050
* `b` must be a `Uint8Array`
4151
* Throws an `Error` if `a.length !== b.length`
4252
* `select_ints(x, a, b)` - Read it as a ternary. If `x` is even, returns `a`. Otherwise, returns `b`.
4353
(You should pass `1` or `0` for `x`).
54+
* [Explanation](https://soatok.blog/2020/08/27/soatoks-guide-to-side-channel-attacks/#conditional-select)
4455
* `x` must be a `boolean`
4556
* `a` must be a `number`
4657
* `b` must be a `number`
4758
* `trim_zeroes_left(buf)`
59+
* [Explanation](https://soatok.blog/2020/08/27/soatoks-guide-to-side-channel-attacks/#null-byte-trimming)
4860
* `buf` must be a `Uint8Array`
4961
* Returns a `Uint8Array`
5062
* `trim_zeroes_right(buf)`
63+
* [Explanation](https://soatok.blog/2020/08/27/soatoks-guide-to-side-channel-attacks/#null-byte-trimming)
5164
* `buf` must be a `Uint8Array`
5265
* Returns a `Uint8Array`
5366

67+
### Not Implemented From the Blog Post Yet
68+
69+
* Constant-Time Integer Multiplication
70+
* Constant-Time Modular Inversion
71+
5472
## Limitations
5573

56-
### Do not use on 32-bit processes.
74+
### Potentially Dangerous on 32-bit Applications
75+
76+
32-bit v8 (and, presumably, a lot of other 32-bit implementations) do things wrong,
77+
and our implementation might be variable-time on it.
78+
79+
Specifically, the most significant bit of a 32-bit integer distinguishes values from pointers.
80+
As a result, accessing the highest bit of a 32-bit number in 32-bit JavaScript engines (such as v8)
81+
is potentially variable-time.
5782

58-
32-bit v8 (and, presumably, a lot of other implementations) do things wrong, and this will be variable-time on it.
83+
To mitigate this risk, the [`int32` class was created](https://github.com/soatok/constant-time-js/blob/master/lib/int32.ts)
84+
which wraps operates on 16-bit limbs (wrapping `Uint16Array`).
5985

6086
## Frequently Asked Questions
6187

@@ -68,6 +94,16 @@ Constant-time algorithms written in TypeScript.
6894
This is a proof-of-concept library, that will eventually implement
6995
all of the algorithms described in [the accompanying blog post](https://soatok.blog/2020/08/27/soatoks-guide-to-side-channel-attacks/).
7096

97+
The main purpose of this library is to demonstrate the concepts in a programming
98+
language widely accessible outside of the cryptography orthodoxy (which today is
99+
largely C and sometimes Python, and hopefully soon Rust).
100+
101+
### Can I use this in a project?
102+
103+
Hold off until v1.0.0 is tagged before you even *think* about relying on it for
104+
anything. APIs might break until then.
105+
My fursona is a [dhole](https://soatok.blog/2020/08/10/all-about-dholes-and-dhole-fursonas/), not a wolf.
106+
71107
### What's with the blue {fox, wolf}?
72108

73109
My fursona is a [dhole](https://soatok.blog/2020/08/10/all-about-dholes-and-dhole-fursonas/), not a wolf.

package-lock.json

Lines changed: 1 addition & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "constant-time-js",
3-
"version": "0.1.1",
3+
"version": "0.2.0",
44
"description": "Constant-time algorithms in JavaScript",
55
"main": "index.ts",
66
"scripts": {

0 commit comments

Comments
 (0)