Basic self_encryptor example DIY instructions

You should never need to run this type of application as root. sudo (your command here) may fix a lot of things on a poorly configured system, but you should definitely refrain from making it a habit.

3 Likes

You’re probably right :blush:

[blindsite@localhost ~] cargo clean Could not find `Cargo.toml` in `/home/blindsite` or any parent directory [blindsite@localhost ~]

God damn there are a lot of errors. Also thanks for the tips.

Actually on fedora it’s just “su” and you pretty much stay in root mode after that. Not quite sure how to exit root yet.

You do need to be in the project dir so if you did git clone then the project dir is self_encryption. In there you will see a Cargo.toml file. This is the way you will see all Rust progs, it’s much better than the c/c++ build systems though. So if you have Rust installed its a case of cd into the dir and type cargo build and cargo test if you then go into the examples dir you will see the example prog and just run it form there.

You really should not go into root mode (su == superuser == bad bad things can happen and your very insecure). sudo allows single commands to be run as superuser (root). If you need root mode for any program something bad has happened and you need to reverse what you have done.

2 Likes

[blindsite@localhost ~] cd self_encryption/ [blindsite@localhost self_encryption] cargo clean
[blindsite@localhost self_encryption] cargo update A Cargo.lock must exist before it is updated [blindsite@localhost self_encryption]

In the proper directory? Check.

Cargo clean? Check.

Cargo update? Grrrrr

At some stage you may have created stuff as root and it cannot be overwritten now. Perhaps clean the dir and start again with the git clone? Seems you have rust installed so this should be quick (he said quietly)

Lol okay so what do you mean start again with the git clone?

Nevermind I think I figured that out but still same error.

[blindsite@localhost ~] git clone http://github.com/dirvine/self_encryption.git Cloning into 'self_encryption'... remote: Counting objects: 2690, done. remote: Total 2690 (delta 0), reused 0 (delta 0), pack-reused 2690 Receiving objects: 100% (2690/2690), 2.16 MiB | 1.51 MiB/s, done. Resolving deltas: 100% (1820/1820), done. Checking connectivity... done. [blindsite@localhost ~] cd self_encryption/
[blindsite@localhost self_encryption] cargo clean [blindsite@localhost self_encryption] cargo update
A Cargo.lock must exist before it is updated
[blindsite@localhost self_encryption]$

Oh and I was not logged in as root when I cloned it that time.

you do not need update there just do cargo test then you will have built and tested the lib. Then you can cd into the taraget/debug/examples dir and run the example

[update literally means update all libs I have used that are included in this crate, as you have never built then you have no libs to update, yet]

Success!

