Skip to content

Commit

Permalink
Change header language to cpp.
Browse files Browse the repository at this point in the history
  • Loading branch information
samscott89 committed Dec 19, 2017
1 parent ca2645c commit 132aa0d
Show file tree
Hide file tree
Showing 4 changed files with 26 additions and 27 deletions.
2 changes: 1 addition & 1 deletion libpasta-capi/build.rs
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ use cbindgen::{Builder, Config, Language};
fn main() {
let crate_dir = env::var("CARGO_MANIFEST_DIR").unwrap();

let config = Config { language: Language::C, .. Config::default() };
let config = Config { language: Language::Cxx, .. Config::default() };

Builder::new()
.with_crate(crate_dir)
Expand Down
2 changes: 1 addition & 1 deletion libpasta-capi/ctest/compile.sh
Original file line number Diff line number Diff line change
Expand Up @@ -3,4 +3,4 @@
set -ex

cargo build --release --manifest-path ../Cargo.toml
gcc -DDEBUG -g -o test test.c -Wall -I../include -L../target/release -lpasta
g++ -DDEBUG -g -o test test.cpp -Wall -I../include -L../target/release -lpasta
4 changes: 2 additions & 2 deletions libpasta-capi/ctest/test.c → libpasta-capi/ctest/test.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -12,12 +12,12 @@ void test_hash_and_verify() {
}

void test_migrate() {
char *hash = "$2a$10$vI8aWBnW3fID.ZQ4/zo1G.q1lRps.9cGLcZEiGDMVr5yUP1KUOYTa";
char *hash = (char *)"$2a$10$vI8aWBnW3fID.ZQ4/zo1G.q1lRps.9cGLcZEiGDMVr5yUP1KUOYTa";
hash = migrate_hash(hash);
// printf("New hash: %s\n", hash);
free_string(hash);

hash = "$2a$10$vI8aWBnW3fID.ZQ4/zo1G.q1lRps.9cGLcZEiGDMVr5yUP1KUOYTa";
hash = (char *)"$2a$10$vI8aWBnW3fID.ZQ4/zo1G.q1lRps.9cGLcZEiGDMVr5yUP1KUOYTa";
char *newhash;
bool res = verify_password_update_hash_in_place(hash, "my password", &newhash);
assert (res);
Expand Down
45 changes: 22 additions & 23 deletions libpasta-capi/include/pasta-bindings.h
Original file line number Diff line number Diff line change
@@ -1,26 +1,23 @@
#include <stdint.h>
#include <stdlib.h>
#include <stdbool.h>

/*
* Holds possible configuration options
* See the [module level documentation](index.html) for more information.
*/
typedef struct Config Config;

/*
* Password hashing primitives
*
* Each variant is backed up by different implementation.
* Internally, primitives can either be static values, for example,
* the `lazy_static` generated value `DEFAULT_PRIM`, or dynamically allocated
* variables, which are `Arc<Box<...>>`.
*
* Most operations are expected to be performed using the static functions,
* since most use the default algorithms. However, the flexibilty to support
* arbitrary parameter sets is essential.
*/
typedef struct Primitive Primitive;
#include <cstdint>
#include <cstdlib>

// Holds possible configuration options
// See the [module level documentation](index.html) for more information.
struct Config;

// Password hashing primitives
//
// Each variant is backed up by different implementation.
// Internally, primitives can either be static values, for example,
// the `lazy_static` generated value `DEFAULT_PRIM`, or dynamically allocated
// variables, which are `Arc<Box<...>>`.
//
// Most operations are expected to be performed using the static functions,
// since most use the default algorithms. However, the flexibilty to support
// arbitrary parameter sets is essential.
struct Primitive;

extern "C" {

char *config_hash_password(const Config *config, const char *password);

Expand Down Expand Up @@ -64,3 +61,5 @@ char *read_password(const char *prompt);
bool verify_password(const char *hash, const char *password);

bool verify_password_update_hash_in_place(const char *hash, const char *password, char **new_hash);

} // extern "C"

0 comments on commit 132aa0d

Please sign in to comment.