Skip to content

Commit c93b83a

Browse files
author
Ernie Turner
authored
#26 Fix a number of vulnerable sub dependencies (#27)
* #26 Fix a number of vulnerable sub dependencies * Remove Node 9 and 11, add Node 12 as supported versions * Try to use forked version of neon as patch to get Node 12 working * Change to point to direct git hash * Upgrade to Recrypt 0.8 and consume all breaking changes. Remove export of hash256 method since it isnt needed or used * Update README to add support for Node 12 and remove support for Node 9/11 * Update version and add changelog entry
1 parent 0ae2b72 commit c93b83a

File tree

11 files changed

+1237
-1246
lines changed

11 files changed

+1237
-1246
lines changed

.travis.yml

Lines changed: 5 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
language: rust
22
rust:
3-
- 1.34.0
3+
- 1.36.0
44

55
# all unlabeled jobs run at test. Only if all "test" jobs finish, will the publish job run
66
stages:
@@ -23,18 +23,6 @@ jobs:
2323
- TRAVIS_NODE_VERSION="8"
2424
- SKIP_DEPLOY=0
2525
if: tag =~ /^\d+\.\d+\.\d+/ OR branch = master OR type = pull_request
26-
- name: "Linux - Node 9"
27-
os: linux
28-
env:
29-
- TRAVIS_NODE_VERSION="9"
30-
- SKIP_DEPLOY=0
31-
if: tag =~ /^\d+\.\d+\.\d+/ OR branch = master OR type = pull_request
32-
- name: "OSX - Node 9"
33-
os: osx
34-
env:
35-
- TRAVIS_NODE_VERSION="9"
36-
- SKIP_DEPLOY=0
37-
if: tag =~ /^\d+\.\d+\.\d+/ OR branch = master OR type = pull_request
3826
- name: "Linux - Node 10"
3927
os: linux
4028
env:
@@ -47,16 +35,16 @@ jobs:
4735
- TRAVIS_NODE_VERSION="10"
4836
- SKIP_DEPLOY=0
4937
if: tag =~ /^\d+\.\d+\.\d+/ OR branch = master OR type = pull_request
50-
- name: "Linux - Node 11"
38+
- name: "Linux - Node 12"
5139
os: linux
5240
env:
53-
- TRAVIS_NODE_VERSION="11"
41+
- TRAVIS_NODE_VERSION="12"
5442
- SKIP_DEPLOY=0
5543
if: tag =~ /^\d+\.\d+\.\d+/ OR branch = master OR type = pull_request
56-
- name: "OSX - Node 11"
44+
- name: "OSX - Node 12"
5745
os: osx
5846
env:
59-
- TRAVIS_NODE_VERSION="11"
47+
- TRAVIS_NODE_VERSION="12"
6048
- SKIP_DEPLOY=0
6149
if: tag =~ /^\d+\.\d+\.\d+/ OR branch = master OR type = pull_request
6250

CHANGELOG.md

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,15 @@
1+
## 0.5.0
2+
3+
### Breaking Changes
4+
5+
+ Added support for Node 12
6+
+ Removed support for Node 9 and 11
7+
+ Removed the `hash256` method from the API. Use the `deriveSymmetricKey` method instead.
8+
9+
### Changed
10+
11+
+ Updated all dependencies to their latest versions, including Recrypt to 0.8.
12+
113
## 0.4.2
214

315
### Added

