<commit_before>// Copyright 2014 Google Inc. All rights reserved.
//
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
// You may obtain a copy of the License at
//
//     http://www.apache.org/licenses/LICENSE-2.0
//
// Unless required by applicable law or agreed to in writing, software
// distributed under the License is distributed on an "AS IS" BASIS,
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
// See the License for the specific language governing permissions and
// limitations under the License.

use libsodium_sys;
use secstr;
use argon2rs;

struct PublicKey(secstr::SecStr);
struct SecretKey(secstr::SecStr);

pub fn keyed_fingerprint(sk: &[u8],
                         msg: &[u8],
                         salt: &[u8; libsodium_sys::crypto_generichash_blake2b_SALTBYTES],
                         out: &mut [u8]) {
    let outlen = out.len();
    let personal: &[u8; libsodium_sys::crypto_generichash_blake2b_PERSONALBYTES] =
        b"hat-backup~~~~~a";

    let ret = unsafe {
        libsodium_sys::crypto_generichash_blake2b_salt_personal(out.as_mut_ptr(),
                                                                outlen,
                                                                msg.as_ptr(),
                                                                msg.len() as u64,
                                                                sk.as_ptr(),
                                                                sk.len(),
                                                                salt.as_ptr() as *const [u8; libsodium_sys::crypto_generichash_blake2b_SALTBYTES],
                                                                personal.as_ptr() as *const [u8; libsodium_sys::crypto_generichash_blake2b_PERSONALBYTES])
    };
    assert_eq!(ret, 0);
}

pub struct Keeper {
    universal_key: secstr::SecStr,
    fingerprint_key: Option<secstr::SecStr>,
    blob_authentication_key: Option<secstr::SecStr>,

    data_key_pk: Option<PublicKey>,
    data_key_sk: Option<SecretKey>,<commit_msg>Minor: Fix too long line.<commit_after>// Copyright 2014 Google Inc. All rights reserved.
//
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
// You may obtain a copy of the License at
//
//     http://www.apache.org/licenses/LICENSE-2.0
//
// Unless required by applicable law or agreed to in writing, software
// distributed under the License is distributed on an "AS IS" BASIS,
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
// See the License for the specific language governing permissions and
// limitations under the License.

use libsodium_sys;
use secstr;
use argon2rs;

struct PublicKey(secstr::SecStr);
struct SecretKey(secstr::SecStr);

pub fn keyed_fingerprint(sk: &[u8],
                         msg: &[u8],
                         salt: &[u8; libsodium_sys::crypto_generichash_blake2b_SALTBYTES],
                         out: &mut [u8]) {
    use libsodium_sys::{crypto_generichash_blake2b_SALTBYTES,
                        crypto_generichash_blake2b_PERSONALBYTES};

    let outlen = out.len();
    let personal: &[u8; libsodium_sys::crypto_generichash_blake2b_PERSONALBYTES] =
        b"hat-backup~~~~~a";

    let ret = unsafe {
        libsodium_sys::crypto_generichash_blake2b_salt_personal(
            out.as_mut_ptr(),
            outlen,
            msg.as_ptr(),
            msg.len() as u64,
            sk.as_ptr(),
            sk.len(),
            salt.as_ptr() as *const [u8; crypto_generichash_blake2b_SALTBYTES],
            personal.as_ptr() as *const [u8; crypto_generichash_blake2b_PERSONALBYTES])
    };
    assert_eq!(ret, 0);
}

pub struct Keeper {
    universal_key: secstr::SecStr,
    fingerprint_key: Option<secstr::SecStr>,
    blob_authentication_key: Option<secstr::SecStr>,

    data_key_pk: Option<PublicKey>,
    data_key_sk: Option<SecretKey>,
{'fraction_non_alphanumeric': 0.09657551120965756, 'fraction_numerical': 0.01231830500123183, 'mean_word_length': 2.111111111111111, 'pattern_counts': {'":': 0, '<': 11, '<?xml version=': 0, '>': 11, 'https://': 0, 'lorem ipsum': 0, 'www.': 2, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 14, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '6467463', 'n_tokens_mistral': 1198, 'n_tokens_neox': 1148, 'n_words': 311}