[blindsite@localhost self_encryption]$ cargo test
Updating registry https://github.com/rust-lang/crates.io-index
Downloading docopt v0.6.64
Downloading rand v0.3.8
Downloading regex v0.1.30
Downloading gcc v0.3.5
Downloading rust-crypto v0.2.31
Downloading time v0.1.25
Downloading rustc-serialize v0.3.14
Downloading tempdir v0.3.4
Downloading strsim v0.3.0
Downloading cbor v0.3.6
Downloading byteorder v0.3.9
Downloading libc v0.1.6
Compiling gcc v0.3.5
Compiling byteorder v0.3.9
Compiling strsim v0.3.0
Compiling libc v0.1.6
Compiling rustc-serialize v0.3.14
Compiling regex v0.1.30
Compiling rand v0.3.8
Compiling time v0.1.25
Compiling rust-crypto v0.2.31
Compiling tempdir v0.3.4
Compiling docopt v0.6.64
Compiling cbor v0.3.6
Compiling self_encryption v0.1.1 (file:///home/blindsite/self_encryption)
Running target/debug/lib-11223db2a5457c7e

running 3 tests
test new_read … ok
test write_random_sizes_at_random_positions … ok
test write_random_sizes_out_of_sequence_with_gaps_and_overlaps … ok

test result: ok. 3 passed; 0 failed; 0 ignored; 0 measured

 Running target/debug/self_encryption-bc3815502d109d54

running 15 tests
test encryption::test::test_hash_sha_512 … ok
test encryption::test::test_aes_cbc … ok
test datamap::dummy … ok
test test::check_3_min_chunks … ok
test test::check_3_min_chunks_minus1 … ok
test test::check_3_min_chunks_plus1 … ok
test test::check_3_max_chunks_plus1 … ok
test test::check_3_max_chunks … ok
test test::check_5_and_extend_to_7_plus_one … ok
test test::check_7_and_a_bit_max_chunks … ok
test test::check_large_file_1_byte_over_11_chunks … ok
test test::check_write … ok
test test::test_xor … ok
test test::check_large_file_1_byte_under_11_chunks … ok
test test::check_large_file_size_1024_over_11_chunks … ok

test result: ok. 15 passed; 0 failed; 0 ignored; 0 measured

Doc-tests self_encryption

running 1 test
test _0 … ok

test result: ok. 1 passed; 0 failed; 0 ignored; 0 measured

[blindsite@localhost self_encryption] cargo run --example basic_encryptor -- -e /home/blindsite/02_Track_02.m4a Running `target/debug/examples/basic_encryptor -e /home/blindsite/02_Track_02.m4a` chunk written chunk written chunk written chunk written chunk written [blindsite@localhost self_encryption] ls
appveyor.yml Cargo.toml COPYING img src
benches chunk_store_test data_map LICENSE target
Cargo.lock CONTRIBUTOR examples README.md tests
[blindsite@localhost self_encryption] cargo run --example basic_encryptor -- -d /home/blindsite/self_encryption/data_map /home/blindsite/02_track_02_test.m4a Running `target/debug/examples/basic_encryptor -d /home/blindsite/self_encryption/data_map /home/blindsite/02_track_02_test.m4a` ! chunk_store_test AlreadyExists chunk written [blindsite@localhost self_encryption] ls
appveyor.yml Cargo.toml COPYING img src
benches chunk_store_test data_map LICENSE target
Cargo.lock CONTRIBUTOR examples README.md tests
[blindsite@localhost self_encryption] cd ..// [blindsite@localhost ~] ls
02_Track_02.m4a Documents Music self_encryption
02_track_02_test.m4a Downloads Pictures Templates
Desktop dwhelper Public Videos

Didn’t you post a modified version or something earlier? I got kind of caught up in trying to get this thing working.

4 Likes

Congratulations! Now…Don’t that feel goooooood :slight_smile:

4 Likes

Little steps towards a decentralized internet.

1 Like

I followed the instructions and I got this:

dargal@dargal:~/self_encryption$ cargo run --example basic_encryptor -- -e /home/dargal/YUMI-2.0.1.6.exe   Compiling rust-crypto v0.2.31
failed to run custom build command for `rust-crypto v0.2.31`
Process didn't exit successfully: `/home/dargal/self_encryption/target/debug/build/rust-crypto-daa25690d0c0b110/build-script-build` (exit code: 101)
--- stdout
TARGET = Some("i686-unknown-linux-gnu")
CARGO_MANIFEST_DIR = Some("/home/dargal/.cargo/registry/src/github.com-1285ae84e5963aae/rust-crypto-0.2.31")
OUT_DIR = Some("/home/dargal/self_encryption/target/debug/build/rust-crypto-daa25690d0c0b110/out")
TARGET = Some("i686-unknown-linux-gnu")
OPT_LEVEL = Some("0")
PROFILE = Some("debug")
debug 0
TARGET = Some("i686-unknown-linux-gnu")
HOST = Some("i686-unknown-linux-gnu")
CC_i686-unknown-linux-gnu = None
CC_i686_unknown_linux_gnu = None
HOST_CC = None
CC = None
TARGET = Some("i686-unknown-linux-gnu")
HOST = Some("i686-unknown-linux-gnu")
CFLAGS_i686-unknown-linux-gnu = None
CFLAGS_i686_unknown_linux_gnu = None
HOST_CFLAGS = None
CFLAGS = None
TARGET = Some("i686-unknown-linux-gnu")
HOST = Some("i686-unknown-linux-gnu")
CC_i686-unknown-linux-gnu = None
CC_i686_unknown_linux_gnu = None
HOST_CC = None
CC = None
running: "cc" "-O0" "-c" "-ffunction-sections" "-fdata-sections" "-m32" "/home/dargal/.cargo/registry/src/github.com-1285ae84e5963aae/rust-crypto-0.2.31/src/util_helpers.c" "-o" "/home/dargal/self_encryption/target/debug/build/rust-crypto-daa25690d0c0b110/out/src/util_helpers.o"
TARGET = Some("i686-unknown-linux-gnu")
OPT_LEVEL = Some("0")
PROFILE = Some("debug")
debug 0
TARGET = Some("i686-unknown-linux-gnu")
HOST = Some("i686-unknown-linux-gnu")
CC_i686-unknown-linux-gnu = None
CC_i686_unknown_linux_gnu = None
HOST_CC = None
CC = None
TARGET = Some("i686-unknown-linux-gnu")
HOST = Some("i686-unknown-linux-gnu")
CFLAGS_i686-unknown-linux-gnu = None
CFLAGS_i686_unknown_linux_gnu = None
HOST_CFLAGS = None
CFLAGS = None
TARGET = Some("i686-unknown-linux-gnu")
HOST = Some("i686-unknown-linux-gnu")
CC_i686-unknown-linux-gnu = None
CC_i686_unknown_linux_gnu = None
HOST_CC = None
CC = None
running: "cc" "-O0" "-c" "-ffunction-sections" "-fdata-sections" "-m32" "/home/dargal/.cargo/registry/src/github.com-1285ae84e5963aae/rust-crypto-0.2.31/src/aesni_helpers.c" "-o" "/home/dargal/self_encryption/target/debug/build/rust-crypto-daa25690d0c0b110/out/src/aesni_helpers.o"


command did not execute successfully, got: exit code: 1



--- stderr
/home/dargal/.cargo/registry/src/github.com-1285ae84e5963aae/rust-crypto-0.2.31/src/aesni_helpers.c: In function ‘rust_crypto_aesni_aesimc’:
/home/dargal/.cargo/registry/src/github.com-1285ae84e5963aae/rust-crypto-0.2.31/src/aesni_helpers.c:12:5: error: unknown register name ‘xmm1’ in ‘asm’
/home/dargal/.cargo/registry/src/github.com-1285ae84e5963aae/rust-crypto-0.2.31/src/aesni_helpers.c: In function ‘rust_crypto_aesni_setup_working_key_128’:
/home/dargal/.cargo/registry/src/github.com-1285ae84e5963aae/rust-crypto-0.2.31/src/aesni_helpers.c:27:5: error: unknown register name ‘xmm3’ in ‘asm’
/home/dargal/.cargo/registry/src/github.com-1285ae84e5963aae/rust-crypto-0.2.31/src/aesni_helpers.c:27:5: error: unknown register name ‘xmm2’ in ‘asm’
/home/dargal/.cargo/registry/src/github.com-1285ae84e5963aae/rust-crypto-0.2.31/src/aesni_helpers.c:27:5: error: unknown register name ‘xmm1’ in ‘asm’
/home/dargal/.cargo/registry/src/github.com-1285ae84e5963aae/rust-crypto-0.2.31/src/aesni_helpers.c: In function ‘rust_crypto_aesni_setup_working_key_192’:
/home/dargal/.cargo/registry/src/github.com-1285ae84e5963aae/rust-crypto-0.2.31/src/aesni_helpers.c:80:5: error: unknown register name ‘xmm3’ in ‘asm’
/home/dargal/.cargo/registry/src/github.com-1285ae84e5963aae/rust-crypto-0.2.31/src/aesni_helpers.c:80:5: error: unknown register name ‘xmm2’ in ‘asm’
/home/dargal/.cargo/registry/src/github.com-1285ae84e5963aae/rust-crypto-0.2.31/src/aesni_helpers.c:80:5: error: unknown register name ‘xmm1’ in ‘asm’
/home/dargal/.cargo/registry/src/github.com-1285ae84e5963aae/rust-crypto-0.2.31/src/aesni_helpers.c: In function ‘rust_crypto_aesni_setup_working_key_256’:
/home/dargal/.cargo/registry/src/github.com-1285ae84e5963aae/rust-crypto-0.2.31/src/aesni_helpers.c:168:5: error: unknown register name ‘xmm3’ in ‘asm’
/home/dargal/.cargo/registry/src/github.com-1285ae84e5963aae/rust-crypto-0.2.31/src/aesni_helpers.c:168:5: error: unknown register name ‘xmm2’ in ‘asm’
/home/dargal/.cargo/registry/src/github.com-1285ae84e5963aae/rust-crypto-0.2.31/src/aesni_helpers.c:168:5: error: unknown register name ‘xmm1’ in ‘asm’
/home/dargal/.cargo/registry/src/github.com-1285ae84e5963aae/rust-crypto-0.2.31/src/aesni_helpers.c: In function ‘rust_crypto_aesni_encrypt_block’:
/home/dargal/.cargo/registry/src/github.com-1285ae84e5963aae/rust-crypto-0.2.31/src/aesni_helpers.c:266:5: error: unknown register name ‘xmm1’ in ‘asm’
/home/dargal/.cargo/registry/src/github.com-1285ae84e5963aae/rust-crypto-0.2.31/src/aesni_helpers.c:266:5: error: unknown register name ‘xmm0’ in ‘asm’
/home/dargal/.cargo/registry/src/github.com-1285ae84e5963aae/rust-crypto-0.2.31/src/aesni_helpers.c: In function ‘rust_crypto_aesni_decrypt_block’:
/home/dargal/.cargo/registry/src/github.com-1285ae84e5963aae/rust-crypto-0.2.31/src/aesni_helpers.c:303:5: error: unknown register name ‘xmm1’ in ‘asm’
/home/dargal/.cargo/registry/src/github.com-1285ae84e5963aae/rust-crypto-0.2.31/src/aesni_helpers.c:303:5: error: unknown register name ‘xmm0’ in ‘asm’
thread '<main>' panicked at 'explicit panic', /home/dargal/.cargo/registry/src/github.com-1285ae84e5963aae/gcc-0.3.5/src/lib.rs:384

and I can’t figure it out myself. Anyone ?

Have you installed gcc?

dargal@dargal:~/self_encryption$ gcc --version
gcc (Ubuntu/Linaro 4.6.3-1ubuntu5) 4.6.3
Copyright (C) 2011 Free Software Foundation, Inc.
This is free software; see the source for copying conditions.  There is NO
warranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.

It’s beyond me, I’m sorry :frowning:

I think you’re running 32 bit. SafeNet seems to require 64 bit.

Type

 gcc -v

You want the Target line to say something about 64 bits. Here’s mine from my linux machine and from my windows machine.

My Linux Box
$ gcc -v
Using built-in specs.
COLLECT_GCC=gcc
COLLECT_LTO_WRAPPER=/usr/lib/gcc/x86_64-linux-gnu/4.8/lto-wrapper
Target: x86_64-linux-gnu

My Windows Box
C>gcc -v
Using built-in specs.
COLLECT_GCC=gcc
COLLECT_LTO_WRAPPER=C:/Program\ Files/mingw-w64/x86_64-4.9.2-posix-seh-rt_v4-rev2/mingw64/bin/…/libexec/gcc/x86_64-w64-mingw32/4.9.2/lto-wrapper.exe
Target: x86_64-w64-mingw32

What does it say for your Target:?

Yeah I’m quite aware I’m running 32 bit system , didnt realize self encryption requires 64 bit though.

I could be wrong about that. I personally had problems when I had 32 bit gcc, but that may have been due to a mismatch between my rust version and my gcc version. Hopefully somebody will chime in and set me straight if I’m wrong.

Yeah but there is no mismatch between my rust version and my gcc version as they are both 32 bit.

Had the same error on my Ubuntu notepad. This was solved by adding the following command in my .bashrc file:
export CFLAGS=“-mmmx -msse”

With this export self_encryptor compiles and runs correctly (and my notepad has a 32 bits Ubuntu OS).