README.md

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -9,10 +9,10 @@ This library uses the [Neon Bindings](https://www.neon-bindings.com) toolchain t
99

1010
## Supported Platforms
1111

12-
| | Node 8 | Node 9 | Node 10 | Node 11 |
13-
| --------- | ------ | ------- | ------ | ------- |
14-
| Linux x64 |||||
15-
| OSX x64 |||||
12+
| | Node 8 | Node 10 | Node 12 |
13+
| --------- | ------ | ------- | ------ |
14+
| Linux x64 ||||
15+
| OSX x64 ||||
1616

1717
## Install
1818

index.d.ts

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -52,7 +52,6 @@ export class Api256 {
5252
generatePlaintext(): Plaintext;
5353
generateTransformKey(fromPrivateKey: PrivateKey, toPublicKey: PublicKey, privateSigningKey: PrivateSigningKey): TransformKey;
5454
computePublicKey(privateKey: PrivateKey): PublicKey;
55-
hash256(hashable_buffer: Buffer): Buffer;
5655
deriveSymmetricKey(plaintext: Plaintext): Buffer;
5756
encrypt(plaintext: Plaintext, toPublicKey: PublicKey, privateSigningKey: PrivateSigningKey): EncryptedValue;
5857
transform(encryptedValue: EncryptedValue, transformKey: TransformKey, privateSigningKey: PrivateSigningKey): EncryptedValue;

native/Cargo.toml

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -8,10 +8,13 @@ name = "recrypt_node"
88
crate-type = ["dylib"]
99

1010
[dependencies]
11-
rand = "~0.6.1"
12-
recrypt = "~0.6"
11+
recrypt = "~0.8"
1312
neon = "~0.2.0"
1413

14+
[patch.crates-io]
15+
neon = { git = 'https://github.com/kjvalencik/neon', rev = '5d877ac0' }
16+
neon-runtime = { git = 'https://github.com/kjvalencik/neon', rev = '5d877ac0' }
17+
1518
[build-dependencies]
1619
neon-build = "0.2.0"
1720

native/src/api256.rs

Lines changed: 18 additions & 32 deletions
Original file line numberDiff line numberDiff line change
@@ -1,28 +1,27 @@
11
use neon::prelude::*;
22
use neon::types::JsBuffer;
3-
use rand;
43
use recrypt::api::Hashable;
54
use recrypt::api::{
6-
Api, CryptoOps, Ed25519, Ed25519Ops, KeyGenOps, PublicSigningKey, RandomBytes, SchnorrOps,
7-
Sha256, SigningKeypair,
5+
CryptoOps, DefaultRng, Ed25519, Ed25519Ops, KeyGenOps, PublicSigningKey, RandomBytes, Recrypt,
6+
SchnorrOps, Sha256, SigningKeypair,
87
};
98
use util;
109

1110
pub struct RecryptApi256 {
12-
api: Api<Sha256, Ed25519, RandomBytes<rand::rngs::ThreadRng>>,
11+
api: Recrypt<Sha256, Ed25519, RandomBytes<DefaultRng>>,
1312
}
1413

1514
declare_types! {
1615
pub class Api256 for RecryptApi256 {
1716
init(_cx) {
18-
Ok(RecryptApi256 {api: Api::new()})
17+
Ok(RecryptApi256 {api: Recrypt::new()})
1918
}
2019

2120
method generateKeyPair(mut cx) {
2221
let (priv_key, pub_key) = {
2322
let mut this = cx.this();
2423
let guard = cx.lock();
25-
let mut recrypt_api_256 = this.borrow_mut(&guard);
24+
let recrypt_api_256 = this.borrow_mut(&guard);
2625
recrypt_api_256.api.generate_key_pair().unwrap()
2726
};
2827

@@ -41,12 +40,12 @@ declare_types! {
4140
let signing_key_pair = {
4241
let mut this = cx.this();
4342
let guard = cx.lock();
44-
let mut recrypt_api_256 = this.borrow_mut(&guard);
43+
let recrypt_api_256 = this.borrow_mut(&guard);
4544
recrypt_api_256.api.generate_ed25519_key_pair()
4645
};
4746

4847
let signing_key_pair_obj: Handle<JsObject> = cx.empty_object();
49-
let priv_key_buffer = util::bytes_to_buffer(&mut cx, &signing_key_pair.bytes())?;
48+
let priv_key_buffer = util::bytes_to_buffer(&mut cx, signing_key_pair.bytes())?;
5049
let pub_key_buffer = util::bytes_to_buffer(&mut cx, signing_key_pair.public_key().bytes())?;
5150

5251
signing_key_pair_obj.set(&mut cx, "privateKey", priv_key_buffer)?;
@@ -94,7 +93,7 @@ declare_types! {
9493
let plaintext = {
9594
let mut this = cx.this();
9695
let guard = cx.lock();
97-
let mut recrypt_api_256 = this.borrow_mut(&guard);
96+
let recrypt_api_256 = this.borrow_mut(&guard);
9897
recrypt_api_256.api.gen_plaintext()
9998
};
10099

@@ -113,10 +112,10 @@ declare_types! {
113112
let transform_key = {
114113
let mut this = cx.this();
115114
let guard = cx.lock();
116-
let mut recrypt_api_256 = this.borrow_mut(&guard);
115+
let recrypt_api_256 = this.borrow_mut(&guard);
117116
recrypt_api_256.api.generate_transform_key(
118117
&util::buffer_to_private_key(&cx, from_private_key_buffer),
119-
to_public_key,
118+
&to_public_key,
120119
&signing_key_pair
121120
).unwrap()
122121
};
@@ -136,26 +135,13 @@ declare_types! {
136135
Ok(util::public_key_to_js_object(&mut cx, &derived_public_key)?.upcast())
137136
}
138137

139-
method hash256(mut cx) {
140-
let hashable_buffer: Handle<JsBuffer> = cx.argument::<JsBuffer>(0)?;
141-
142-
let hashed_bytes = {
143-
let mut this = cx.this();
144-
let guard = cx.lock();
145-
let mut recrypt_api_256 = this.borrow_mut(&guard);
146-
recrypt_api_256.api.hash_256(&util::buffer_to_variable_bytes(&cx, hashable_buffer))
147-
};
148-
149-
Ok(util::bytes_to_buffer(&mut cx, &hashed_bytes)?.upcast())
150-
}
151-
152138
method deriveSymmetricKey(mut cx){
153139
let plaintext_buffer: Handle<JsBuffer> = cx.argument::<JsBuffer>(0)?;
154140

155141
let decrypted_symmetric_key = {
156142
let mut this = cx.this();
157143
let guard = cx.lock();
158-
let mut recrypt_api_256 = this.borrow_mut(&guard);
144+
let recrypt_api_256 = this.borrow_mut(&guard);
159145
recrypt_api_256.api.derive_symmetric_key(&util::buffer_to_plaintext(&cx, plaintext_buffer))
160146
};
161147

@@ -173,10 +159,10 @@ declare_types! {
173159
let encrypted_value = {
174160
let mut this = cx.this();
175161
let guard = cx.lock();
176-
let mut recrypt_api_256 = this.borrow_mut(&guard);
162+
let recrypt_api_256 = this.borrow_mut(&guard);
177163
recrypt_api_256.api.encrypt(
178164
&util::buffer_to_plaintext(&cx, plaintext_buffer),
179-
public_key,
165+
&public_key,
180166
&signing_key_pair
181167
).unwrap()
182168
};
@@ -196,7 +182,7 @@ declare_types! {
196182
let transformed_encrypted_value = {
197183
let mut this = cx.this();
198184
let guard = cx.lock();
199-
let mut recrypt_api_256 = this.borrow_mut(&guard);
185+
let recrypt_api_256 = this.borrow_mut(&guard);
200186
recrypt_api_256.api.transform(encrypted_value, transform_key, &signing_key_pair).unwrap()
201187
};
202188

@@ -232,10 +218,10 @@ declare_types! {
232218
let signature = {
233219
let mut this = cx.this();
234220
let guard = cx.lock();
235-
let mut recrypt_api_256 = this.borrow_mut(&guard);
221+
let recrypt_api_256 = this.borrow_mut(&guard);
236222
recrypt_api_256.api.schnorr_sign(
237223
&util::buffer_to_private_key(&cx, private_key_buffer),
238-
public_key,
224+
&public_key,
239225
&util::buffer_to_variable_bytes(&cx, message_buffer)
240226
)
241227
};
@@ -269,9 +255,9 @@ declare_types! {
269255
let verified = {
270256
let mut this = cx.this();
271257
let guard = cx.lock();
272-
let mut recrypt_api_256 = this.borrow_mut(&guard);
258+
let recrypt_api_256 = this.borrow_mut(&guard);
273259
recrypt_api_256.api.schnorr_verify(
274-
public_key,
260+
&public_key,
275261
augmented_private_key.as_ref(),
276262
&util::buffer_to_variable_bytes(&cx, message_buffer),
277263
signature

native/src/lib.rs

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,5 @@
11
#[macro_use]
22
extern crate neon;
3-
extern crate rand;
43
extern crate recrypt;
54

65
mod api256;

native/src/util.rs

Lines changed: 20 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -25,23 +25,21 @@ macro_rules! buffer_to_fixed_bytes { ($($fn_name: ident, $n: expr); *) => {
2525
})+
2626
}}
2727

28-
///
29-
/// Create the various methods we need to convert buffers into fixed length bytes
30-
///
28+
// Create the various methods we need to convert buffers into fixed length bytes
3129
buffer_to_fixed_bytes! {buffer_to_fixed_32_bytes, 32; buffer_to_fixed_64_bytes, 64; buffer_to_fixed_128_bytes, 128; buffer_to_fixed_384_bytes, 384}
3230

3331
///
34-
/// Create a macro for converting JsBuffers to different types of signature objects which all have the same size
32+
/// Create a macro for converting JsBuffers to different types of signature objects which all have the same size. Marked as dead code because usage
33+
/// of this function in the wrapped macro in `api256.rs` can't be parsed by Rust.
3534
///
3635
macro_rules! buffer_to_signature { ($($fn_name: ident, $sig_type: expr, $ret_type: ty); *) => {
36+
#[allow(dead_code)]
3737
$(pub fn $fn_name<'a, T: Context<'a>>(cx: &T, buffer: Handle<JsBuffer>) -> $ret_type {
3838
$sig_type(buffer_to_fixed_64_bytes(cx, buffer, "signature"))
3939
})+
4040
}}
4141

42-
///
43-
/// Create two methods from the macro for Schnorr and ED25519 signatures
44-
///
42+
// Create two methods from the macro for Schnorr and ED25519 signatures
4543
buffer_to_signature! {buffer_to_schnorr_signature, SchnorrSignature::new, SchnorrSignature; buffer_to_ed25519_signature, Ed25519Signature::new, Ed25519Signature}
4644

4745
///
@@ -78,8 +76,10 @@ pub fn buffer_to_private_key<'a, T: Context<'a>>(cx: &T, buffer: Handle<JsBuffer
7876
}
7977

8078
///
81-
/// Convert a JsBuffer handle to a Plaintext object
79+
/// Convert a JsBuffer handle to a Plaintext object. Marked as dead code because usage
80+
/// of this function in the wrapped macro in `api256.rs` can't be parsed by Rust
8281
///
82+
#[allow(dead_code)]
8383
pub fn buffer_to_plaintext<'a, T: Context<'a>>(cx: &T, buffer: Handle<JsBuffer>) -> Plaintext {
8484
Plaintext::new(buffer_to_fixed_384_bytes(cx, buffer, "plaintext"))
8585
}
@@ -207,8 +207,10 @@ pub fn transform_key_to_js_object<'a, T: Context<'a>>(
207207
}
208208

209209
///
210-
/// Convert an array of transform blocks into a non-empty vector of internal recrypt TransformBlock structs
210+
/// Convert an array of transform blocks into a non-empty vector of internal recrypt TransformBlock structs. Marked as dead code because usage
211+
/// of this function in the wrapped macro in `api256.rs` can't be parsed by Rust
211212
///
213+
#[allow(dead_code)]
212214
pub fn js_object_to_transform_blocks<'a, T: Context<'a>>(
213215
cx: &mut T,
214216
js_array: Handle<JsArray>,
@@ -262,8 +264,10 @@ pub fn js_object_to_transform_blocks<'a, T: Context<'a>>(
262264
}
263265

264266
///
265-
/// Iterate through the provided internal TransformBlocks and convert each block to an external array of transform block objects.
267+
/// Iterate through the provided internal TransformBlocks and convert each block to an external array of transform block objects. Marked as dead code because usage
268+
/// of this function in the wrapped macro in `api256.rs` can't be parsed by Rust
266269
///
270+
#[allow(dead_code)]
267271
pub fn transform_blocks_to_js_object<'a, T: Context<'a>>(
268272
cx: &mut T,
269273
transform_blocks: Vec<TransformBlock>,
@@ -300,8 +304,10 @@ pub fn transform_blocks_to_js_object<'a, T: Context<'a>>(
300304
}
301305

302306
///
303-
/// Convert a JsObject with various encrypted value keys into a EncryptedOnce or TransformedValue value
307+
/// Convert a JsObject with various encrypted value keys into a EncryptedOnce or TransformedValue value. Marked as dead code because usage
308+
/// of this function in the wrapped macro in `api256.rs` can't be parsed by Rust
304309
///
310+
#[allow(dead_code)]
305311
pub fn js_object_to_encrypted_value<'a, T: Context<'a>>(
306312
cx: &mut T,
307313
object: Handle<JsObject>,
@@ -375,8 +381,10 @@ pub fn js_object_to_encrypted_value<'a, T: Context<'a>>(
375381
}
376382

377383
///
378-
/// Convert a Recrypt EncryptedValue into a JsObbject with expeted properties and bytes converted to Buffers
384+
/// Convert a Recrypt EncryptedValue into a JsObbject with expeted properties and bytes converted to Buffers. Marked as dead code because usage
385+
/// of this function in the wrapped macro in `api256.rs` can't be parsed by Rust
379386
///
387+
#[allow(dead_code)]
380388
pub fn encrypted_value_to_js_object<'a, T: Context<'a>>(
381389
cx: &mut T,
382390
encrypted_value: EncryptedValue,

package.json

Lines changed: 11 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "@ironcorelabs/recrypt-node-binding",
3-
"version": "0.4.2",
3+
"version": "0.5.0",
44
"description": "Bindings to allow the recrypt-rs library to work via NodeJS.",
55
"repository": {
66
"type": "git",
@@ -27,13 +27,16 @@
2727
"benchmark": "node benchmark/index.js",
2828
"test": "jest"
2929
},
30+
"dependencies": {
31+
"node-pre-gyp": "^0.13.0"
32+
},
3033
"devDependencies": {
31-
"@types/node": "^10.11.0",
34+
"@types/node": "^12.7.1",
3235
"benchmark": "^2.1.4",
33-
"jest": "^23.6.0",
34-
"jest-extended": "^0.11.0",
36+
"jest": "^24.8.0",
37+
"jest-extended": "^0.11.2",
3538
"neon-cli": "^0.2.0",
36-
"shelljs": "^0.8.2"
39+
"shelljs": "^0.8.3"
3740
},
3841
"prettier": {
3942
"printWidth": 160,
@@ -45,10 +48,9 @@
4548
},
4649
"jest": {
4750
"testEnvironment": "node",
48-
"setupTestFrameworkScriptFile": "jest-extended"
49-
},
50-
"dependencies": {
51-
"node-pre-gyp": "^0.11.0"
51+
"setupFilesAfterEnv": [
52+
"jest-extended"
53+
]
5254
},
5355
"binary": {
5456
"module_name": "index",

0 commit comments

Comments
 (0)