├── .gitignore ├── .golangci.yml ├── .pre-commit-config.yaml ├── .travis.yml ├── LICENSE ├── README.md ├── common └── client │ ├── client.go │ └── json.go ├── crypto ├── README.md ├── crypto.go ├── crypto_bench_test.go ├── crypto_test.go ├── errors.go ├── hashtype.go ├── helper.go ├── keytype.go ├── keytype_test.go ├── privatekey.go ├── publickey.go ├── random.go ├── stream.go └── wrapper │ ├── build │ ├── Dockerfile │ ├── Dockerfile_legacy │ ├── build_c_crypto.ps1 │ ├── build_c_crypto.sh │ ├── entrypoint_legacy.sh │ └── update_codegen.sh │ ├── foundation │ ├── aes256_cbc.go │ ├── aes256_cbc_test.go │ ├── aes256_gcm.go │ ├── aes256_gcm_test.go │ ├── alg.go │ ├── alg_factory.go │ ├── alg_id.go │ ├── alg_info.go │ ├── alg_info_der_deserializer.go │ ├── alg_info_der_serializer.go │ ├── alg_info_deserializer.go │ ├── alg_info_serializer.go │ ├── asn1_reader.go │ ├── asn1_tag.go │ ├── asn1_writer.go │ ├── asn1rd.go │ ├── asn1wr.go │ ├── asn1wr_test.go │ ├── auth_decrypt.go │ ├── auth_encrypt.go │ ├── base64.go │ ├── base64_test.go │ ├── brainkey_client.go │ ├── brainkey_server.go │ ├── cipher.go │ ├── cipher_alg_info.go │ ├── cipher_auth.go │ ├── cipher_auth_info.go │ ├── cipher_info.go │ ├── cipher_state.go │ ├── compound_key_alg.go │ ├── compound_key_alg_info.go │ ├── compound_private_key.go │ ├── compound_public_key.go │ ├── compute_shared_key.go │ ├── config_test.go │ ├── context.go │ ├── ctr_drbg.go │ ├── curve25519.go │ ├── decrypt.go │ ├── ecc.go │ ├── ecc_alg_info.go │ ├── ecc_private_key.go │ ├── ecc_public_key.go │ ├── ecc_test.go │ ├── ecies.go │ ├── ed25519.go │ ├── ed25519_test.go │ ├── encrypt.go │ ├── entropy_accumulator.go │ ├── entropy_source.go │ ├── fake_random.go │ ├── fake_random_test.go │ ├── falcon.go │ ├── footer_info.go │ ├── foundation_error.go │ ├── foundation_implementation.go │ ├── group_msg_type.go │ ├── group_session.go │ ├── group_session_message.go │ ├── group_session_ticket.go │ ├── hash.go │ ├── hash_based_alg_info.go │ ├── helper.go │ ├── hkdf.go │ ├── hmac.go │ ├── hybrid_key_alg.go │ ├── hybrid_key_alg_info.go │ ├── hybrid_private_key.go │ ├── hybrid_public_key.go │ ├── kdf.go │ ├── kdf1.go │ ├── kdf2.go │ ├── kem.go │ ├── key.go │ ├── key_alg.go │ ├── key_alg_factory.go │ ├── key_asn1_deserializer.go │ ├── key_asn1_serializer.go │ ├── key_cipher.go │ ├── key_deserializer.go │ ├── key_info.go │ ├── key_material_rng.go │ ├── key_provider.go │ ├── key_provider_test.go │ ├── key_recipient_info.go │ ├── key_recipient_info_list.go │ ├── key_serializer.go │ ├── key_signer.go │ ├── mac.go │ ├── message_info.go │ ├── message_info_custom_params.go │ ├── message_info_der_serializer.go │ ├── message_info_editor.go │ ├── message_info_footer.go │ ├── message_info_footer_serializer.go │ ├── message_info_serializer.go │ ├── oid.go │ ├── oid_id.go │ ├── padding.go │ ├── padding_params.go │ ├── password_recipient_info.go │ ├── password_recipient_info_list.go │ ├── pbe_alg_info.go │ ├── pem.go │ ├── pkcs5_pbes2.go │ ├── pkcs5_pbkdf2.go │ ├── pkcs8_serializer.go │ ├── platform.go │ ├── private_key.go │ ├── public_key.go │ ├── random.go │ ├── random_padding.go │ ├── raw_private_key.go │ ├── raw_public_key.go │ ├── recipient_cipher.go │ ├── recipient_cipher_test.go │ ├── round5.go │ ├── rsa.go │ ├── rsa_private_key.go │ ├── rsa_public_key.go │ ├── rsa_test.go │ ├── salted_kdf.go │ ├── salted_kdf_alg_info.go │ ├── sec1_serializer.go │ ├── seed_entropy_source.go │ ├── sha224.go │ ├── sha224_test.go │ ├── sha256.go │ ├── sha256_test.go │ ├── sha384.go │ ├── sha384_test.go │ ├── sha512.go │ ├── sha512_test.go │ ├── signed_data_info.go │ ├── signer.go │ ├── signer_info.go │ ├── signer_info_list.go │ ├── simple_alg_info.go │ ├── simple_alg_info_test.go │ └── verifier.go │ ├── phe │ ├── context.go │ ├── helper.go │ ├── phe_cipher.go │ ├── phe_cipher_test.go │ ├── phe_client.go │ ├── phe_client_test.go │ ├── phe_common.go │ ├── phe_error.go │ ├── phe_implementation.go │ ├── phe_server.go │ ├── phe_server_test.go │ ├── platform.go │ ├── uokms_client.go │ ├── uokms_server.go │ └── uokms_wrap_rotation.go │ └── pkg │ ├── darwin_amd64 │ ├── include │ │ ├── ed25519 │ │ │ ├── ed25519.h │ │ │ └── ed25519_sha512.h │ │ ├── falcon │ │ │ ├── config.h │ │ │ ├── falcon.h │ │ │ ├── fpr.h │ │ │ └── inner.h │ │ ├── mbedtls │ │ │ ├── aes.h │ │ │ ├── aesni.h │ │ │ ├── arc4.h │ │ │ ├── aria.h │ │ │ ├── asn1.h │ │ │ ├── asn1write.h │ │ │ ├── base64.h │ │ │ ├── bignum.h │ │ │ ├── blowfish.h │ │ │ ├── bn_mul.h │ │ │ ├── camellia.h │ │ │ ├── ccm.h │ │ │ ├── certs.h │ │ │ ├── chacha20.h │ │ │ ├── chachapoly.h │ │ │ ├── check_config.h │ │ │ ├── cipher.h │ │ │ ├── cipher_internal.h │ │ │ ├── cmac.h │ │ │ ├── compat-1.3.h │ │ │ ├── config.h │ │ │ ├── ctr_drbg.h │ │ │ ├── debug.h │ │ │ ├── des.h │ │ │ ├── dhm.h │ │ │ ├── ecdh.h │ │ │ ├── ecdsa.h │ │ │ ├── ecjpake.h │ │ │ ├── ecp.h │ │ │ ├── ecp_internal.h │ │ │ ├── entropy.h │ │ │ ├── entropy_poll.h │ │ │ ├── error.h │ │ │ ├── fake_alt.h │ │ │ ├── gcm.h │ │ │ ├── havege.h │ │ │ ├── hkdf.h │ │ │ ├── hmac_drbg.h │ │ │ ├── md.h │ │ │ ├── md2.h │ │ │ ├── md4.h │ │ │ ├── md5.h │ │ │ ├── md_internal.h │ │ │ ├── memory_buffer_alloc.h │ │ │ ├── net.h │ │ │ ├── net_sockets.h │ │ │ ├── nist_kw.h │ │ │ ├── oid.h │ │ │ ├── padlock.h │ │ │ ├── pem.h │ │ │ ├── pk.h │ │ │ ├── pk_internal.h │ │ │ ├── pkcs11.h │ │ │ ├── pkcs12.h │ │ │ ├── pkcs5.h │ │ │ ├── platform.h │ │ │ ├── platform_time.h │ │ │ ├── platform_util.h │ │ │ ├── poly1305.h │ │ │ ├── ripemd160.h │ │ │ ├── rsa.h │ │ │ ├── rsa_internal.h │ │ │ ├── sha1.h │ │ │ ├── sha256.h │ │ │ ├── sha512.h │ │ │ ├── ssl.h │ │ │ ├── ssl_cache.h │ │ │ ├── ssl_ciphersuites.h │ │ │ ├── ssl_cookie.h │ │ │ ├── ssl_internal.h │ │ │ ├── ssl_ticket.h │ │ │ ├── threading.h │ │ │ ├── timing.h │ │ │ ├── version.h │ │ │ ├── x509.h │ │ │ ├── x509_crl.h │ │ │ ├── x509_crt.h │ │ │ ├── x509_csr.h │ │ │ └── xtea.h │ │ ├── pb.h │ │ ├── pb_common.h │ │ ├── pb_decode.h │ │ ├── pb_encode.h │ │ ├── round5 │ │ │ ├── a_fixed.h │ │ │ ├── a_random.h │ │ │ ├── checkPublicParameter.h │ │ │ ├── chooseparameters.h │ │ │ ├── drbg.h │ │ │ ├── f202sp800185.h │ │ │ ├── keccakf1600.h │ │ │ ├── kem.h │ │ │ ├── little_endian.h │ │ │ ├── matmul.h │ │ │ ├── misc.h │ │ │ ├── pack.h │ │ │ ├── pke.h │ │ │ ├── r5_cca_kem.h │ │ │ ├── r5_cca_pke.h │ │ │ ├── r5_cpa_kem.h │ │ │ ├── r5_cpa_pke.h │ │ │ ├── r5_dem.h │ │ │ ├── r5_hash.h │ │ │ ├── r5_memory.h │ │ │ ├── r5_parameter_sets.h │ │ │ ├── r5_secretkeygen.h │ │ │ ├── ringmul.h │ │ │ ├── rng.h │ │ │ └── xef.h │ │ └── virgil │ │ │ └── crypto │ │ │ ├── common │ │ │ ├── private │ │ │ │ ├── vsc_atomic.h │ │ │ │ ├── vsc_buffer_defs.h │ │ │ │ └── vsc_common_private.h │ │ │ ├── vsc_assert.h │ │ │ ├── vsc_buffer.h │ │ │ ├── vsc_common_public.h │ │ │ ├── vsc_data.h │ │ │ ├── vsc_library.h │ │ │ ├── vsc_memory.h │ │ │ └── vsc_platform.h │ │ │ ├── foundation │ │ │ ├── private │ │ │ │ ├── vscf_aes256_cbc_defs.h │ │ │ │ ├── vscf_aes256_gcm_defs.h │ │ │ │ ├── vscf_alg_api.h │ │ │ │ ├── vscf_alg_info_api.h │ │ │ │ ├── vscf_alg_info_der_deserializer_defs.h │ │ │ │ ├── vscf_alg_info_der_serializer_defs.h │ │ │ │ ├── vscf_alg_info_deserializer_api.h │ │ │ │ ├── vscf_alg_info_serializer_api.h │ │ │ │ ├── vscf_api_private.h │ │ │ │ ├── vscf_asn1_reader_api.h │ │ │ │ ├── vscf_asn1_writer_api.h │ │ │ │ ├── vscf_asn1rd_defs.h │ │ │ │ ├── vscf_asn1wr_defs.h │ │ │ │ ├── vscf_atomic.h │ │ │ │ ├── vscf_auth_decrypt_api.h │ │ │ │ ├── vscf_auth_encrypt_api.h │ │ │ │ ├── vscf_cipher_alg_info_defs.h │ │ │ │ ├── vscf_cipher_api.h │ │ │ │ ├── vscf_cipher_auth_api.h │ │ │ │ ├── vscf_cipher_auth_info_api.h │ │ │ │ ├── vscf_cipher_info_api.h │ │ │ │ ├── vscf_compound_key_alg_defs.h │ │ │ │ ├── vscf_compound_key_alg_info_defs.h │ │ │ │ ├── vscf_compound_private_key_defs.h │ │ │ │ ├── vscf_compound_public_key_defs.h │ │ │ │ ├── vscf_compute_shared_key_api.h │ │ │ │ ├── vscf_ctr_drbg_defs.h │ │ │ │ ├── vscf_curve25519_defs.h │ │ │ │ ├── vscf_decrypt_api.h │ │ │ │ ├── vscf_defaults_api.h │ │ │ │ ├── vscf_ec_alg_info_defs.h │ │ │ │ ├── vscf_ecc_alg_info_defs.h │ │ │ │ ├── vscf_ecc_defs.h │ │ │ │ ├── vscf_ecc_private_key_defs.h │ │ │ │ ├── vscf_ecc_public_key_defs.h │ │ │ │ ├── vscf_ecies_defs.h │ │ │ │ ├── vscf_ed25519_defs.h │ │ │ │ ├── vscf_encrypt_api.h │ │ │ │ ├── vscf_endianness.h │ │ │ │ ├── vscf_entropy_accumulator_defs.h │ │ │ │ ├── vscf_entropy_source_api.h │ │ │ │ ├── vscf_fake_random_defs.h │ │ │ │ ├── vscf_falcon_defs.h │ │ │ │ ├── vscf_footer_info_defs.h │ │ │ │ ├── vscf_foundation_private.h │ │ │ │ ├── vscf_generate_ephemeral_key_api.h │ │ │ │ ├── vscf_generate_key_api.h │ │ │ │ ├── vscf_group_session_message_defs.h │ │ │ │ ├── vscf_group_session_ticket_defs.h │ │ │ │ ├── vscf_hash_api.h │ │ │ │ ├── vscf_hash_based_alg_info_defs.h │ │ │ │ ├── vscf_hkdf_defs.h │ │ │ │ ├── vscf_hkdf_private.h │ │ │ │ ├── vscf_hmac_defs.h │ │ │ │ ├── vscf_hybrid_key_alg_defs.h │ │ │ │ ├── vscf_hybrid_key_alg_info_defs.h │ │ │ │ ├── vscf_hybrid_private_key_defs.h │ │ │ │ ├── vscf_hybrid_public_key_defs.h │ │ │ │ ├── vscf_impl_private.h │ │ │ │ ├── vscf_kdf1_defs.h │ │ │ │ ├── vscf_kdf2_defs.h │ │ │ │ ├── vscf_kdf_api.h │ │ │ │ ├── vscf_kem_api.h │ │ │ │ ├── vscf_key_alg_api.h │ │ │ │ ├── vscf_key_api.h │ │ │ │ ├── vscf_key_asn1_deserializer_defs.h │ │ │ │ ├── vscf_key_asn1_serializer_defs.h │ │ │ │ ├── vscf_key_cipher_api.h │ │ │ │ ├── vscf_key_deserializer_api.h │ │ │ │ ├── vscf_key_info_defs.h │ │ │ │ ├── vscf_key_material_rng_defs.h │ │ │ │ ├── vscf_key_provider_defs.h │ │ │ │ ├── vscf_key_recipient_info_defs.h │ │ │ │ ├── vscf_key_recipient_info_list_defs.h │ │ │ │ ├── vscf_key_serializer_api.h │ │ │ │ ├── vscf_key_signer_api.h │ │ │ │ ├── vscf_list_key_value_node_defs.h │ │ │ │ ├── vscf_mac_api.h │ │ │ │ ├── vscf_mac_info_api.h │ │ │ │ ├── vscf_mac_stream_api.h │ │ │ │ ├── vscf_mbedtls_bridge_entropy.h │ │ │ │ ├── vscf_mbedtls_bridge_random.h │ │ │ │ ├── vscf_message_cipher.h │ │ │ │ ├── vscf_message_info_custom_params_defs.h │ │ │ │ ├── vscf_message_info_defs.h │ │ │ │ ├── vscf_message_info_der_serializer_defs.h │ │ │ │ ├── vscf_message_info_editor_defs.h │ │ │ │ ├── vscf_message_info_footer_defs.h │ │ │ │ ├── vscf_message_info_footer_serializer_api.h │ │ │ │ ├── vscf_message_info_serializer_api.h │ │ │ │ ├── vscf_message_padding.h │ │ │ │ ├── vscf_padding_api.h │ │ │ │ ├── vscf_padding_params_defs.h │ │ │ │ ├── vscf_password_recipient_info_defs.h │ │ │ │ ├── vscf_password_recipient_info_list_defs.h │ │ │ │ ├── vscf_pbe_alg_info_defs.h │ │ │ │ ├── vscf_pkcs5_pbes2_defs.h │ │ │ │ ├── vscf_pkcs5_pbkdf2_defs.h │ │ │ │ ├── vscf_pkcs8_der_serializer_defs.h │ │ │ │ ├── vscf_pkcs8_serializer_defs.h │ │ │ │ ├── vscf_private_key_api.h │ │ │ │ ├── vscf_public_key_api.h │ │ │ │ ├── vscf_random_api.h │ │ │ │ ├── vscf_random_padding_defs.h │ │ │ │ ├── vscf_raw_key_defs.h │ │ │ │ ├── vscf_raw_private_key_defs.h │ │ │ │ ├── vscf_raw_public_key_defs.h │ │ │ │ ├── vscf_recipient_cipher_decryption_state.h │ │ │ │ ├── vscf_recipient_cipher_defs.h │ │ │ │ ├── vscf_round5_defs.h │ │ │ │ ├── vscf_rsa_defs.h │ │ │ │ ├── vscf_rsa_private_key_defs.h │ │ │ │ ├── vscf_rsa_public_key_defs.h │ │ │ │ ├── vscf_salted_kdf_alg_info_defs.h │ │ │ │ ├── vscf_salted_kdf_api.h │ │ │ │ ├── vscf_sec1_serializer_defs.h │ │ │ │ ├── vscf_seed_entropy_source_defs.h │ │ │ │ ├── vscf_sha224_defs.h │ │ │ │ ├── vscf_sha256_defs.h │ │ │ │ ├── vscf_sha384_defs.h │ │ │ │ ├── vscf_sha512_defs.h │ │ │ │ ├── vscf_sign_hash_api.h │ │ │ │ ├── vscf_signed_data_info_defs.h │ │ │ │ ├── vscf_signer_defs.h │ │ │ │ ├── vscf_signer_info_defs.h │ │ │ │ ├── vscf_signer_info_list_defs.h │ │ │ │ ├── vscf_simple_alg_info_defs.h │ │ │ │ ├── vscf_simple_swu.h │ │ │ │ ├── vscf_verifier_defs.h │ │ │ │ └── vscf_verify_hash_api.h │ │ │ ├── vscf_GroupMessage.pb.h │ │ │ ├── vscf_aes256_cbc.h │ │ │ ├── vscf_aes256_gcm.h │ │ │ ├── vscf_alg.h │ │ │ ├── vscf_alg_factory.h │ │ │ ├── vscf_alg_id.h │ │ │ ├── vscf_alg_info.h │ │ │ ├── vscf_alg_info_der_deserializer.h │ │ │ ├── vscf_alg_info_der_serializer.h │ │ │ ├── vscf_alg_info_deserializer.h │ │ │ ├── vscf_alg_info_serializer.h │ │ │ ├── vscf_api.h │ │ │ ├── vscf_asn1_reader.h │ │ │ ├── vscf_asn1_tag.h │ │ │ ├── vscf_asn1_writer.h │ │ │ ├── vscf_asn1rd.h │ │ │ ├── vscf_asn1wr.h │ │ │ ├── vscf_assert.h │ │ │ ├── vscf_auth_decrypt.h │ │ │ ├── vscf_auth_encrypt.h │ │ │ ├── vscf_base64.h │ │ │ ├── vscf_brainkey_client.h │ │ │ ├── vscf_brainkey_server.h │ │ │ ├── vscf_cipher.h │ │ │ ├── vscf_cipher_alg_info.h │ │ │ ├── vscf_cipher_auth.h │ │ │ ├── vscf_cipher_auth_info.h │ │ │ ├── vscf_cipher_info.h │ │ │ ├── vscf_cipher_state.h │ │ │ ├── vscf_compound_key_alg.h │ │ │ ├── vscf_compound_key_alg_info.h │ │ │ ├── vscf_compound_private_key.h │ │ │ ├── vscf_compound_public_key.h │ │ │ ├── vscf_compute_shared_key.h │ │ │ ├── vscf_ctr_drbg.h │ │ │ ├── vscf_curve25519.h │ │ │ ├── vscf_decrypt.h │ │ │ ├── vscf_defaults.h │ │ │ ├── vscf_ec_alg_info.h │ │ │ ├── vscf_ecc.h │ │ │ ├── vscf_ecc_alg_info.h │ │ │ ├── vscf_ecc_private_key.h │ │ │ ├── vscf_ecc_public_key.h │ │ │ ├── vscf_ecies.h │ │ │ ├── vscf_ed25519.h │ │ │ ├── vscf_encrypt.h │ │ │ ├── vscf_entropy_accumulator.h │ │ │ ├── vscf_entropy_source.h │ │ │ ├── vscf_error.h │ │ │ ├── vscf_fake_random.h │ │ │ ├── vscf_falcon.h │ │ │ ├── vscf_footer_info.h │ │ │ ├── vscf_foundation_public.h │ │ │ ├── vscf_generate_ephemeral_key.h │ │ │ ├── vscf_generate_key.h │ │ │ ├── vscf_group_msg_type.h │ │ │ ├── vscf_group_session.h │ │ │ ├── vscf_group_session_message.h │ │ │ ├── vscf_group_session_ticket.h │ │ │ ├── vscf_hash.h │ │ │ ├── vscf_hash_based_alg_info.h │ │ │ ├── vscf_hkdf.h │ │ │ ├── vscf_hmac.h │ │ │ ├── vscf_hybrid_key_alg.h │ │ │ ├── vscf_hybrid_key_alg_info.h │ │ │ ├── vscf_hybrid_private_key.h │ │ │ ├── vscf_hybrid_public_key.h │ │ │ ├── vscf_impl.h │ │ │ ├── vscf_kdf.h │ │ │ ├── vscf_kdf1.h │ │ │ ├── vscf_kdf2.h │ │ │ ├── vscf_kem.h │ │ │ ├── vscf_key.h │ │ │ ├── vscf_key_alg.h │ │ │ ├── vscf_key_alg_factory.h │ │ │ ├── vscf_key_asn1_deserializer.h │ │ │ ├── vscf_key_asn1_serializer.h │ │ │ ├── vscf_key_cipher.h │ │ │ ├── vscf_key_deserializer.h │ │ │ ├── vscf_key_info.h │ │ │ ├── vscf_key_material_rng.h │ │ │ ├── vscf_key_provider.h │ │ │ ├── vscf_key_recipient_info.h │ │ │ ├── vscf_key_recipient_info_list.h │ │ │ ├── vscf_key_serializer.h │ │ │ ├── vscf_key_signer.h │ │ │ ├── vscf_library.h │ │ │ ├── vscf_list_key_value_node.h │ │ │ ├── vscf_mac.h │ │ │ ├── vscf_mac_info.h │ │ │ ├── vscf_mac_stream.h │ │ │ ├── vscf_memory.h │ │ │ ├── vscf_message_info.h │ │ │ ├── vscf_message_info_custom_params.h │ │ │ ├── vscf_message_info_der_serializer.h │ │ │ ├── vscf_message_info_editor.h │ │ │ ├── vscf_message_info_footer.h │ │ │ ├── vscf_message_info_footer_serializer.h │ │ │ ├── vscf_message_info_serializer.h │ │ │ ├── vscf_oid.h │ │ │ ├── vscf_oid_id.h │ │ │ ├── vscf_padding.h │ │ │ ├── vscf_padding_params.h │ │ │ ├── vscf_password_recipient_info.h │ │ │ ├── vscf_password_recipient_info_list.h │ │ │ ├── vscf_pbe_alg_info.h │ │ │ ├── vscf_pem.h │ │ │ ├── vscf_pkcs5_pbes2.h │ │ │ ├── vscf_pkcs5_pbkdf2.h │ │ │ ├── vscf_pkcs8_der_serializer.h │ │ │ ├── vscf_pkcs8_serializer.h │ │ │ ├── vscf_platform.h │ │ │ ├── vscf_private_key.h │ │ │ ├── vscf_public_key.h │ │ │ ├── vscf_random.h │ │ │ ├── vscf_random_padding.h │ │ │ ├── vscf_raw_key.h │ │ │ ├── vscf_raw_private_key.h │ │ │ ├── vscf_raw_public_key.h │ │ │ ├── vscf_recipient_cipher.h │ │ │ ├── vscf_round5.h │ │ │ ├── vscf_rsa.h │ │ │ ├── vscf_rsa_private_key.h │ │ │ ├── vscf_rsa_public_key.h │ │ │ ├── vscf_salted_kdf.h │ │ │ ├── vscf_salted_kdf_alg_info.h │ │ │ ├── vscf_sec1_serializer.h │ │ │ ├── vscf_seed_entropy_source.h │ │ │ ├── vscf_sha224.h │ │ │ ├── vscf_sha256.h │ │ │ ├── vscf_sha384.h │ │ │ ├── vscf_sha512.h │ │ │ ├── vscf_sign_hash.h │ │ │ ├── vscf_signed_data_info.h │ │ │ ├── vscf_signer.h │ │ │ ├── vscf_signer_info.h │ │ │ ├── vscf_signer_info_list.h │ │ │ ├── vscf_simple_alg_info.h │ │ │ ├── vscf_status.h │ │ │ ├── vscf_verifier.h │ │ │ └── vscf_verify_hash.h │ │ │ └── phe │ │ │ ├── PHEModels.pb.h │ │ │ ├── UOKMSModels.pb.h │ │ │ ├── private │ │ │ ├── vsce_atomic.h │ │ │ ├── vsce_phe_hash_defs.h │ │ │ └── vsce_phe_private.h │ │ │ ├── vsce_assert.h │ │ │ ├── vsce_error.h │ │ │ ├── vsce_library.h │ │ │ ├── vsce_memory.h │ │ │ ├── vsce_phe_cipher.h │ │ │ ├── vsce_phe_client.h │ │ │ ├── vsce_phe_common.h │ │ │ ├── vsce_phe_public.h │ │ │ ├── vsce_phe_server.h │ │ │ ├── vsce_platform.h │ │ │ ├── vsce_status.h │ │ │ ├── vsce_uokms_client.h │ │ │ ├── vsce_uokms_server.h │ │ │ └── vsce_uokms_wrap_rotation.h │ └── lib │ │ ├── libed25519.a │ │ ├── libfalcon.a │ │ ├── libmbedcrypto.a │ │ ├── libprotobuf-nanopb.a │ │ ├── libround5.a │ │ ├── libvsc_common.a │ │ ├── libvsc_foundation.a │ │ ├── libvsc_foundation_pb.a │ │ ├── libvsc_phe.a │ │ └── libvsc_phe_pb.a │ ├── linux_amd64 │ ├── include │ │ ├── ed25519 │ │ │ ├── ed25519.h │ │ │ └── ed25519_sha512.h │ │ ├── falcon │ │ │ ├── config.h │ │ │ ├── falcon.h │ │ │ ├── fpr.h │ │ │ └── inner.h │ │ ├── mbedtls │ │ │ ├── aes.h │ │ │ ├── aesni.h │ │ │ ├── arc4.h │ │ │ ├── aria.h │ │ │ ├── asn1.h │ │ │ ├── asn1write.h │ │ │ ├── base64.h │ │ │ ├── bignum.h │ │ │ ├── blowfish.h │ │ │ ├── bn_mul.h │ │ │ ├── camellia.h │ │ │ ├── ccm.h │ │ │ ├── certs.h │ │ │ ├── chacha20.h │ │ │ ├── chachapoly.h │ │ │ ├── check_config.h │ │ │ ├── cipher.h │ │ │ ├── cipher_internal.h │ │ │ ├── cmac.h │ │ │ ├── compat-1.3.h │ │ │ ├── config.h │ │ │ ├── ctr_drbg.h │ │ │ ├── debug.h │ │ │ ├── des.h │ │ │ ├── dhm.h │ │ │ ├── ecdh.h │ │ │ ├── ecdsa.h │ │ │ ├── ecjpake.h │ │ │ ├── ecp.h │ │ │ ├── ecp_internal.h │ │ │ ├── entropy.h │ │ │ ├── entropy_poll.h │ │ │ ├── error.h │ │ │ ├── fake_alt.h │ │ │ ├── gcm.h │ │ │ ├── havege.h │ │ │ ├── hkdf.h │ │ │ ├── hmac_drbg.h │ │ │ ├── md.h │ │ │ ├── md2.h │ │ │ ├── md4.h │ │ │ ├── md5.h │ │ │ ├── md_internal.h │ │ │ ├── memory_buffer_alloc.h │ │ │ ├── net.h │ │ │ ├── net_sockets.h │ │ │ ├── nist_kw.h │ │ │ ├── oid.h │ │ │ ├── padlock.h │ │ │ ├── pem.h │ │ │ ├── pk.h │ │ │ ├── pk_internal.h │ │ │ ├── pkcs11.h │ │ │ ├── pkcs12.h │ │ │ ├── pkcs5.h │ │ │ ├── platform.h │ │ │ ├── platform_time.h │ │ │ ├── platform_util.h │ │ │ ├── poly1305.h │ │ │ ├── ripemd160.h │ │ │ ├── rsa.h │ │ │ ├── rsa_internal.h │ │ │ ├── sha1.h │ │ │ ├── sha256.h │ │ │ ├── sha512.h │ │ │ ├── ssl.h │ │ │ ├── ssl_cache.h │ │ │ ├── ssl_ciphersuites.h │ │ │ ├── ssl_cookie.h │ │ │ ├── ssl_internal.h │ │ │ ├── ssl_ticket.h │ │ │ ├── threading.h │ │ │ ├── timing.h │ │ │ ├── version.h │ │ │ ├── x509.h │ │ │ ├── x509_crl.h │ │ │ ├── x509_crt.h │ │ │ ├── x509_csr.h │ │ │ └── xtea.h │ │ ├── pb.h │ │ ├── pb_common.h │ │ ├── pb_decode.h │ │ ├── pb_encode.h │ │ ├── round5 │ │ │ ├── a_fixed.h │ │ │ ├── a_random.h │ │ │ ├── checkPublicParameter.h │ │ │ ├── chooseparameters.h │ │ │ ├── drbg.h │ │ │ ├── f202sp800185.h │ │ │ ├── keccakf1600.h │ │ │ ├── kem.h │ │ │ ├── little_endian.h │ │ │ ├── matmul.h │ │ │ ├── misc.h │ │ │ ├── pack.h │ │ │ ├── pke.h │ │ │ ├── r5_cca_kem.h │ │ │ ├── r5_cca_pke.h │ │ │ ├── r5_cpa_kem.h │ │ │ ├── r5_cpa_pke.h │ │ │ ├── r5_dem.h │ │ │ ├── r5_hash.h │ │ │ ├── r5_memory.h │ │ │ ├── r5_parameter_sets.h │ │ │ ├── r5_secretkeygen.h │ │ │ ├── ringmul.h │ │ │ ├── rng.h │ │ │ └── xef.h │ │ └── virgil │ │ │ └── crypto │ │ │ ├── common │ │ │ ├── private │ │ │ │ ├── vsc_atomic.h │ │ │ │ ├── vsc_buffer_defs.h │ │ │ │ └── vsc_common_private.h │ │ │ ├── vsc_assert.h │ │ │ ├── vsc_buffer.h │ │ │ ├── vsc_common_public.h │ │ │ ├── vsc_data.h │ │ │ ├── vsc_library.h │ │ │ ├── vsc_memory.h │ │ │ └── vsc_platform.h │ │ │ ├── foundation │ │ │ ├── private │ │ │ │ ├── vscf_aes256_cbc_defs.h │ │ │ │ ├── vscf_aes256_gcm_defs.h │ │ │ │ ├── vscf_alg_api.h │ │ │ │ ├── vscf_alg_info_api.h │ │ │ │ ├── vscf_alg_info_der_deserializer_defs.h │ │ │ │ ├── vscf_alg_info_der_serializer_defs.h │ │ │ │ ├── vscf_alg_info_deserializer_api.h │ │ │ │ ├── vscf_alg_info_serializer_api.h │ │ │ │ ├── vscf_api_private.h │ │ │ │ ├── vscf_asn1_reader_api.h │ │ │ │ ├── vscf_asn1_writer_api.h │ │ │ │ ├── vscf_asn1rd_defs.h │ │ │ │ ├── vscf_asn1wr_defs.h │ │ │ │ ├── vscf_atomic.h │ │ │ │ ├── vscf_auth_decrypt_api.h │ │ │ │ ├── vscf_auth_encrypt_api.h │ │ │ │ ├── vscf_cipher_alg_info_defs.h │ │ │ │ ├── vscf_cipher_api.h │ │ │ │ ├── vscf_cipher_auth_api.h │ │ │ │ ├── vscf_cipher_auth_info_api.h │ │ │ │ ├── vscf_cipher_info_api.h │ │ │ │ ├── vscf_compound_key_alg_defs.h │ │ │ │ ├── vscf_compound_key_alg_info_defs.h │ │ │ │ ├── vscf_compound_private_key_defs.h │ │ │ │ ├── vscf_compound_public_key_defs.h │ │ │ │ ├── vscf_compute_shared_key_api.h │ │ │ │ ├── vscf_ctr_drbg_defs.h │ │ │ │ ├── vscf_curve25519_defs.h │ │ │ │ ├── vscf_decrypt_api.h │ │ │ │ ├── vscf_defaults_api.h │ │ │ │ ├── vscf_ec_alg_info_defs.h │ │ │ │ ├── vscf_ecc_alg_info_defs.h │ │ │ │ ├── vscf_ecc_defs.h │ │ │ │ ├── vscf_ecc_private_key_defs.h │ │ │ │ ├── vscf_ecc_public_key_defs.h │ │ │ │ ├── vscf_ecies_defs.h │ │ │ │ ├── vscf_ed25519_defs.h │ │ │ │ ├── vscf_encrypt_api.h │ │ │ │ ├── vscf_endianness.h │ │ │ │ ├── vscf_entropy_accumulator_defs.h │ │ │ │ ├── vscf_entropy_source_api.h │ │ │ │ ├── vscf_fake_random_defs.h │ │ │ │ ├── vscf_falcon_defs.h │ │ │ │ ├── vscf_footer_info_defs.h │ │ │ │ ├── vscf_foundation_private.h │ │ │ │ ├── vscf_generate_ephemeral_key_api.h │ │ │ │ ├── vscf_generate_key_api.h │ │ │ │ ├── vscf_group_session_message_defs.h │ │ │ │ ├── vscf_group_session_ticket_defs.h │ │ │ │ ├── vscf_hash_api.h │ │ │ │ ├── vscf_hash_based_alg_info_defs.h │ │ │ │ ├── vscf_hkdf_defs.h │ │ │ │ ├── vscf_hkdf_private.h │ │ │ │ ├── vscf_hmac_defs.h │ │ │ │ ├── vscf_hybrid_key_alg_defs.h │ │ │ │ ├── vscf_hybrid_key_alg_info_defs.h │ │ │ │ ├── vscf_hybrid_private_key_defs.h │ │ │ │ ├── vscf_hybrid_public_key_defs.h │ │ │ │ ├── vscf_impl_private.h │ │ │ │ ├── vscf_kdf1_defs.h │ │ │ │ ├── vscf_kdf2_defs.h │ │ │ │ ├── vscf_kdf_api.h │ │ │ │ ├── vscf_kem_api.h │ │ │ │ ├── vscf_key_alg_api.h │ │ │ │ ├── vscf_key_api.h │ │ │ │ ├── vscf_key_asn1_deserializer_defs.h │ │ │ │ ├── vscf_key_asn1_serializer_defs.h │ │ │ │ ├── vscf_key_cipher_api.h │ │ │ │ ├── vscf_key_deserializer_api.h │ │ │ │ ├── vscf_key_info_defs.h │ │ │ │ ├── vscf_key_material_rng_defs.h │ │ │ │ ├── vscf_key_provider_defs.h │ │ │ │ ├── vscf_key_recipient_info_defs.h │ │ │ │ ├── vscf_key_recipient_info_list_defs.h │ │ │ │ ├── vscf_key_serializer_api.h │ │ │ │ ├── vscf_key_signer_api.h │ │ │ │ ├── vscf_list_key_value_node_defs.h │ │ │ │ ├── vscf_mac_api.h │ │ │ │ ├── vscf_mac_info_api.h │ │ │ │ ├── vscf_mac_stream_api.h │ │ │ │ ├── vscf_mbedtls_bridge_entropy.h │ │ │ │ ├── vscf_mbedtls_bridge_random.h │ │ │ │ ├── vscf_message_cipher.h │ │ │ │ ├── vscf_message_info_custom_params_defs.h │ │ │ │ ├── vscf_message_info_defs.h │ │ │ │ ├── vscf_message_info_der_serializer_defs.h │ │ │ │ ├── vscf_message_info_editor_defs.h │ │ │ │ ├── vscf_message_info_footer_defs.h │ │ │ │ ├── vscf_message_info_footer_serializer_api.h │ │ │ │ ├── vscf_message_info_serializer_api.h │ │ │ │ ├── vscf_message_padding.h │ │ │ │ ├── vscf_padding_api.h │ │ │ │ ├── vscf_padding_params_defs.h │ │ │ │ ├── vscf_password_recipient_info_defs.h │ │ │ │ ├── vscf_password_recipient_info_list_defs.h │ │ │ │ ├── vscf_pbe_alg_info_defs.h │ │ │ │ ├── vscf_pkcs5_pbes2_defs.h │ │ │ │ ├── vscf_pkcs5_pbkdf2_defs.h │ │ │ │ ├── vscf_pkcs8_der_serializer_defs.h │ │ │ │ ├── vscf_pkcs8_serializer_defs.h │ │ │ │ ├── vscf_private_key_api.h │ │ │ │ ├── vscf_public_key_api.h │ │ │ │ ├── vscf_random_api.h │ │ │ │ ├── vscf_random_padding_defs.h │ │ │ │ ├── vscf_raw_key_defs.h │ │ │ │ ├── vscf_raw_private_key_defs.h │ │ │ │ ├── vscf_raw_public_key_defs.h │ │ │ │ ├── vscf_recipient_cipher_decryption_state.h │ │ │ │ ├── vscf_recipient_cipher_defs.h │ │ │ │ ├── vscf_round5_defs.h │ │ │ │ ├── vscf_rsa_defs.h │ │ │ │ ├── vscf_rsa_private_key_defs.h │ │ │ │ ├── vscf_rsa_public_key_defs.h │ │ │ │ ├── vscf_salted_kdf_alg_info_defs.h │ │ │ │ ├── vscf_salted_kdf_api.h │ │ │ │ ├── vscf_sec1_serializer_defs.h │ │ │ │ ├── vscf_seed_entropy_source_defs.h │ │ │ │ ├── vscf_sha224_defs.h │ │ │ │ ├── vscf_sha256_defs.h │ │ │ │ ├── vscf_sha384_defs.h │ │ │ │ ├── vscf_sha512_defs.h │ │ │ │ ├── vscf_sign_hash_api.h │ │ │ │ ├── vscf_signed_data_info_defs.h │ │ │ │ ├── vscf_signer_defs.h │ │ │ │ ├── vscf_signer_info_defs.h │ │ │ │ ├── vscf_signer_info_list_defs.h │ │ │ │ ├── vscf_simple_alg_info_defs.h │ │ │ │ ├── vscf_simple_swu.h │ │ │ │ ├── vscf_verifier_defs.h │ │ │ │ └── vscf_verify_hash_api.h │ │ │ ├── vscf_GroupMessage.pb.h │ │ │ ├── vscf_aes256_cbc.h │ │ │ ├── vscf_aes256_gcm.h │ │ │ ├── vscf_alg.h │ │ │ ├── vscf_alg_factory.h │ │ │ ├── vscf_alg_id.h │ │ │ ├── vscf_alg_info.h │ │ │ ├── vscf_alg_info_der_deserializer.h │ │ │ ├── vscf_alg_info_der_serializer.h │ │ │ ├── vscf_alg_info_deserializer.h │ │ │ ├── vscf_alg_info_serializer.h │ │ │ ├── vscf_api.h │ │ │ ├── vscf_asn1_reader.h │ │ │ ├── vscf_asn1_tag.h │ │ │ ├── vscf_asn1_writer.h │ │ │ ├── vscf_asn1rd.h │ │ │ ├── vscf_asn1wr.h │ │ │ ├── vscf_assert.h │ │ │ ├── vscf_auth_decrypt.h │ │ │ ├── vscf_auth_encrypt.h │ │ │ ├── vscf_base64.h │ │ │ ├── vscf_brainkey_client.h │ │ │ ├── vscf_brainkey_server.h │ │ │ ├── vscf_cipher.h │ │ │ ├── vscf_cipher_alg_info.h │ │ │ ├── vscf_cipher_auth.h │ │ │ ├── vscf_cipher_auth_info.h │ │ │ ├── vscf_cipher_info.h │ │ │ ├── vscf_cipher_state.h │ │ │ ├── vscf_compound_key_alg.h │ │ │ ├── vscf_compound_key_alg_info.h │ │ │ ├── vscf_compound_private_key.h │ │ │ ├── vscf_compound_public_key.h │ │ │ ├── vscf_compute_shared_key.h │ │ │ ├── vscf_ctr_drbg.h │ │ │ ├── vscf_curve25519.h │ │ │ ├── vscf_decrypt.h │ │ │ ├── vscf_defaults.h │ │ │ ├── vscf_ec_alg_info.h │ │ │ ├── vscf_ecc.h │ │ │ ├── vscf_ecc_alg_info.h │ │ │ ├── vscf_ecc_private_key.h │ │ │ ├── vscf_ecc_public_key.h │ │ │ ├── vscf_ecies.h │ │ │ ├── vscf_ed25519.h │ │ │ ├── vscf_encrypt.h │ │ │ ├── vscf_entropy_accumulator.h │ │ │ ├── vscf_entropy_source.h │ │ │ ├── vscf_error.h │ │ │ ├── vscf_fake_random.h │ │ │ ├── vscf_falcon.h │ │ │ ├── vscf_footer_info.h │ │ │ ├── vscf_foundation_public.h │ │ │ ├── vscf_generate_ephemeral_key.h │ │ │ ├── vscf_generate_key.h │ │ │ ├── vscf_group_msg_type.h │ │ │ ├── vscf_group_session.h │ │ │ ├── vscf_group_session_message.h │ │ │ ├── vscf_group_session_ticket.h │ │ │ ├── vscf_hash.h │ │ │ ├── vscf_hash_based_alg_info.h │ │ │ ├── vscf_hkdf.h │ │ │ ├── vscf_hmac.h │ │ │ ├── vscf_hybrid_key_alg.h │ │ │ ├── vscf_hybrid_key_alg_info.h │ │ │ ├── vscf_hybrid_private_key.h │ │ │ ├── vscf_hybrid_public_key.h │ │ │ ├── vscf_impl.h │ │ │ ├── vscf_kdf.h │ │ │ ├── vscf_kdf1.h │ │ │ ├── vscf_kdf2.h │ │ │ ├── vscf_kem.h │ │ │ ├── vscf_key.h │ │ │ ├── vscf_key_alg.h │ │ │ ├── vscf_key_alg_factory.h │ │ │ ├── vscf_key_asn1_deserializer.h │ │ │ ├── vscf_key_asn1_serializer.h │ │ │ ├── vscf_key_cipher.h │ │ │ ├── vscf_key_deserializer.h │ │ │ ├── vscf_key_info.h │ │ │ ├── vscf_key_material_rng.h │ │ │ ├── vscf_key_provider.h │ │ │ ├── vscf_key_recipient_info.h │ │ │ ├── vscf_key_recipient_info_list.h │ │ │ ├── vscf_key_serializer.h │ │ │ ├── vscf_key_signer.h │ │ │ ├── vscf_library.h │ │ │ ├── vscf_list_key_value_node.h │ │ │ ├── vscf_mac.h │ │ │ ├── vscf_mac_info.h │ │ │ ├── vscf_mac_stream.h │ │ │ ├── vscf_memory.h │ │ │ ├── vscf_message_info.h │ │ │ ├── vscf_message_info_custom_params.h │ │ │ ├── vscf_message_info_der_serializer.h │ │ │ ├── vscf_message_info_editor.h │ │ │ ├── vscf_message_info_footer.h │ │ │ ├── vscf_message_info_footer_serializer.h │ │ │ ├── vscf_message_info_serializer.h │ │ │ ├── vscf_oid.h │ │ │ ├── vscf_oid_id.h │ │ │ ├── vscf_padding.h │ │ │ ├── vscf_padding_params.h │ │ │ ├── vscf_password_recipient_info.h │ │ │ ├── vscf_password_recipient_info_list.h │ │ │ ├── vscf_pbe_alg_info.h │ │ │ ├── vscf_pem.h │ │ │ ├── vscf_pkcs5_pbes2.h │ │ │ ├── vscf_pkcs5_pbkdf2.h │ │ │ ├── vscf_pkcs8_der_serializer.h │ │ │ ├── vscf_pkcs8_serializer.h │ │ │ ├── vscf_platform.h │ │ │ ├── vscf_private_key.h │ │ │ ├── vscf_public_key.h │ │ │ ├── vscf_random.h │ │ │ ├── vscf_random_padding.h │ │ │ ├── vscf_raw_key.h │ │ │ ├── vscf_raw_private_key.h │ │ │ ├── vscf_raw_public_key.h │ │ │ ├── vscf_recipient_cipher.h │ │ │ ├── vscf_round5.h │ │ │ ├── vscf_rsa.h │ │ │ ├── vscf_rsa_private_key.h │ │ │ ├── vscf_rsa_public_key.h │ │ │ ├── vscf_salted_kdf.h │ │ │ ├── vscf_salted_kdf_alg_info.h │ │ │ ├── vscf_sec1_serializer.h │ │ │ ├── vscf_seed_entropy_source.h │ │ │ ├── vscf_sha224.h │ │ │ ├── vscf_sha256.h │ │ │ ├── vscf_sha384.h │ │ │ ├── vscf_sha512.h │ │ │ ├── vscf_sign_hash.h │ │ │ ├── vscf_signed_data_info.h │ │ │ ├── vscf_signer.h │ │ │ ├── vscf_signer_info.h │ │ │ ├── vscf_signer_info_list.h │ │ │ ├── vscf_simple_alg_info.h │ │ │ ├── vscf_status.h │ │ │ ├── vscf_verifier.h │ │ │ └── vscf_verify_hash.h │ │ │ └── phe │ │ │ ├── PHEModels.pb.h │ │ │ ├── UOKMSModels.pb.h │ │ │ ├── private │ │ │ ├── vsce_atomic.h │ │ │ ├── vsce_phe_hash_defs.h │ │ │ └── vsce_phe_private.h │ │ │ ├── vsce_assert.h │ │ │ ├── vsce_error.h │ │ │ ├── vsce_library.h │ │ │ ├── vsce_memory.h │ │ │ ├── vsce_phe_cipher.h │ │ │ ├── vsce_phe_client.h │ │ │ ├── vsce_phe_common.h │ │ │ ├── vsce_phe_public.h │ │ │ ├── vsce_phe_server.h │ │ │ ├── vsce_platform.h │ │ │ ├── vsce_status.h │ │ │ ├── vsce_uokms_client.h │ │ │ ├── vsce_uokms_server.h │ │ │ └── vsce_uokms_wrap_rotation.h │ └── lib │ │ ├── libed25519.a │ │ ├── libfalcon.a │ │ ├── libmbedcrypto.a │ │ ├── libprotobuf-nanopb.a │ │ ├── libround5.a │ │ ├── libvsc_common.a │ │ ├── libvsc_foundation.a │ │ ├── libvsc_foundation_pb.a │ │ ├── libvsc_phe.a │ │ └── libvsc_phe_pb.a │ ├── linux_amd64__legacy_os │ ├── include │ │ ├── ed25519 │ │ │ ├── ed25519.h │ │ │ └── ed25519_sha512.h │ │ ├── falcon │ │ │ ├── config.h │ │ │ ├── falcon.h │ │ │ ├── fpr.h │ │ │ └── inner.h │ │ ├── mbedtls │ │ │ ├── aes.h │ │ │ ├── aesni.h │ │ │ ├── arc4.h │ │ │ ├── aria.h │ │ │ ├── asn1.h │ │ │ ├── asn1write.h │ │ │ ├── base64.h │ │ │ ├── bignum.h │ │ │ ├── blowfish.h │ │ │ ├── bn_mul.h │ │ │ ├── camellia.h │ │ │ ├── ccm.h │ │ │ ├── certs.h │ │ │ ├── chacha20.h │ │ │ ├── chachapoly.h │ │ │ ├── check_config.h │ │ │ ├── cipher.h │ │ │ ├── cipher_internal.h │ │ │ ├── cmac.h │ │ │ ├── compat-1.3.h │ │ │ ├── config.h │ │ │ ├── ctr_drbg.h │ │ │ ├── debug.h │ │ │ ├── des.h │ │ │ ├── dhm.h │ │ │ ├── ecdh.h │ │ │ ├── ecdsa.h │ │ │ ├── ecjpake.h │ │ │ ├── ecp.h │ │ │ ├── ecp_internal.h │ │ │ ├── entropy.h │ │ │ ├── entropy_poll.h │ │ │ ├── error.h │ │ │ ├── fake_alt.h │ │ │ ├── gcm.h │ │ │ ├── havege.h │ │ │ ├── hkdf.h │ │ │ ├── hmac_drbg.h │ │ │ ├── md.h │ │ │ ├── md2.h │ │ │ ├── md4.h │ │ │ ├── md5.h │ │ │ ├── md_internal.h │ │ │ ├── memory_buffer_alloc.h │ │ │ ├── net.h │ │ │ ├── net_sockets.h │ │ │ ├── nist_kw.h │ │ │ ├── oid.h │ │ │ ├── padlock.h │ │ │ ├── pem.h │ │ │ ├── pk.h │ │ │ ├── pk_internal.h │ │ │ ├── pkcs11.h │ │ │ ├── pkcs12.h │ │ │ ├── pkcs5.h │ │ │ ├── platform.h │ │ │ ├── platform_time.h │ │ │ ├── platform_util.h │ │ │ ├── poly1305.h │ │ │ ├── ripemd160.h │ │ │ ├── rsa.h │ │ │ ├── rsa_internal.h │ │ │ ├── sha1.h │ │ │ ├── sha256.h │ │ │ ├── sha512.h │ │ │ ├── ssl.h │ │ │ ├── ssl_cache.h │ │ │ ├── ssl_ciphersuites.h │ │ │ ├── ssl_cookie.h │ │ │ ├── ssl_internal.h │ │ │ ├── ssl_ticket.h │ │ │ ├── threading.h │ │ │ ├── timing.h │ │ │ ├── version.h │ │ │ ├── x509.h │ │ │ ├── x509_crl.h │ │ │ ├── x509_crt.h │ │ │ ├── x509_csr.h │ │ │ └── xtea.h │ │ ├── pb.h │ │ ├── pb_common.h │ │ ├── pb_decode.h │ │ ├── pb_encode.h │ │ ├── round5 │ │ │ ├── a_fixed.h │ │ │ ├── a_random.h │ │ │ ├── checkPublicParameter.h │ │ │ ├── chooseparameters.h │ │ │ ├── drbg.h │ │ │ ├── f202sp800185.h │ │ │ ├── keccakf1600.h │ │ │ ├── kem.h │ │ │ ├── little_endian.h │ │ │ ├── matmul.h │ │ │ ├── misc.h │ │ │ ├── pack.h │ │ │ ├── pke.h │ │ │ ├── r5_cca_kem.h │ │ │ ├── r5_cca_pke.h │ │ │ ├── r5_cpa_kem.h │ │ │ ├── r5_cpa_pke.h │ │ │ ├── r5_dem.h │ │ │ ├── r5_hash.h │ │ │ ├── r5_memory.h │ │ │ ├── r5_parameter_sets.h │ │ │ ├── r5_secretkeygen.h │ │ │ ├── ringmul.h │ │ │ ├── rng.h │ │ │ └── xef.h │ │ └── virgil │ │ │ └── crypto │ │ │ ├── common │ │ │ ├── private │ │ │ │ ├── vsc_atomic.h │ │ │ │ ├── vsc_buffer_defs.h │ │ │ │ └── vsc_common_private.h │ │ │ ├── vsc_assert.h │ │ │ ├── vsc_buffer.h │ │ │ ├── vsc_common_public.h │ │ │ ├── vsc_data.h │ │ │ ├── vsc_library.h │ │ │ ├── vsc_memory.h │ │ │ └── vsc_platform.h │ │ │ ├── foundation │ │ │ ├── private │ │ │ │ ├── vscf_aes256_cbc_defs.h │ │ │ │ ├── vscf_aes256_gcm_defs.h │ │ │ │ ├── vscf_alg_api.h │ │ │ │ ├── vscf_alg_info_api.h │ │ │ │ ├── vscf_alg_info_der_deserializer_defs.h │ │ │ │ ├── vscf_alg_info_der_serializer_defs.h │ │ │ │ ├── vscf_alg_info_deserializer_api.h │ │ │ │ ├── vscf_alg_info_serializer_api.h │ │ │ │ ├── vscf_api_private.h │ │ │ │ ├── vscf_asn1_reader_api.h │ │ │ │ ├── vscf_asn1_writer_api.h │ │ │ │ ├── vscf_asn1rd_defs.h │ │ │ │ ├── vscf_asn1wr_defs.h │ │ │ │ ├── vscf_atomic.h │ │ │ │ ├── vscf_auth_decrypt_api.h │ │ │ │ ├── vscf_auth_encrypt_api.h │ │ │ │ ├── vscf_cipher_alg_info_defs.h │ │ │ │ ├── vscf_cipher_api.h │ │ │ │ ├── vscf_cipher_auth_api.h │ │ │ │ ├── vscf_cipher_auth_info_api.h │ │ │ │ ├── vscf_cipher_info_api.h │ │ │ │ ├── vscf_compound_key_alg_defs.h │ │ │ │ ├── vscf_compound_key_alg_info_defs.h │ │ │ │ ├── vscf_compound_private_key_defs.h │ │ │ │ ├── vscf_compound_public_key_defs.h │ │ │ │ ├── vscf_compute_shared_key_api.h │ │ │ │ ├── vscf_ctr_drbg_defs.h │ │ │ │ ├── vscf_curve25519_defs.h │ │ │ │ ├── vscf_decrypt_api.h │ │ │ │ ├── vscf_defaults_api.h │ │ │ │ ├── vscf_ec_alg_info_defs.h │ │ │ │ ├── vscf_ecc_alg_info_defs.h │ │ │ │ ├── vscf_ecc_defs.h │ │ │ │ ├── vscf_ecc_private_key_defs.h │ │ │ │ ├── vscf_ecc_public_key_defs.h │ │ │ │ ├── vscf_ecies_defs.h │ │ │ │ ├── vscf_ed25519_defs.h │ │ │ │ ├── vscf_encrypt_api.h │ │ │ │ ├── vscf_endianness.h │ │ │ │ ├── vscf_entropy_accumulator_defs.h │ │ │ │ ├── vscf_entropy_source_api.h │ │ │ │ ├── vscf_fake_random_defs.h │ │ │ │ ├── vscf_falcon_defs.h │ │ │ │ ├── vscf_footer_info_defs.h │ │ │ │ ├── vscf_foundation_private.h │ │ │ │ ├── vscf_generate_ephemeral_key_api.h │ │ │ │ ├── vscf_generate_key_api.h │ │ │ │ ├── vscf_group_session_message_defs.h │ │ │ │ ├── vscf_group_session_ticket_defs.h │ │ │ │ ├── vscf_hash_api.h │ │ │ │ ├── vscf_hash_based_alg_info_defs.h │ │ │ │ ├── vscf_hkdf_defs.h │ │ │ │ ├── vscf_hkdf_private.h │ │ │ │ ├── vscf_hmac_defs.h │ │ │ │ ├── vscf_hybrid_key_alg_defs.h │ │ │ │ ├── vscf_hybrid_key_alg_info_defs.h │ │ │ │ ├── vscf_hybrid_private_key_defs.h │ │ │ │ ├── vscf_hybrid_public_key_defs.h │ │ │ │ ├── vscf_impl_private.h │ │ │ │ ├── vscf_kdf1_defs.h │ │ │ │ ├── vscf_kdf2_defs.h │ │ │ │ ├── vscf_kdf_api.h │ │ │ │ ├── vscf_kem_api.h │ │ │ │ ├── vscf_key_alg_api.h │ │ │ │ ├── vscf_key_api.h │ │ │ │ ├── vscf_key_asn1_deserializer_defs.h │ │ │ │ ├── vscf_key_asn1_serializer_defs.h │ │ │ │ ├── vscf_key_cipher_api.h │ │ │ │ ├── vscf_key_deserializer_api.h │ │ │ │ ├── vscf_key_info_defs.h │ │ │ │ ├── vscf_key_material_rng_defs.h │ │ │ │ ├── vscf_key_provider_defs.h │ │ │ │ ├── vscf_key_recipient_info_defs.h │ │ │ │ ├── vscf_key_recipient_info_list_defs.h │ │ │ │ ├── vscf_key_serializer_api.h │ │ │ │ ├── vscf_key_signer_api.h │ │ │ │ ├── vscf_list_key_value_node_defs.h │ │ │ │ ├── vscf_mac_api.h │ │ │ │ ├── vscf_mac_info_api.h │ │ │ │ ├── vscf_mac_stream_api.h │ │ │ │ ├── vscf_mbedtls_bridge_entropy.h │ │ │ │ ├── vscf_mbedtls_bridge_random.h │ │ │ │ ├── vscf_message_cipher.h │ │ │ │ ├── vscf_message_info_custom_params_defs.h │ │ │ │ ├── vscf_message_info_defs.h │ │ │ │ ├── vscf_message_info_der_serializer_defs.h │ │ │ │ ├── vscf_message_info_editor_defs.h │ │ │ │ ├── vscf_message_info_footer_defs.h │ │ │ │ ├── vscf_message_info_footer_serializer_api.h │ │ │ │ ├── vscf_message_info_serializer_api.h │ │ │ │ ├── vscf_message_padding.h │ │ │ │ ├── vscf_padding_api.h │ │ │ │ ├── vscf_padding_params_defs.h │ │ │ │ ├── vscf_password_recipient_info_defs.h │ │ │ │ ├── vscf_password_recipient_info_list_defs.h │ │ │ │ ├── vscf_pbe_alg_info_defs.h │ │ │ │ ├── vscf_pkcs5_pbes2_defs.h │ │ │ │ ├── vscf_pkcs5_pbkdf2_defs.h │ │ │ │ ├── vscf_pkcs8_der_serializer_defs.h │ │ │ │ ├── vscf_pkcs8_serializer_defs.h │ │ │ │ ├── vscf_private_key_api.h │ │ │ │ ├── vscf_public_key_api.h │ │ │ │ ├── vscf_random_api.h │ │ │ │ ├── vscf_random_padding_defs.h │ │ │ │ ├── vscf_raw_key_defs.h │ │ │ │ ├── vscf_raw_private_key_defs.h │ │ │ │ ├── vscf_raw_public_key_defs.h │ │ │ │ ├── vscf_recipient_cipher_decryption_state.h │ │ │ │ ├── vscf_recipient_cipher_defs.h │ │ │ │ ├── vscf_round5_defs.h │ │ │ │ ├── vscf_rsa_defs.h │ │ │ │ ├── vscf_rsa_private_key_defs.h │ │ │ │ ├── vscf_rsa_public_key_defs.h │ │ │ │ ├── vscf_salted_kdf_alg_info_defs.h │ │ │ │ ├── vscf_salted_kdf_api.h │ │ │ │ ├── vscf_sec1_serializer_defs.h │ │ │ │ ├── vscf_seed_entropy_source_defs.h │ │ │ │ ├── vscf_sha224_defs.h │ │ │ │ ├── vscf_sha256_defs.h │ │ │ │ ├── vscf_sha384_defs.h │ │ │ │ ├── vscf_sha512_defs.h │ │ │ │ ├── vscf_sign_hash_api.h │ │ │ │ ├── vscf_signed_data_info_defs.h │ │ │ │ ├── vscf_signer_defs.h │ │ │ │ ├── vscf_signer_info_defs.h │ │ │ │ ├── vscf_signer_info_list_defs.h │ │ │ │ ├── vscf_simple_alg_info_defs.h │ │ │ │ ├── vscf_simple_swu.h │ │ │ │ ├── vscf_verifier_defs.h │ │ │ │ └── vscf_verify_hash_api.h │ │ │ ├── vscf_GroupMessage.pb.h │ │ │ ├── vscf_aes256_cbc.h │ │ │ ├── vscf_aes256_gcm.h │ │ │ ├── vscf_alg.h │ │ │ ├── vscf_alg_factory.h │ │ │ ├── vscf_alg_id.h │ │ │ ├── vscf_alg_info.h │ │ │ ├── vscf_alg_info_der_deserializer.h │ │ │ ├── vscf_alg_info_der_serializer.h │ │ │ ├── vscf_alg_info_deserializer.h │ │ │ ├── vscf_alg_info_serializer.h │ │ │ ├── vscf_api.h │ │ │ ├── vscf_asn1_reader.h │ │ │ ├── vscf_asn1_tag.h │ │ │ ├── vscf_asn1_writer.h │ │ │ ├── vscf_asn1rd.h │ │ │ ├── vscf_asn1wr.h │ │ │ ├── vscf_assert.h │ │ │ ├── vscf_auth_decrypt.h │ │ │ ├── vscf_auth_encrypt.h │ │ │ ├── vscf_base64.h │ │ │ ├── vscf_brainkey_client.h │ │ │ ├── vscf_brainkey_server.h │ │ │ ├── vscf_cipher.h │ │ │ ├── vscf_cipher_alg_info.h │ │ │ ├── vscf_cipher_auth.h │ │ │ ├── vscf_cipher_auth_info.h │ │ │ ├── vscf_cipher_info.h │ │ │ ├── vscf_cipher_state.h │ │ │ ├── vscf_compound_key_alg.h │ │ │ ├── vscf_compound_key_alg_info.h │ │ │ ├── vscf_compound_private_key.h │ │ │ ├── vscf_compound_public_key.h │ │ │ ├── vscf_compute_shared_key.h │ │ │ ├── vscf_ctr_drbg.h │ │ │ ├── vscf_curve25519.h │ │ │ ├── vscf_decrypt.h │ │ │ ├── vscf_defaults.h │ │ │ ├── vscf_ec_alg_info.h │ │ │ ├── vscf_ecc.h │ │ │ ├── vscf_ecc_alg_info.h │ │ │ ├── vscf_ecc_private_key.h │ │ │ ├── vscf_ecc_public_key.h │ │ │ ├── vscf_ecies.h │ │ │ ├── vscf_ed25519.h │ │ │ ├── vscf_encrypt.h │ │ │ ├── vscf_entropy_accumulator.h │ │ │ ├── vscf_entropy_source.h │ │ │ ├── vscf_error.h │ │ │ ├── vscf_fake_random.h │ │ │ ├── vscf_falcon.h │ │ │ ├── vscf_footer_info.h │ │ │ ├── vscf_foundation_public.h │ │ │ ├── vscf_generate_ephemeral_key.h │ │ │ ├── vscf_generate_key.h │ │ │ ├── vscf_group_msg_type.h │ │ │ ├── vscf_group_session.h │ │ │ ├── vscf_group_session_message.h │ │ │ ├── vscf_group_session_ticket.h │ │ │ ├── vscf_hash.h │ │ │ ├── vscf_hash_based_alg_info.h │ │ │ ├── vscf_hkdf.h │ │ │ ├── vscf_hmac.h │ │ │ ├── vscf_hybrid_key_alg.h │ │ │ ├── vscf_hybrid_key_alg_info.h │ │ │ ├── vscf_hybrid_private_key.h │ │ │ ├── vscf_hybrid_public_key.h │ │ │ ├── vscf_impl.h │ │ │ ├── vscf_kdf.h │ │ │ ├── vscf_kdf1.h │ │ │ ├── vscf_kdf2.h │ │ │ ├── vscf_kem.h │ │ │ ├── vscf_key.h │ │ │ ├── vscf_key_alg.h │ │ │ ├── vscf_key_alg_factory.h │ │ │ ├── vscf_key_asn1_deserializer.h │ │ │ ├── vscf_key_asn1_serializer.h │ │ │ ├── vscf_key_cipher.h │ │ │ ├── vscf_key_deserializer.h │ │ │ ├── vscf_key_info.h │ │ │ ├── vscf_key_material_rng.h │ │ │ ├── vscf_key_provider.h │ │ │ ├── vscf_key_recipient_info.h │ │ │ ├── vscf_key_recipient_info_list.h │ │ │ ├── vscf_key_serializer.h │ │ │ ├── vscf_key_signer.h │ │ │ ├── vscf_library.h │ │ │ ├── vscf_list_key_value_node.h │ │ │ ├── vscf_mac.h │ │ │ ├── vscf_mac_info.h │ │ │ ├── vscf_mac_stream.h │ │ │ ├── vscf_memory.h │ │ │ ├── vscf_message_info.h │ │ │ ├── vscf_message_info_custom_params.h │ │ │ ├── vscf_message_info_der_serializer.h │ │ │ ├── vscf_message_info_editor.h │ │ │ ├── vscf_message_info_footer.h │ │ │ ├── vscf_message_info_footer_serializer.h │ │ │ ├── vscf_message_info_serializer.h │ │ │ ├── vscf_oid.h │ │ │ ├── vscf_oid_id.h │ │ │ ├── vscf_padding.h │ │ │ ├── vscf_padding_params.h │ │ │ ├── vscf_password_recipient_info.h │ │ │ ├── vscf_password_recipient_info_list.h │ │ │ ├── vscf_pbe_alg_info.h │ │ │ ├── vscf_pem.h │ │ │ ├── vscf_pkcs5_pbes2.h │ │ │ ├── vscf_pkcs5_pbkdf2.h │ │ │ ├── vscf_pkcs8_der_serializer.h │ │ │ ├── vscf_pkcs8_serializer.h │ │ │ ├── vscf_platform.h │ │ │ ├── vscf_private_key.h │ │ │ ├── vscf_public_key.h │ │ │ ├── vscf_random.h │ │ │ ├── vscf_random_padding.h │ │ │ ├── vscf_raw_key.h │ │ │ ├── vscf_raw_private_key.h │ │ │ ├── vscf_raw_public_key.h │ │ │ ├── vscf_recipient_cipher.h │ │ │ ├── vscf_round5.h │ │ │ ├── vscf_rsa.h │ │ │ ├── vscf_rsa_private_key.h │ │ │ ├── vscf_rsa_public_key.h │ │ │ ├── vscf_salted_kdf.h │ │ │ ├── vscf_salted_kdf_alg_info.h │ │ │ ├── vscf_sec1_serializer.h │ │ │ ├── vscf_seed_entropy_source.h │ │ │ ├── vscf_sha224.h │ │ │ ├── vscf_sha256.h │ │ │ ├── vscf_sha384.h │ │ │ ├── vscf_sha512.h │ │ │ ├── vscf_sign_hash.h │ │ │ ├── vscf_signed_data_info.h │ │ │ ├── vscf_signer.h │ │ │ ├── vscf_signer_info.h │ │ │ ├── vscf_signer_info_list.h │ │ │ ├── vscf_simple_alg_info.h │ │ │ ├── vscf_status.h │ │ │ ├── vscf_verifier.h │ │ │ └── vscf_verify_hash.h │ │ │ └── phe │ │ │ ├── PHEModels.pb.h │ │ │ ├── UOKMSModels.pb.h │ │ │ ├── private │ │ │ ├── vsce_atomic.h │ │ │ ├── vsce_phe_hash_defs.h │ │ │ └── vsce_phe_private.h │ │ │ ├── vsce_assert.h │ │ │ ├── vsce_error.h │ │ │ ├── vsce_library.h │ │ │ ├── vsce_memory.h │ │ │ ├── vsce_phe_cipher.h │ │ │ ├── vsce_phe_client.h │ │ │ ├── vsce_phe_common.h │ │ │ ├── vsce_phe_public.h │ │ │ ├── vsce_phe_server.h │ │ │ ├── vsce_platform.h │ │ │ ├── vsce_status.h │ │ │ ├── vsce_uokms_client.h │ │ │ ├── vsce_uokms_server.h │ │ │ └── vsce_uokms_wrap_rotation.h │ └── lib │ │ ├── libed25519.a │ │ ├── libfalcon.a │ │ ├── libmbedcrypto.a │ │ ├── libprotobuf-nanopb.a │ │ ├── libround5.a │ │ ├── libvsc_common.a │ │ ├── libvsc_foundation.a │ │ ├── libvsc_foundation_pb.a │ │ ├── libvsc_phe.a │ │ └── libvsc_phe_pb.a │ └── windows_amd64 │ ├── include │ ├── ed25519 │ │ ├── ed25519.h │ │ └── ed25519_sha512.h │ ├── falcon │ │ ├── config.h │ │ ├── falcon.h │ │ ├── fpr.h │ │ └── inner.h │ ├── mbedtls │ │ ├── aes.h │ │ ├── aesni.h │ │ ├── arc4.h │ │ ├── aria.h │ │ ├── asn1.h │ │ ├── asn1write.h │ │ ├── base64.h │ │ ├── bignum.h │ │ ├── blowfish.h │ │ ├── bn_mul.h │ │ ├── camellia.h │ │ ├── ccm.h │ │ ├── certs.h │ │ ├── chacha20.h │ │ ├── chachapoly.h │ │ ├── check_config.h │ │ ├── cipher.h │ │ ├── cipher_internal.h │ │ ├── cmac.h │ │ ├── compat-1.3.h │ │ ├── config.h │ │ ├── ctr_drbg.h │ │ ├── debug.h │ │ ├── des.h │ │ ├── dhm.h │ │ ├── ecdh.h │ │ ├── ecdsa.h │ │ ├── ecjpake.h │ │ ├── ecp.h │ │ ├── ecp_internal.h │ │ ├── entropy.h │ │ ├── entropy_poll.h │ │ ├── error.h │ │ ├── fake_alt.h │ │ ├── gcm.h │ │ ├── havege.h │ │ ├── hkdf.h │ │ ├── hmac_drbg.h │ │ ├── md.h │ │ ├── md2.h │ │ ├── md4.h │ │ ├── md5.h │ │ ├── md_internal.h │ │ ├── memory_buffer_alloc.h │ │ ├── net.h │ │ ├── net_sockets.h │ │ ├── nist_kw.h │ │ ├── oid.h │ │ ├── padlock.h │ │ ├── pem.h │ │ ├── pk.h │ │ ├── pk_internal.h │ │ ├── pkcs11.h │ │ ├── pkcs12.h │ │ ├── pkcs5.h │ │ ├── platform.h │ │ ├── platform_time.h │ │ ├── platform_util.h │ │ ├── poly1305.h │ │ ├── ripemd160.h │ │ ├── rsa.h │ │ ├── rsa_internal.h │ │ ├── sha1.h │ │ ├── sha256.h │ │ ├── sha512.h │ │ ├── ssl.h │ │ ├── ssl_cache.h │ │ ├── ssl_ciphersuites.h │ │ ├── ssl_cookie.h │ │ ├── ssl_internal.h │ │ ├── ssl_ticket.h │ │ ├── threading.h │ │ ├── timing.h │ │ ├── version.h │ │ ├── x509.h │ │ ├── x509_crl.h │ │ ├── x509_crt.h │ │ ├── x509_csr.h │ │ └── xtea.h │ ├── pb.h │ ├── pb_common.h │ ├── pb_decode.h │ ├── pb_encode.h │ ├── round5 │ │ ├── a_fixed.h │ │ ├── a_random.h │ │ ├── checkPublicParameter.h │ │ ├── chooseparameters.h │ │ ├── drbg.h │ │ ├── f202sp800185.h │ │ ├── keccakf1600.h │ │ ├── kem.h │ │ ├── little_endian.h │ │ ├── matmul.h │ │ ├── misc.h │ │ ├── pack.h │ │ ├── pke.h │ │ ├── r5_cca_kem.h │ │ ├── r5_cca_pke.h │ │ ├── r5_cpa_kem.h │ │ ├── r5_cpa_pke.h │ │ ├── r5_dem.h │ │ ├── r5_hash.h │ │ ├── r5_memory.h │ │ ├── r5_parameter_sets.h │ │ ├── r5_secretkeygen.h │ │ ├── ringmul.h │ │ ├── rng.h │ │ └── xef.h │ └── virgil │ │ └── crypto │ │ ├── common │ │ ├── private │ │ │ ├── vsc_atomic.h │ │ │ ├── vsc_buffer_defs.h │ │ │ └── vsc_common_private.h │ │ ├── vsc_assert.h │ │ ├── vsc_buffer.h │ │ ├── vsc_common_public.h │ │ ├── vsc_data.h │ │ ├── vsc_library.h │ │ ├── vsc_memory.h │ │ └── vsc_platform.h │ │ ├── foundation │ │ ├── private │ │ │ ├── vscf_aes256_cbc_defs.h │ │ │ ├── vscf_aes256_gcm_defs.h │ │ │ ├── vscf_alg_api.h │ │ │ ├── vscf_alg_info_api.h │ │ │ ├── vscf_alg_info_der_deserializer_defs.h │ │ │ ├── vscf_alg_info_der_serializer_defs.h │ │ │ ├── vscf_alg_info_deserializer_api.h │ │ │ ├── vscf_alg_info_serializer_api.h │ │ │ ├── vscf_api_private.h │ │ │ ├── vscf_asn1_reader_api.h │ │ │ ├── vscf_asn1_writer_api.h │ │ │ ├── vscf_asn1rd_defs.h │ │ │ ├── vscf_asn1wr_defs.h │ │ │ ├── vscf_atomic.h │ │ │ ├── vscf_auth_decrypt_api.h │ │ │ ├── vscf_auth_encrypt_api.h │ │ │ ├── vscf_cipher_alg_info_defs.h │ │ │ ├── vscf_cipher_api.h │ │ │ ├── vscf_cipher_auth_api.h │ │ │ ├── vscf_cipher_auth_info_api.h │ │ │ ├── vscf_cipher_info_api.h │ │ │ ├── vscf_compound_key_alg_defs.h │ │ │ ├── vscf_compound_key_alg_info_defs.h │ │ │ ├── vscf_compound_private_key_defs.h │ │ │ ├── vscf_compound_public_key_defs.h │ │ │ ├── vscf_compute_shared_key_api.h │ │ │ ├── vscf_ctr_drbg_defs.h │ │ │ ├── vscf_curve25519_defs.h │ │ │ ├── vscf_decrypt_api.h │ │ │ ├── vscf_defaults_api.h │ │ │ ├── vscf_ec_alg_info_defs.h │ │ │ ├── vscf_ecc_alg_info_defs.h │ │ │ ├── vscf_ecc_defs.h │ │ │ ├── vscf_ecc_private_key_defs.h │ │ │ ├── vscf_ecc_public_key_defs.h │ │ │ ├── vscf_ecies_defs.h │ │ │ ├── vscf_ed25519_defs.h │ │ │ ├── vscf_encrypt_api.h │ │ │ ├── vscf_endianness.h │ │ │ ├── vscf_entropy_accumulator_defs.h │ │ │ ├── vscf_entropy_source_api.h │ │ │ ├── vscf_fake_random_defs.h │ │ │ ├── vscf_falcon_defs.h │ │ │ ├── vscf_footer_info_defs.h │ │ │ ├── vscf_foundation_private.h │ │ │ ├── vscf_generate_ephemeral_key_api.h │ │ │ ├── vscf_generate_key_api.h │ │ │ ├── vscf_group_session_message_defs.h │ │ │ ├── vscf_group_session_ticket_defs.h │ │ │ ├── vscf_hash_api.h │ │ │ ├── vscf_hash_based_alg_info_defs.h │ │ │ ├── vscf_hkdf_defs.h │ │ │ ├── vscf_hkdf_private.h │ │ │ ├── vscf_hmac_defs.h │ │ │ ├── vscf_hybrid_key_alg_defs.h │ │ │ ├── vscf_hybrid_key_alg_info_defs.h │ │ │ ├── vscf_hybrid_private_key_defs.h │ │ │ ├── vscf_hybrid_public_key_defs.h │ │ │ ├── vscf_impl_private.h │ │ │ ├── vscf_kdf1_defs.h │ │ │ ├── vscf_kdf2_defs.h │ │ │ ├── vscf_kdf_api.h │ │ │ ├── vscf_kem_api.h │ │ │ ├── vscf_key_alg_api.h │ │ │ ├── vscf_key_api.h │ │ │ ├── vscf_key_asn1_deserializer_defs.h │ │ │ ├── vscf_key_asn1_serializer_defs.h │ │ │ ├── vscf_key_cipher_api.h │ │ │ ├── vscf_key_deserializer_api.h │ │ │ ├── vscf_key_info_defs.h │ │ │ ├── vscf_key_material_rng_defs.h │ │ │ ├── vscf_key_provider_defs.h │ │ │ ├── vscf_key_recipient_info_defs.h │ │ │ ├── vscf_key_recipient_info_list_defs.h │ │ │ ├── vscf_key_serializer_api.h │ │ │ ├── vscf_key_signer_api.h │ │ │ ├── vscf_list_key_value_node_defs.h │ │ │ ├── vscf_mac_api.h │ │ │ ├── vscf_mac_info_api.h │ │ │ ├── vscf_mac_stream_api.h │ │ │ ├── vscf_mbedtls_bridge_entropy.h │ │ │ ├── vscf_mbedtls_bridge_random.h │ │ │ ├── vscf_message_cipher.h │ │ │ ├── vscf_message_info_custom_params_defs.h │ │ │ ├── vscf_message_info_defs.h │ │ │ ├── vscf_message_info_der_serializer_defs.h │ │ │ ├── vscf_message_info_editor_defs.h │ │ │ ├── vscf_message_info_footer_defs.h │ │ │ ├── vscf_message_info_footer_serializer_api.h │ │ │ ├── vscf_message_info_serializer_api.h │ │ │ ├── vscf_message_padding.h │ │ │ ├── vscf_padding_api.h │ │ │ ├── vscf_padding_params_defs.h │ │ │ ├── vscf_password_recipient_info_defs.h │ │ │ ├── vscf_password_recipient_info_list_defs.h │ │ │ ├── vscf_pbe_alg_info_defs.h │ │ │ ├── vscf_pkcs5_pbes2_defs.h │ │ │ ├── vscf_pkcs5_pbkdf2_defs.h │ │ │ ├── vscf_pkcs8_der_serializer_defs.h │ │ │ ├── vscf_pkcs8_serializer_defs.h │ │ │ ├── vscf_private_key_api.h │ │ │ ├── vscf_public_key_api.h │ │ │ ├── vscf_random_api.h │ │ │ ├── vscf_random_padding_defs.h │ │ │ ├── vscf_raw_key_defs.h │ │ │ ├── vscf_raw_private_key_defs.h │ │ │ ├── vscf_raw_public_key_defs.h │ │ │ ├── vscf_recipient_cipher_decryption_state.h │ │ │ ├── vscf_recipient_cipher_defs.h │ │ │ ├── vscf_round5_defs.h │ │ │ ├── vscf_rsa_defs.h │ │ │ ├── vscf_rsa_private_key_defs.h │ │ │ ├── vscf_rsa_public_key_defs.h │ │ │ ├── vscf_salted_kdf_alg_info_defs.h │ │ │ ├── vscf_salted_kdf_api.h │ │ │ ├── vscf_sec1_serializer_defs.h │ │ │ ├── vscf_seed_entropy_source_defs.h │ │ │ ├── vscf_sha224_defs.h │ │ │ ├── vscf_sha256_defs.h │ │ │ ├── vscf_sha384_defs.h │ │ │ ├── vscf_sha512_defs.h │ │ │ ├── vscf_sign_hash_api.h │ │ │ ├── vscf_signed_data_info_defs.h │ │ │ ├── vscf_signer_defs.h │ │ │ ├── vscf_signer_info_defs.h │ │ │ ├── vscf_signer_info_list_defs.h │ │ │ ├── vscf_simple_alg_info_defs.h │ │ │ ├── vscf_simple_swu.h │ │ │ ├── vscf_verifier_defs.h │ │ │ └── vscf_verify_hash_api.h │ │ ├── vscf_GroupMessage.pb.h │ │ ├── vscf_aes256_cbc.h │ │ ├── vscf_aes256_gcm.h │ │ ├── vscf_alg.h │ │ ├── vscf_alg_factory.h │ │ ├── vscf_alg_id.h │ │ ├── vscf_alg_info.h │ │ ├── vscf_alg_info_der_deserializer.h │ │ ├── vscf_alg_info_der_serializer.h │ │ ├── vscf_alg_info_deserializer.h │ │ ├── vscf_alg_info_serializer.h │ │ ├── vscf_api.h │ │ ├── vscf_asn1_reader.h │ │ ├── vscf_asn1_tag.h │ │ ├── vscf_asn1_writer.h │ │ ├── vscf_asn1rd.h │ │ ├── vscf_asn1wr.h │ │ ├── vscf_assert.h │ │ ├── vscf_auth_decrypt.h │ │ ├── vscf_auth_encrypt.h │ │ ├── vscf_base64.h │ │ ├── vscf_brainkey_client.h │ │ ├── vscf_brainkey_server.h │ │ ├── vscf_cipher.h │ │ ├── vscf_cipher_alg_info.h │ │ ├── vscf_cipher_auth.h │ │ ├── vscf_cipher_auth_info.h │ │ ├── vscf_cipher_info.h │ │ ├── vscf_cipher_state.h │ │ ├── vscf_compound_key_alg.h │ │ ├── vscf_compound_key_alg_info.h │ │ ├── vscf_compound_private_key.h │ │ ├── vscf_compound_public_key.h │ │ ├── vscf_compute_shared_key.h │ │ ├── vscf_ctr_drbg.h │ │ ├── vscf_curve25519.h │ │ ├── vscf_decrypt.h │ │ ├── vscf_defaults.h │ │ ├── vscf_ec_alg_info.h │ │ ├── vscf_ecc.h │ │ ├── vscf_ecc_alg_info.h │ │ ├── vscf_ecc_private_key.h │ │ ├── vscf_ecc_public_key.h │ │ ├── vscf_ecies.h │ │ ├── vscf_ed25519.h │ │ ├── vscf_encrypt.h │ │ ├── vscf_entropy_accumulator.h │ │ ├── vscf_entropy_source.h │ │ ├── vscf_error.h │ │ ├── vscf_fake_random.h │ │ ├── vscf_falcon.h │ │ ├── vscf_footer_info.h │ │ ├── vscf_foundation_public.h │ │ ├── vscf_generate_ephemeral_key.h │ │ ├── vscf_generate_key.h │ │ ├── vscf_group_msg_type.h │ │ ├── vscf_group_session.h │ │ ├── vscf_group_session_message.h │ │ ├── vscf_group_session_ticket.h │ │ ├── vscf_hash.h │ │ ├── vscf_hash_based_alg_info.h │ │ ├── vscf_hkdf.h │ │ ├── vscf_hmac.h │ │ ├── vscf_hybrid_key_alg.h │ │ ├── vscf_hybrid_key_alg_info.h │ │ ├── vscf_hybrid_private_key.h │ │ ├── vscf_hybrid_public_key.h │ │ ├── vscf_impl.h │ │ ├── vscf_kdf.h │ │ ├── vscf_kdf1.h │ │ ├── vscf_kdf2.h │ │ ├── vscf_kem.h │ │ ├── vscf_key.h │ │ ├── vscf_key_alg.h │ │ ├── vscf_key_alg_factory.h │ │ ├── vscf_key_asn1_deserializer.h │ │ ├── vscf_key_asn1_serializer.h │ │ ├── vscf_key_cipher.h │ │ ├── vscf_key_deserializer.h │ │ ├── vscf_key_info.h │ │ ├── vscf_key_material_rng.h │ │ ├── vscf_key_provider.h │ │ ├── vscf_key_recipient_info.h │ │ ├── vscf_key_recipient_info_list.h │ │ ├── vscf_key_serializer.h │ │ ├── vscf_key_signer.h │ │ ├── vscf_library.h │ │ ├── vscf_list_key_value_node.h │ │ ├── vscf_mac.h │ │ ├── vscf_mac_info.h │ │ ├── vscf_mac_stream.h │ │ ├── vscf_memory.h │ │ ├── vscf_message_info.h │ │ ├── vscf_message_info_custom_params.h │ │ ├── vscf_message_info_der_serializer.h │ │ ├── vscf_message_info_editor.h │ │ ├── vscf_message_info_footer.h │ │ ├── vscf_message_info_footer_serializer.h │ │ ├── vscf_message_info_serializer.h │ │ ├── vscf_oid.h │ │ ├── vscf_oid_id.h │ │ ├── vscf_padding.h │ │ ├── vscf_padding_params.h │ │ ├── vscf_password_recipient_info.h │ │ ├── vscf_password_recipient_info_list.h │ │ ├── vscf_pbe_alg_info.h │ │ ├── vscf_pem.h │ │ ├── vscf_pkcs5_pbes2.h │ │ ├── vscf_pkcs5_pbkdf2.h │ │ ├── vscf_pkcs8_der_serializer.h │ │ ├── vscf_pkcs8_serializer.h │ │ ├── vscf_platform.h │ │ ├── vscf_private_key.h │ │ ├── vscf_public_key.h │ │ ├── vscf_random.h │ │ ├── vscf_random_padding.h │ │ ├── vscf_raw_key.h │ │ ├── vscf_raw_private_key.h │ │ ├── vscf_raw_public_key.h │ │ ├── vscf_recipient_cipher.h │ │ ├── vscf_round5.h │ │ ├── vscf_rsa.h │ │ ├── vscf_rsa_private_key.h │ │ ├── vscf_rsa_public_key.h │ │ ├── vscf_salted_kdf.h │ │ ├── vscf_salted_kdf_alg_info.h │ │ ├── vscf_sec1_serializer.h │ │ ├── vscf_seed_entropy_source.h │ │ ├── vscf_sha224.h │ │ ├── vscf_sha256.h │ │ ├── vscf_sha384.h │ │ ├── vscf_sha512.h │ │ ├── vscf_sign_hash.h │ │ ├── vscf_signed_data_info.h │ │ ├── vscf_signer.h │ │ ├── vscf_signer_info.h │ │ ├── vscf_signer_info_list.h │ │ ├── vscf_simple_alg_info.h │ │ ├── vscf_status.h │ │ ├── vscf_verifier.h │ │ └── vscf_verify_hash.h │ │ └── phe │ │ ├── PHEModels.pb.h │ │ ├── UOKMSModels.pb.h │ │ ├── private │ │ ├── vsce_atomic.h │ │ ├── vsce_phe_hash_defs.h │ │ └── vsce_phe_private.h │ │ ├── vsce_assert.h │ │ ├── vsce_error.h │ │ ├── vsce_library.h │ │ ├── vsce_memory.h │ │ ├── vsce_phe_cipher.h │ │ ├── vsce_phe_client.h │ │ ├── vsce_phe_common.h │ │ ├── vsce_phe_public.h │ │ ├── vsce_phe_server.h │ │ ├── vsce_platform.h │ │ ├── vsce_status.h │ │ ├── vsce_uokms_client.h │ │ ├── vsce_uokms_server.h │ │ └── vsce_uokms_wrap_rotation.h │ └── lib │ ├── libed25519.a │ ├── libfalcon.a │ ├── libmbedcrypto.a │ ├── libprotobuf-nanopb.a │ ├── libround5.a │ ├── libvsc_common.a │ ├── libvsc_foundation.a │ ├── libvsc_foundation_pb.a │ ├── libvsc_phe.a │ └── libvsc_phe_pb.a ├── doc.go ├── errors ├── api.go └── sdk.go ├── go.mod ├── go.sum ├── jenkinsfile ├── sdk ├── card.go ├── cardclient.go ├── cardmanager.go ├── cardmanager_test.go ├── cardparams.go ├── cardutils.go ├── cardverifier.go ├── cardverifier_test.go ├── crypto.go ├── errors.go ├── example_test.go ├── modelsigner.go ├── rawcard.go ├── rawsignedmodel_test.go └── sdk_test.go ├── session ├── accesstoken.go ├── accesstokenprovider.go ├── accesstokensigner.go ├── cachingjwtprovider.go ├── cachingjwtprovider_test.go ├── callbackjwtprovider.go ├── errors.go ├── generatorjwtprovider.go ├── jwt.go ├── jwtgenerator.go ├── jwtverifier.go ├── jwtverifier_test.go └── tokecontext.go ├── storage ├── encryptstorage.go ├── filestorage.go ├── privatekeystorage.go └── storage.go └── version.go /.gitignore: -------------------------------------------------------------------------------- 1 | # Compiled Object files, Static and Dynamic libs (Shared Objects) 2 | *.o 3 | *.so 4 | 5 | # Folders 6 | _obj 7 | _test 8 | 9 | # Architecture specific extensions/prefixes 10 | *.[568vq] 11 | [568vq].out 12 | 13 | *.cgo1.go 14 | *.cgo2.c 15 | _cgo_defun.c 16 | _cgo_gotypes.go 17 | _cgo_export.* 18 | 19 | _testmain.go 20 | 21 | *.env 22 | 23 | *.exe 24 | *.test 25 | *.prof 26 | *.out 27 | # Covers JetBrains IDEs: IntelliJ, RubyMine, PhpStorm, AppCode, PyCharm, CLion, Android Studio and Webstorm 28 | # Reference: https://intellij-support.jetbrains.com/hc/en-us/articles/206544839 29 | 30 | # User-specific stuff: 31 | .idea/workspace.xml 32 | .idea/tasks.xml 33 | .idea/dictionaries 34 | .idea/vcs.xml 35 | .idea/jsLibraryMappings.xml 36 | 37 | # Sensitive or high-churn files: 38 | .idea/dataSources.ids 39 | .idea/dataSources.xml 40 | .idea/dataSources.local.xml 41 | .idea/sqlDataSources.xml 42 | .idea/dynamic.xml 43 | .idea/uiDesigner.xml 44 | 45 | # Gradle: 46 | .idea/gradle.xml 47 | .idea/libraries 48 | 49 | # Mongo Explorer plugin: 50 | .idea/mongoSettings.xml 51 | 52 | ## File-based project format: 53 | *.iws 54 | 55 | ## Plugin-specific files: 56 | 57 | # IntelliJ 58 | /out/ 59 | 60 | # mpeltonen/sbt-idea plugin 61 | .idea_modules/ 62 | # JIRA plugin 63 | atlassian-ide-plugin.xml 64 | 65 | # Crashlytics plugin (for Android Studio and IntelliJ) 66 | com_crashlytics_export_strings.xml 67 | crashlytics.properties 68 | crashlytics-build.properties 69 | fabric.properties 70 | .idea/* 71 | *.iml 72 | Sample* 73 | *.vscode* 74 | /http2* 75 | /udp* 76 | /.sample/* 77 | -------------------------------------------------------------------------------- /.pre-commit-config.yaml: -------------------------------------------------------------------------------- 1 | - repo: local 2 | hooks: 3 | - id: golangci-lint 4 | name: golangci-lint 5 | description: Fast linters runner for Go. 6 | entry: golangci-lint run 7 | types: [go] 8 | language: golang 9 | pass_filenames: false 10 | -------------------------------------------------------------------------------- /.travis.yml: -------------------------------------------------------------------------------- 1 | language: go 2 | 3 | cache: 4 | directories: 5 | - $HOME/gopath/pkg/mod 6 | 7 | matrix: 8 | include: 9 | ########################################################################## 10 | # Go versions 11 | ########################################################################## 12 | - os: linux 13 | go: "1.21.3" 14 | 15 | ########################################################################## 16 | # GCC on Linux 17 | ########################################################################## 18 | - os: linux 19 | go: "1.21.3" 20 | addons: 21 | apt: 22 | sources: 23 | - ubuntu-toolchain-r-test 24 | packages: 25 | - g++-5 26 | env: 27 | - CC=gcc-5 28 | - CXX=g++-5 29 | - os: linux 30 | go: "1.21.3" 31 | addons: 32 | apt: 33 | sources: 34 | - ubuntu-toolchain-r-test 35 | packages: 36 | - g++-9 37 | env: 38 | - CC=gcc-9 39 | - CXX=g++-9 40 | 41 | install: 42 | - go mod download 43 | 44 | script: 45 | - "if [[ $LINT_ENABLE ]]; then 46 | curl -sSfL https://raw.githubusercontent.com/golangci/golangci-lint/master/install.sh | sh -s -- -b /tmp/lint v1.38.0; 47 | /tmp/lint/golangci-lint run --allow-parallel-runners -c .golangci.yml -v; 48 | fi" 49 | - 'if [[ $LEGACY ]]; then 50 | go test -tags "legacy integration" -mod=readonly -count 1 ./... ; 51 | else 52 | go test -tags integration -mod=readonly -count 1 ./... ; 53 | fi' 54 | -------------------------------------------------------------------------------- /LICENSE: -------------------------------------------------------------------------------- 1 | BSD 3-Clause License 2 | 3 | Copyright (c) 2020, Virgil Security, Inc. 4 | All rights reserved. 5 | 6 | Redistribution and use in source and binary forms, with or without 7 | modification, are permitted provided that the following conditions are met: 8 | 9 | * Redistributions of source code must retain the above copyright notice, this 10 | list of conditions and the following disclaimer. 11 | 12 | * Redistributions in binary form must reproduce the above copyright notice, 13 | this list of conditions and the following disclaimer in the documentation 14 | and/or other materials provided with the distribution. 15 | 16 | * Neither the name of the copyright holder nor the names of its 17 | contributors may be used to endorse or promote products derived from 18 | this software without specific prior written permission. 19 | 20 | THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" 21 | AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE 22 | IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE 23 | DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE 24 | FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL 25 | DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR 26 | SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER 27 | CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, 28 | OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE 29 | OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 30 | -------------------------------------------------------------------------------- /common/client/json.go: -------------------------------------------------------------------------------- 1 | package client 2 | 3 | import ( 4 | "encoding/json" 5 | ) 6 | 7 | type JSONCodec struct{} 8 | 9 | func (c *JSONCodec) Marshal(obj interface{}) (body []byte, err error) { 10 | return json.Marshal(obj) 11 | } 12 | 13 | func (c *JSONCodec) Unmarshal(data []byte, obj interface{}) error { 14 | return json.Unmarshal(data, obj) 15 | } 16 | 17 | func (c *JSONCodec) Name() string { 18 | return "application/json" 19 | } 20 | -------------------------------------------------------------------------------- /crypto/keytype_test.go: -------------------------------------------------------------------------------- 1 | package crypto 2 | 3 | import ( 4 | "testing" 5 | 6 | "github.com/stretchr/testify/require" 7 | ) 8 | 9 | func TestGetKeyType(t *testing.T) { 10 | c := &Crypto{} 11 | for kt := Rsa2048; kt <= Curve25519Round5; kt++ { 12 | sk, err := c.GenerateKeypairForType(kt) 13 | require.NoError(t, err) 14 | require.Equal(t, kt, sk.KeyType()) 15 | require.Equal(t, kt, sk.PublicKey().KeyType()) 16 | } 17 | } 18 | -------------------------------------------------------------------------------- /crypto/privatekey.go: -------------------------------------------------------------------------------- 1 | /* 2 | * BSD 3-Clause License 3 | * 4 | * Copyright (c) 2015-2018, Virgil Security, Inc. 5 | * All rights reserved. 6 | * 7 | * Redistribution and use in source and binary forms, with or without 8 | * modification, are permitted provided that the following conditions are met: 9 | * 10 | * Redistributions of source code must retain the above copyright notice, this 11 | * list of conditions and the following disclaimer. 12 | * 13 | * Redistributions in binary form must reproduce the above copyright notice, 14 | * this list of conditions and the following disclaimer in the documentation 15 | * and/or other materials provided with the distribution. 16 | * 17 | * Neither the name of the copyright holder nor the names of its 18 | * contributors may be used to endorse or promote products derived from 19 | * this software without specific prior written permission. 20 | * 21 | * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" 22 | * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE 23 | * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE 24 | * DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE 25 | * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL 26 | * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR 27 | * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER 28 | * CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, 29 | * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE 30 | * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 31 | */ 32 | 33 | package crypto 34 | 35 | import ( 36 | "github.com/VirgilSecurity/virgil-sdk-go/v6/crypto/wrapper/foundation" 37 | ) 38 | 39 | type privateKey struct { 40 | receiverID []byte 41 | key foundation.PrivateKey 42 | publicKey PublicKey 43 | keyType KeyType 44 | } 45 | 46 | func (k *privateKey) Identifier() []byte { 47 | return k.receiverID 48 | } 49 | 50 | func (k *privateKey) PublicKey() PublicKey { 51 | return k.publicKey 52 | } 53 | 54 | func (k *privateKey) Unwrap() foundation.PrivateKey { 55 | return k.key 56 | } 57 | func (k *privateKey) KeyType() KeyType { 58 | return k.keyType 59 | } 60 | -------------------------------------------------------------------------------- /crypto/random.go: -------------------------------------------------------------------------------- 1 | /* 2 | * BSD 3-Clause License 3 | * 4 | * Copyright (c) 2015-2018, Virgil Security, Inc. 5 | * All rights reserved. 6 | * 7 | * Redistribution and use in source and binary forms, with or without 8 | * modification, are permitted provided that the following conditions are met: 9 | * 10 | * Redistributions of source code must retain the above copyright notice, this 11 | * list of conditions and the following disclaimer. 12 | * 13 | * Redistributions in binary form must reproduce the above copyright notice, 14 | * this list of conditions and the following disclaimer in the documentation 15 | * and/or other materials provided with the distribution. 16 | * 17 | * Neither the name of the copyright holder nor the names of its 18 | * contributors may be used to endorse or promote products derived from 19 | * this software without specific prior written permission. 20 | * 21 | * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" 22 | * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE 23 | * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE 24 | * DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE 25 | * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL 26 | * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR 27 | * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER 28 | * CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, 29 | * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE 30 | * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 31 | */ 32 | 33 | package crypto 34 | 35 | import ( 36 | "fmt" 37 | 38 | "github.com/VirgilSecurity/virgil-sdk-go/v6/crypto/wrapper/foundation" 39 | ) 40 | 41 | var random foundation.Random 42 | 43 | func init() { 44 | rnd := foundation.NewCtrDrbg() 45 | 46 | if err := rnd.SetupDefaults(); err != nil { 47 | panic(fmt.Errorf("virgil crypto cannot initialize random generator: %w", err)) 48 | } 49 | random = rnd 50 | } 51 | -------------------------------------------------------------------------------- /crypto/wrapper/build/Dockerfile: -------------------------------------------------------------------------------- 1 | FROM ubuntu:16.04 2 | 3 | RUN apt-get update && apt-get install -y --no-install-recommends \ 4 | g++ \ 5 | gcc \ 6 | libc6-dev \ 7 | make \ 8 | pkg-config \ 9 | curl \ 10 | ca-certificates \ 11 | git \ 12 | wget \ 13 | libssl-dev \ 14 | python \ 15 | python3-pip \ 16 | zip \ 17 | libcurl4-openssl-dev \ 18 | unzip \ 19 | && rm -rf /var/lib/apt/lists/* 20 | 21 | # --------------------------------------------------------------------------- 22 | # CMake 23 | # --------------------------------------------------------------------------- 24 | ENV CMAKE_VERSION_MAJOR=3 25 | ENV CMAKE_VERSION_MINOR=12 26 | ENV CMAKE_VERSION_PATCH=4 27 | ENV CMAKE_VERSION=${CMAKE_VERSION_MAJOR}.${CMAKE_VERSION_MINOR}.${CMAKE_VERSION_PATCH} 28 | 29 | RUN cd && \ 30 | wget https://cmake.org/files/v${CMAKE_VERSION_MAJOR}.${CMAKE_VERSION_MINOR}/cmake-${CMAKE_VERSION}-Linux-x86_64.sh && \ 31 | bash cmake-${CMAKE_VERSION}-Linux-x86_64.sh --skip-license --exclude-subdir --prefix=/usr/local && \ 32 | rm cmake-${CMAKE_VERSION}-Linux-x86_64.sh 33 | 34 | 35 | RUN pip3 install protobuf 36 | RUN update-alternatives --install /usr/bin/python python /usr/bin/python3 10 37 | 38 | # install golang 39 | ENV GOLANG_VERSION 1.16.2 40 | ENV GOLANG_DOWNLOAD_URL https://golang.org/dl/go$GOLANG_VERSION.linux-amd64.tar.gz 41 | ENV GOLANG_DOWNLOAD_SHA256 542e936b19542e62679766194364f45141fde55169db2d8d01046555ca9eb4b8 42 | 43 | RUN curl -fsSL "$GOLANG_DOWNLOAD_URL" -o golang.tar.gz \ 44 | && echo "$GOLANG_DOWNLOAD_SHA256 golang.tar.gz" | sha256sum -c - \ 45 | && tar -C /usr/local -xzf golang.tar.gz \ 46 | && rm golang.tar.gz 47 | 48 | ENV GOPATH /go 49 | ENV PATH $GOPATH/bin:/usr/local/go/bin:$PATH 50 | 51 | RUN mkdir -p "$GOPATH/src" "$GOPATH/bin" && chmod -R 777 "$GOPATH" -------------------------------------------------------------------------------- /crypto/wrapper/build/build_c_crypto.sh: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | 3 | SCRIPT_FOLDER="$( cd "$( dirname "${BASH_SOURCE[0]}" )" >/dev/null 2>&1 && pwd )" 4 | TEMPDIR=`mktemp -d` 5 | OS=`go env GOOS` 6 | ARCH=`go env GOARCH` 7 | if [[ -z "$BRANCH" ]]; then 8 | BRANCH=master; 9 | fi 10 | 11 | PREBUILD_FOLDER=${OS}_${ARCH}${PREBUILD_SUFIX} 12 | 13 | git clone -b $BRANCH https://github.com/VirgilSecurity/virgil-crypto-c.git $TEMPDIR && \ 14 | mkdir $TEMPDIR/build && \ 15 | cd $TEMPDIR/build && \ 16 | cmake \ 17 | -DVIRGIL_WRAP_GO=OFF \ 18 | -DVIRGIL_LIB_PYTHIA=OFF \ 19 | -DVIRGIL_SDK_PYTHIA=OFF \ 20 | -DVIRGIL_LIB_RATCHET=OFF \ 21 | -DVIRGIL_INSTALL_HDRS=ON \ 22 | -DVIRGIL_INSTALL_LIBS=ON \ 23 | -DVIRGIL_INSTALL_CMAKE=OFF \ 24 | -DVIRGIL_INSTALL_DEPS_HDRS=ON \ 25 | -DVIRGIL_INSTALL_DEPS_LIBS=ON \ 26 | -DVIRGIL_INSTALL_DEPS_CMAKE=OFF \ 27 | -DENABLE_TESTING=OFF \ 28 | -DVIRGIL_C_TESTING=OFF \ 29 | -DCMAKE_BUILD_TYPE=Release \ 30 | -DVIRGIL_POST_QUANTUM=ON \ 31 | -DED25519_REF10=OFF \ 32 | -DED25519_AMD64_RADIX_64_24K=ON \ 33 | -DCMAKE_INSTALL_PREFIX=../wrappers/go/pkg/${OS}_${ARCH} .. && \ 34 | make -j10 && make -j10 install && \ 35 | cd $TEMPDIR/wrappers/go && \ 36 | if [[ -d "./pkg/${OS}_${ARCH}/lib64" ]]; then 37 | mv ./pkg/${OS}_${ARCH}/lib64 ./pkg/${OS}_${ARCH}/lib 38 | fi && \ 39 | rm -rf ratchet 40 | go test ./... 41 | 42 | RETRES=$? 43 | echo $RETRES 44 | if [ "$RETRES" == "0" ]; then 45 | rm -rf $SCRIPT_FOLDER/../pkg/$PREBUILD_FOLDER; 46 | mkdir -p $SCRIPT_FOLDER/../pkg/$PREBUILD_FOLDER/{lib,include}; 47 | cp -R $TEMPDIR/wrappers/go/pkg/${OS}_${ARCH}/include/* $SCRIPT_FOLDER/../pkg/$PREBUILD_FOLDER/include; 48 | cp -R $TEMPDIR/wrappers/go/pkg/${OS}_${ARCH}/lib/* $SCRIPT_FOLDER/../pkg/$PREBUILD_FOLDER/lib; 49 | fi 50 | rm -rf $TEMPDIR 51 | -------------------------------------------------------------------------------- /crypto/wrapper/build/entrypoint_legacy.sh: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | source scl_source enable devtoolset-2 3 | # Python35 installed from sources and absent in SCL 4 | #source scl_source enable rh-python35 5 | pip3 install protobuf 6 | exec "$@" 7 | -------------------------------------------------------------------------------- /crypto/wrapper/build/update_codegen.sh: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | 3 | SCRIPT_FOLDER="$( cd "$( dirname "${BASH_SOURCE[0]}" )" >/dev/null 2>&1 && pwd )" 4 | echo $SCRIPT_FOLDER 5 | TEMPDIR=`mktemp -d` 6 | 7 | if [[ -z "$BRANCH" ]]; then 8 | BRANCH=master; 9 | fi 10 | 11 | git clone -b $BRANCH https://github.com/VirgilSecurity/virgil-crypto-c.git $TEMPDIR 12 | 13 | RETRES=$? 14 | echo $RETRES 15 | if [ "$RETRES" == "0" ]; then 16 | rm -rf $SCRIPT_FOLDER/../{foundation,phe,sdk}; 17 | cp -R $TEMPDIR/wrappers/go/{foundation,phe,sdk} $SCRIPT_FOLDER/../; 18 | for i in $(grep -R "virgil/foundation" $SCRIPT_FOLDER/../{foundation,phe,sdk} | cut -d ":" -f 1) 19 | do 20 | echo $i 21 | sed -i -e 's/virgil\/foundation/github.com\/VirgilSecurity\/virgil-sdk-go\/v6\/crypto\/wrapper\/foundation/g' $i 22 | done; 23 | fi 24 | rm -rf $TEMPDIR -------------------------------------------------------------------------------- /crypto/wrapper/foundation/alg.go: -------------------------------------------------------------------------------- 1 | package foundation 2 | 3 | import "C" 4 | 5 | /* 6 | * Provide interface to persist algorithm information and it parameters 7 | * and then restore the algorithm from it. 8 | */ 9 | type Alg interface { 10 | context 11 | 12 | /* 13 | * Provide algorithm identificator. 14 | */ 15 | AlgId() AlgId 16 | 17 | /* 18 | * Produce object with algorithm information and configuration parameters. 19 | */ 20 | ProduceAlgInfo() (AlgInfo, error) 21 | 22 | /* 23 | * Restore algorithm configuration from the given object. 24 | */ 25 | RestoreAlgInfo(algInfo AlgInfo) error 26 | 27 | /* 28 | * Release underlying C context. 29 | */ 30 | Delete() 31 | } 32 | -------------------------------------------------------------------------------- /crypto/wrapper/foundation/alg_id.go: -------------------------------------------------------------------------------- 1 | package foundation 2 | 3 | import "C" 4 | 5 | /* 6 | * Define implemented algorithm identificator. 7 | */ 8 | type AlgId int 9 | 10 | const ( 11 | AlgIdNone AlgId = 0 12 | AlgIdSha224 AlgId = 1 13 | AlgIdSha256 AlgId = 2 14 | AlgIdSha384 AlgId = 3 15 | AlgIdSha512 AlgId = 4 16 | AlgIdKdf1 AlgId = 5 17 | AlgIdKdf2 AlgId = 6 18 | AlgIdRsa AlgId = 7 19 | AlgIdEd25519 AlgId = 8 20 | AlgIdCurve25519 AlgId = 9 21 | AlgIdSecp256r1 AlgId = 10 22 | AlgIdAes256Gcm AlgId = 11 23 | AlgIdAes256Cbc AlgId = 12 24 | AlgIdHmac AlgId = 13 25 | AlgIdHkdf AlgId = 14 26 | AlgIdPkcs5Pbkdf2 AlgId = 15 27 | AlgIdPkcs5Pbes2 AlgId = 16 28 | AlgIdCompoundKey AlgId = 17 29 | AlgIdHybridKey AlgId = 18 30 | AlgIdFalcon AlgId = 19 31 | AlgIdRound5Nd1cca5d AlgId = 20 32 | AlgIdRandomPadding AlgId = 21 33 | ) 34 | -------------------------------------------------------------------------------- /crypto/wrapper/foundation/alg_info.go: -------------------------------------------------------------------------------- 1 | package foundation 2 | 3 | import "C" 4 | 5 | /* 6 | * Provide details about implemented algorithms. 7 | */ 8 | type AlgInfo interface { 9 | context 10 | 11 | /* 12 | * Provide algorithm identificator. 13 | */ 14 | AlgId() AlgId 15 | 16 | /* 17 | * Release underlying C context. 18 | */ 19 | Delete() 20 | } 21 | -------------------------------------------------------------------------------- /crypto/wrapper/foundation/alg_info_deserializer.go: -------------------------------------------------------------------------------- 1 | package foundation 2 | 3 | import "C" 4 | 5 | /* 6 | * Provide algorithm deserialization. 7 | */ 8 | type AlgInfoDeserializer interface { 9 | context 10 | 11 | /* 12 | * Deserialize algorithm from the data. 13 | */ 14 | Deserialize(data []byte) (AlgInfo, error) 15 | 16 | /* 17 | * Release underlying C context. 18 | */ 19 | Delete() 20 | } 21 | -------------------------------------------------------------------------------- /crypto/wrapper/foundation/alg_info_serializer.go: -------------------------------------------------------------------------------- 1 | package foundation 2 | 3 | import "C" 4 | 5 | /* 6 | * Provide serialization of algorithm 7 | */ 8 | type AlgInfoSerializer interface { 9 | context 10 | 11 | /* 12 | * Return buffer size enough to hold serialized algorithm. 13 | */ 14 | SerializedLen(algInfo AlgInfo) uint 15 | 16 | /* 17 | * Serialize algorithm info to buffer class. 18 | */ 19 | Serialize(algInfo AlgInfo) []byte 20 | 21 | /* 22 | * Release underlying C context. 23 | */ 24 | Delete() 25 | } 26 | -------------------------------------------------------------------------------- /crypto/wrapper/foundation/asn1_tag.go: -------------------------------------------------------------------------------- 1 | package foundation 2 | 3 | import "C" 4 | 5 | /* 6 | * ASN.1 constants. 7 | */ 8 | type Asn1Tag int 9 | 10 | const ( 11 | Asn1TagBoolean Asn1Tag = 0x01 12 | Asn1TagInteger Asn1Tag = 0x02 13 | Asn1TagBitString Asn1Tag = 0x03 14 | Asn1TagOctetString Asn1Tag = 0x04 15 | Asn1TagNull Asn1Tag = 0x05 16 | Asn1TagOid Asn1Tag = 0x06 17 | Asn1TagUtf8String Asn1Tag = 0x0C 18 | Asn1TagSequence Asn1Tag = 0x10 19 | Asn1TagSet Asn1Tag = 0x11 20 | Asn1TagPrintableString Asn1Tag = 0x13 21 | Asn1TagT61String Asn1Tag = 0x14 22 | Asn1TagIa5String Asn1Tag = 0x16 23 | Asn1TagUtcTime Asn1Tag = 0x17 24 | Asn1TagGeneralizedTime Asn1Tag = 0x18 25 | Asn1TagUniversalString Asn1Tag = 0x1C 26 | Asn1TagBmpString Asn1Tag = 0x1E 27 | Asn1TagPrimitive Asn1Tag = 0x00 28 | Asn1TagConstructed Asn1Tag = 0x20 29 | Asn1TagContextSpecific Asn1Tag = 0x80 30 | ) 31 | -------------------------------------------------------------------------------- /crypto/wrapper/foundation/auth_decrypt.go: -------------------------------------------------------------------------------- 1 | package foundation 2 | 3 | import "C" 4 | 5 | /* 6 | * Provide interface for data encryption. 7 | */ 8 | type AuthDecrypt interface { 9 | context 10 | 11 | /* 12 | * Decrypt given data. 13 | * If 'tag' is not given, then it will be taken from the 'enc'. 14 | */ 15 | AuthDecrypt(data []byte, authData []byte, tag []byte) ([]byte, error) 16 | 17 | /* 18 | * Calculate required buffer length to hold the authenticated decrypted data. 19 | */ 20 | AuthDecryptedLen(dataLen uint) uint 21 | 22 | /* 23 | * Release underlying C context. 24 | */ 25 | Delete() 26 | } 27 | -------------------------------------------------------------------------------- /crypto/wrapper/foundation/auth_encrypt.go: -------------------------------------------------------------------------------- 1 | package foundation 2 | 3 | import "C" 4 | 5 | /* 6 | * Provide interface for authenticated data encryption. 7 | */ 8 | type AuthEncrypt interface { 9 | context 10 | 11 | /* 12 | * Encrypt given data. 13 | * If 'tag' is not given, then it will written to the 'enc'. 14 | */ 15 | AuthEncrypt(data []byte, authData []byte) ([]byte, []byte, error) 16 | 17 | /* 18 | * Calculate required buffer length to hold the authenticated encrypted data. 19 | */ 20 | AuthEncryptedLen(dataLen uint) uint 21 | 22 | /* 23 | * Release underlying C context. 24 | */ 25 | Delete() 26 | } 27 | -------------------------------------------------------------------------------- /crypto/wrapper/foundation/base64.go: -------------------------------------------------------------------------------- 1 | package foundation 2 | 3 | // #include 4 | import "C" 5 | 6 | /* 7 | * Implementation of the Base64 algorithm RFC 1421 and RFC 2045. 8 | */ 9 | type Base64 struct { 10 | } 11 | 12 | /* 13 | * Calculate length in bytes required to hold an encoded base64 string. 14 | */ 15 | func Base64EncodedLen(dataLen uint) uint { 16 | proxyResult := /*pr4*/ C.vscf_base64_encoded_len((C.size_t)(dataLen) /*pa10*/) 17 | 18 | return uint(proxyResult) /* r9 */ 19 | } 20 | 21 | /* 22 | * Encode given data to the base64 format. 23 | * Note, written buffer is NOT null-terminated. 24 | */ 25 | func Base64Encode(data []byte) []byte { 26 | strBuf, strBufErr := newBuffer(int(Base64EncodedLen(uint(len(data))) /* lg1 */)) 27 | if strBufErr != nil { 28 | return nil 29 | } 30 | defer strBuf.delete() 31 | dataData := helperWrapData(data) 32 | 33 | C.vscf_base64_encode(dataData, strBuf.ctx) 34 | 35 | return strBuf.getData() /* r7 */ 36 | } 37 | 38 | /* 39 | * Calculate length in bytes required to hold a decoded base64 string. 40 | */ 41 | func Base64DecodedLen(strLen uint) uint { 42 | proxyResult := /*pr4*/ C.vscf_base64_decoded_len((C.size_t)(strLen) /*pa10*/) 43 | 44 | return uint(proxyResult) /* r9 */ 45 | } 46 | 47 | /* 48 | * Decode given data from the base64 format. 49 | */ 50 | func Base64Decode(str []byte) ([]byte, error) { 51 | dataBuf, dataBufErr := newBuffer(int(Base64DecodedLen(uint(len(str))) /* lg1 */)) 52 | if dataBufErr != nil { 53 | return nil, dataBufErr 54 | } 55 | defer dataBuf.delete() 56 | strData := helperWrapData(str) 57 | 58 | proxyResult := /*pr4*/ C.vscf_base64_decode(strData, dataBuf.ctx) 59 | 60 | err := FoundationErrorHandleStatus(proxyResult) 61 | if err != nil { 62 | return nil, err 63 | } 64 | 65 | return dataBuf.getData() /* r7 */, nil 66 | } 67 | -------------------------------------------------------------------------------- /crypto/wrapper/foundation/cipher.go: -------------------------------------------------------------------------------- 1 | package foundation 2 | 3 | import "C" 4 | 5 | /* 6 | * Provide interface for symmetric ciphers. 7 | */ 8 | type Cipher interface { 9 | context 10 | 11 | /* 12 | * Setup IV or nonce. 13 | */ 14 | SetNonce(nonce []byte) 15 | 16 | /* 17 | * Set cipher encryption / decryption key. 18 | */ 19 | SetKey(key []byte) 20 | 21 | /* 22 | * Start sequential encryption. 23 | */ 24 | StartEncryption() 25 | 26 | /* 27 | * Start sequential decryption. 28 | */ 29 | StartDecryption() 30 | 31 | /* 32 | * Process encryption or decryption of the given data chunk. 33 | */ 34 | Update(data []byte) []byte 35 | 36 | /* 37 | * Return buffer length required to hold an output of the methods 38 | * "update" or "finish" in an current mode. 39 | * Pass zero length to define buffer length of the method "finish". 40 | */ 41 | OutLen(dataLen uint) uint 42 | 43 | /* 44 | * Return buffer length required to hold an output of the methods 45 | * "update" or "finish" in an encryption mode. 46 | * Pass zero length to define buffer length of the method "finish". 47 | */ 48 | EncryptedOutLen(dataLen uint) uint 49 | 50 | /* 51 | * Return buffer length required to hold an output of the methods 52 | * "update" or "finish" in an decryption mode. 53 | * Pass zero length to define buffer length of the method "finish". 54 | */ 55 | DecryptedOutLen(dataLen uint) uint 56 | 57 | /* 58 | * Accomplish encryption or decryption process. 59 | */ 60 | Finish() ([]byte, error) 61 | 62 | /* 63 | * Release underlying C context. 64 | */ 65 | Delete() 66 | } 67 | -------------------------------------------------------------------------------- /crypto/wrapper/foundation/cipher_auth.go: -------------------------------------------------------------------------------- 1 | package foundation 2 | 3 | import "C" 4 | 5 | /* 6 | * Mix-in interface that provides specific functionality to authenticated 7 | * encryption and decryption (AEAD ciphers). 8 | */ 9 | type CipherAuth interface { 10 | context 11 | 12 | /* 13 | * Set additional data for for AEAD ciphers. 14 | */ 15 | SetAuthData(authData []byte) 16 | 17 | /* 18 | * Accomplish an authenticated encryption and place tag separately. 19 | * 20 | * Note, if authentication tag should be added to an encrypted data, 21 | * method "finish" can be used. 22 | */ 23 | FinishAuthEncryption() ([]byte, []byte, error) 24 | 25 | /* 26 | * Accomplish an authenticated decryption with explicitly given tag. 27 | * 28 | * Note, if authentication tag is a part of an encrypted data then, 29 | * method "finish" can be used for simplicity. 30 | */ 31 | FinishAuthDecryption(tag []byte) ([]byte, error) 32 | 33 | /* 34 | * Release underlying C context. 35 | */ 36 | Delete() 37 | } 38 | -------------------------------------------------------------------------------- /crypto/wrapper/foundation/cipher_auth_info.go: -------------------------------------------------------------------------------- 1 | package foundation 2 | 3 | import "C" 4 | 5 | type CipherAuthInfo interface { 6 | context 7 | 8 | /* 9 | * Defines authentication tag length in bytes. 10 | */ 11 | GetAuthTagLen() uint 12 | 13 | /* 14 | * Release underlying C context. 15 | */ 16 | Delete() 17 | } 18 | -------------------------------------------------------------------------------- /crypto/wrapper/foundation/cipher_info.go: -------------------------------------------------------------------------------- 1 | package foundation 2 | 3 | import "C" 4 | 5 | /* 6 | * Provides compile time knownledge about algorithm. 7 | */ 8 | type CipherInfo interface { 9 | context 10 | 11 | /* 12 | * Cipher nfonce length or IV length in bytes, or 0 if nonce is not required. 13 | */ 14 | GetNonceLen() uint 15 | 16 | /* 17 | * Cipher key length in bytes. 18 | */ 19 | GetKeyLen() uint 20 | 21 | /* 22 | * Cipher key length in bits. 23 | */ 24 | GetKeyBitlen() uint 25 | 26 | /* 27 | * Cipher block length in bytes. 28 | */ 29 | GetBlockLen() uint 30 | 31 | /* 32 | * Release underlying C context. 33 | */ 34 | Delete() 35 | } 36 | -------------------------------------------------------------------------------- /crypto/wrapper/foundation/cipher_state.go: -------------------------------------------------------------------------------- 1 | package foundation 2 | 3 | import "C" 4 | 5 | /* 6 | * Enumerates possible sequentail cipher's states. 7 | */ 8 | type CipherState int 9 | 10 | const ( 11 | /* 12 | * Cipher is ready for new encryption / decryption operation. 13 | */ 14 | CipherStateInitial CipherState = 0 15 | /* 16 | * Cipher is configured for encryption. 17 | */ 18 | CipherStateEncryption CipherState = 1 19 | /* 20 | * Cipher is configured for decryption. 21 | */ 22 | CipherStateDecryption CipherState = 2 23 | ) 24 | -------------------------------------------------------------------------------- /crypto/wrapper/foundation/compute_shared_key.go: -------------------------------------------------------------------------------- 1 | package foundation 2 | 3 | import "C" 4 | 5 | /* 6 | * Provide interface to compute shared key for 2 asymmetric keys. 7 | */ 8 | type ComputeSharedKey interface { 9 | context 10 | 11 | /* 12 | * Compute shared key for 2 asymmetric keys. 13 | * Note, computed shared key can be used only within symmetric cryptography. 14 | */ 15 | ComputeSharedKey(publicKey PublicKey, privateKey PrivateKey) ([]byte, error) 16 | 17 | /* 18 | * Return number of bytes required to hold shared key. 19 | * Expect Public Key or Private Key. 20 | */ 21 | SharedKeyLen(key Key) uint 22 | 23 | /* 24 | * Release underlying C context. 25 | */ 26 | Delete() 27 | } 28 | -------------------------------------------------------------------------------- /crypto/wrapper/foundation/context.go: -------------------------------------------------------------------------------- 1 | package foundation 2 | 3 | // #include 4 | import "C" 5 | 6 | type context interface { 7 | 8 | /* Get C context */ 9 | Ctx() uintptr 10 | } 11 | -------------------------------------------------------------------------------- /crypto/wrapper/foundation/decrypt.go: -------------------------------------------------------------------------------- 1 | package foundation 2 | 3 | import "C" 4 | 5 | /* 6 | * Provide interface for data encryption. 7 | */ 8 | type Decrypt interface { 9 | context 10 | 11 | /* 12 | * Decrypt given data. 13 | */ 14 | Decrypt(data []byte) ([]byte, error) 15 | 16 | /* 17 | * Calculate required buffer length to hold the decrypted data. 18 | */ 19 | DecryptedLen(dataLen uint) uint 20 | 21 | /* 22 | * Release underlying C context. 23 | */ 24 | Delete() 25 | } 26 | -------------------------------------------------------------------------------- /crypto/wrapper/foundation/encrypt.go: -------------------------------------------------------------------------------- 1 | package foundation 2 | 3 | import "C" 4 | 5 | /* 6 | * Provide interface for data encryption. 7 | */ 8 | type Encrypt interface { 9 | context 10 | 11 | /* 12 | * Encrypt given data. 13 | */ 14 | Encrypt(data []byte) ([]byte, error) 15 | 16 | /* 17 | * Calculate required buffer length to hold the encrypted data. 18 | */ 19 | EncryptedLen(dataLen uint) uint 20 | 21 | /* 22 | * Precise length calculation of encrypted data. 23 | */ 24 | PreciseEncryptedLen(dataLen uint) uint 25 | 26 | /* 27 | * Release underlying C context. 28 | */ 29 | Delete() 30 | } 31 | -------------------------------------------------------------------------------- /crypto/wrapper/foundation/entropy_source.go: -------------------------------------------------------------------------------- 1 | package foundation 2 | 3 | import "C" 4 | 5 | /* 6 | * Defines generic interface for the entropy source. 7 | */ 8 | type EntropySource interface { 9 | context 10 | 11 | /* 12 | * Defines that implemented source is strong. 13 | */ 14 | IsStrong() bool 15 | 16 | /* 17 | * Gather entropy of the requested length. 18 | */ 19 | Gather(len uint) ([]byte, error) 20 | 21 | /* 22 | * Release underlying C context. 23 | */ 24 | Delete() 25 | } 26 | -------------------------------------------------------------------------------- /crypto/wrapper/foundation/fake_random_test.go: -------------------------------------------------------------------------------- 1 | // Copyright (C) 2015-2020 Virgil Security, Inc. 2 | // 3 | // All rights reserved. 4 | // 5 | // Redistribution and use in source and binary forms, with or without 6 | // modification, are permitted provided that the following conditions are 7 | // met: 8 | // 9 | // (1) Redistributions of source code must retain the above copyright 10 | // notice, this list of conditions and the following disclaimer. 11 | // 12 | // (2) Redistributions in binary form must reproduce the above copyright 13 | // notice, this list of conditions and the following disclaimer in 14 | // the documentation and/or other materials provided with the 15 | // distribution. 16 | // 17 | // (3) Neither the name of the copyright holder nor the names of its 18 | // contributors may be used to endorse or promote products derived from 19 | // this software without specific prior written permission. 20 | // 21 | // THIS SOFTWARE IS PROVIDED BY THE AUTHOR ''AS IS'' AND ANY EXPRESS OR 22 | // IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED 23 | // WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE 24 | // DISCLAIMED. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, 25 | // INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES 26 | // (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR 27 | // SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) 28 | // HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, 29 | // STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING 30 | // IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE 31 | // POSSIBILITY OF SUCH DAMAGE. 32 | // 33 | // Lead Maintainer: Virgil Security Inc. 34 | 35 | package foundation 36 | 37 | import ( 38 | "github.com/stretchr/testify/require" 39 | "testing" 40 | ) 41 | 42 | func TestNewFakeRandom(t *testing.T) { 43 | fakeRandom := NewFakeRandom() 44 | 45 | require.NotNil(t, fakeRandom) 46 | } 47 | 48 | func TestFakeRandom_Random(t *testing.T) { 49 | fakeRandom := NewFakeRandom() 50 | bytes, err := fakeRandom.Random(10) 51 | require.Nil(t, err) 52 | require.NotNil(t, bytes) 53 | require.Equal(t, 10, len(bytes)) 54 | } 55 | -------------------------------------------------------------------------------- /crypto/wrapper/foundation/group_msg_type.go: -------------------------------------------------------------------------------- 1 | package foundation 2 | 3 | import "C" 4 | 5 | /* 6 | * Represents group message type 7 | */ 8 | type GroupMsgType int 9 | 10 | const ( 11 | /* 12 | * Group info type with encryption key. 13 | * This type of message should be encrypted before transferring. 14 | */ 15 | GroupMsgTypeGroupInfo GroupMsgType = 1 16 | /* 17 | * Regular group message with encrypted text. 18 | */ 19 | GroupMsgTypeRegular GroupMsgType = 2 20 | ) 21 | -------------------------------------------------------------------------------- /crypto/wrapper/foundation/hash.go: -------------------------------------------------------------------------------- 1 | package foundation 2 | 3 | import "C" 4 | 5 | /* 6 | * Provides interface to the hashing (messege digest) algorithms. 7 | */ 8 | type Hash interface { 9 | context 10 | 11 | /* 12 | * Length of the digest (hashing output) in bytes. 13 | */ 14 | GetDigestLen() uint 15 | 16 | /* 17 | * Block length of the digest function in bytes. 18 | */ 19 | GetBlockLen() uint 20 | 21 | /* 22 | * Calculate hash over given data. 23 | */ 24 | Hash(data []byte) []byte 25 | 26 | /* 27 | * Start a new hashing. 28 | */ 29 | Start() 30 | 31 | /* 32 | * Add given data to the hash. 33 | */ 34 | Update(data []byte) 35 | 36 | /* 37 | * Accompilsh hashing and return it's result (a message digest). 38 | */ 39 | Finish() []byte 40 | 41 | /* 42 | * Release underlying C context. 43 | */ 44 | Delete() 45 | } 46 | -------------------------------------------------------------------------------- /crypto/wrapper/foundation/helper.go: -------------------------------------------------------------------------------- 1 | package foundation 2 | 3 | // #include 4 | import "C" 5 | import unsafe "unsafe" 6 | 7 | type helper struct { 8 | } 9 | 10 | func helperBytesToBytePtr(data []byte) *C.uint8_t { 11 | return (*C.uint8_t)(&data[0]) 12 | } 13 | 14 | func helperWrapData(data []byte) C.vsc_data_t { 15 | if len(data) == 0 { 16 | return C.vsc_data_empty() 17 | } 18 | return C.vsc_data((*C.uint8_t)(&data[0]), C.size_t(len(data))) 19 | } 20 | 21 | func helperExtractData(data C.vsc_data_t) []byte { 22 | newSize := data.len 23 | //FIXME Verify data is not corrupted 24 | //if newSize < len(data.bytes) { 25 | // panic("Underlying C buffer corrupt the memory.") 26 | //} 27 | return C.GoBytes(unsafe.Pointer(data.bytes), C.int(newSize)) 28 | } 29 | 30 | type buffer struct { 31 | memory []byte 32 | ctx *C.vsc_buffer_t 33 | data []byte 34 | } 35 | 36 | func newBuffer(cap int) (*buffer, error) { 37 | capacity := C.size_t(cap) 38 | if capacity == 0 { 39 | return nil, &FoundationError{-1, "Buffer with zero capacity is not allowed."} 40 | } 41 | 42 | ctxLen := C.vsc_buffer_ctx_size() 43 | memory := make([]byte, int(ctxLen+capacity)) 44 | ctx := (*C.vsc_buffer_t)(unsafe.Pointer(&memory[0])) 45 | data := memory[int(ctxLen):] 46 | 47 | C.vsc_buffer_init(ctx) 48 | C.vsc_buffer_use(ctx, (*C.byte)(unsafe.Pointer(&data[0])), capacity) 49 | 50 | return &buffer{ 51 | memory: memory, 52 | ctx: ctx, 53 | data: data, 54 | }, nil 55 | } 56 | 57 | func (obj *buffer) getData() []byte { 58 | newSize := int(C.vsc_buffer_len(obj.ctx)) 59 | if newSize > len(obj.data) { 60 | panic("Underlying C buffer corrupt the memory.") 61 | } 62 | return obj.data[:newSize] 63 | } 64 | 65 | func (obj *buffer) cap() int { 66 | return int(C.vsc_buffer_capacity(obj.ctx)) 67 | } 68 | 69 | func (obj *buffer) len() int { 70 | return int(C.vsc_buffer_len(obj.ctx)) 71 | } 72 | 73 | /* 74 | * Release underlying C context. 75 | */ 76 | func (obj *buffer) delete() { 77 | C.vsc_buffer_delete(obj.ctx) 78 | } 79 | -------------------------------------------------------------------------------- /crypto/wrapper/foundation/kdf.go: -------------------------------------------------------------------------------- 1 | package foundation 2 | 3 | import "C" 4 | 5 | /* 6 | * Provides interface to the key derivation function (KDF) algorithms. 7 | */ 8 | type Kdf interface { 9 | context 10 | 11 | /* 12 | * Derive key of the requested length from the given data. 13 | */ 14 | Derive(data []byte, keyLen uint) []byte 15 | 16 | /* 17 | * Release underlying C context. 18 | */ 19 | Delete() 20 | } 21 | -------------------------------------------------------------------------------- /crypto/wrapper/foundation/kem.go: -------------------------------------------------------------------------------- 1 | package foundation 2 | 3 | import "C" 4 | 5 | /* 6 | * Provides generic interface to the Key Encapsulation Mechanism (KEM). 7 | */ 8 | type Kem interface { 9 | context 10 | 11 | /* 12 | * Return length in bytes required to hold encapsulated shared key. 13 | */ 14 | KemSharedKeyLen(key Key) uint 15 | 16 | /* 17 | * Return length in bytes required to hold encapsulated key. 18 | */ 19 | KemEncapsulatedKeyLen(publicKey PublicKey) uint 20 | 21 | /* 22 | * Generate a shared key and a key encapsulated message. 23 | */ 24 | KemEncapsulate(publicKey PublicKey) ([]byte, []byte, error) 25 | 26 | /* 27 | * Decapsulate the shared key. 28 | */ 29 | KemDecapsulate(encapsulatedKey []byte, privateKey PrivateKey) ([]byte, error) 30 | 31 | /* 32 | * Release underlying C context. 33 | */ 34 | Delete() 35 | } 36 | -------------------------------------------------------------------------------- /crypto/wrapper/foundation/key.go: -------------------------------------------------------------------------------- 1 | package foundation 2 | 3 | import "C" 4 | 5 | /* 6 | * Basic key type. 7 | */ 8 | type Key interface { 9 | context 10 | 11 | /* 12 | * Algorithm identifier the key belongs to. 13 | */ 14 | AlgId() AlgId 15 | 16 | /* 17 | * Return algorithm information that can be used for serialization. 18 | */ 19 | AlgInfo() (AlgInfo, error) 20 | 21 | /* 22 | * Length of the key in bytes. 23 | */ 24 | Len() uint 25 | 26 | /* 27 | * Length of the key in bits. 28 | */ 29 | Bitlen() uint 30 | 31 | /* 32 | * Check that key is valid. 33 | * Note, this operation can be slow. 34 | */ 35 | IsValid() bool 36 | 37 | /* 38 | * Release underlying C context. 39 | */ 40 | Delete() 41 | } 42 | -------------------------------------------------------------------------------- /crypto/wrapper/foundation/key_cipher.go: -------------------------------------------------------------------------------- 1 | package foundation 2 | 3 | import "C" 4 | 5 | /* 6 | * Provide data encryption and decryption interface with asymmetric keys. 7 | */ 8 | type KeyCipher interface { 9 | context 10 | 11 | /* 12 | * Check if algorithm can encrypt data with a given key. 13 | */ 14 | CanEncrypt(publicKey PublicKey, dataLen uint) bool 15 | 16 | /* 17 | * Calculate required buffer length to hold the encrypted data. 18 | */ 19 | EncryptedLen(publicKey PublicKey, dataLen uint) uint 20 | 21 | /* 22 | * Encrypt data with a given public key. 23 | */ 24 | Encrypt(publicKey PublicKey, data []byte) ([]byte, error) 25 | 26 | /* 27 | * Check if algorithm can decrypt data with a given key. 28 | * However, success result of decryption is not guaranteed. 29 | */ 30 | CanDecrypt(privateKey PrivateKey, dataLen uint) bool 31 | 32 | /* 33 | * Calculate required buffer length to hold the decrypted data. 34 | */ 35 | DecryptedLen(privateKey PrivateKey, dataLen uint) uint 36 | 37 | /* 38 | * Decrypt given data. 39 | */ 40 | Decrypt(privateKey PrivateKey, data []byte) ([]byte, error) 41 | 42 | /* 43 | * Release underlying C context. 44 | */ 45 | Delete() 46 | } 47 | -------------------------------------------------------------------------------- /crypto/wrapper/foundation/key_deserializer.go: -------------------------------------------------------------------------------- 1 | package foundation 2 | 3 | import "C" 4 | 5 | /* 6 | * Public and private key deserialization from an interchangeable format. 7 | */ 8 | type KeyDeserializer interface { 9 | context 10 | 11 | /* 12 | * Deserialize given public key as an interchangeable format to the object. 13 | */ 14 | DeserializePublicKey(publicKeyData []byte) (*RawPublicKey, error) 15 | 16 | /* 17 | * Deserialize given private key as an interchangeable format to the object. 18 | */ 19 | DeserializePrivateKey(privateKeyData []byte) (*RawPrivateKey, error) 20 | 21 | /* 22 | * Release underlying C context. 23 | */ 24 | Delete() 25 | } 26 | -------------------------------------------------------------------------------- /crypto/wrapper/foundation/key_serializer.go: -------------------------------------------------------------------------------- 1 | package foundation 2 | 3 | import "C" 4 | 5 | /* 6 | * Public and private key serialization to an interchangeable format. 7 | */ 8 | type KeySerializer interface { 9 | context 10 | 11 | /* 12 | * Calculate buffer size enough to hold serialized public key. 13 | * 14 | * Precondition: public key must be exportable. 15 | */ 16 | SerializedPublicKeyLen(publicKey *RawPublicKey) uint 17 | 18 | /* 19 | * Serialize given public key to an interchangeable format. 20 | * 21 | * Precondition: public key must be exportable. 22 | */ 23 | SerializePublicKey(publicKey *RawPublicKey) ([]byte, error) 24 | 25 | /* 26 | * Calculate buffer size enough to hold serialized private key. 27 | * 28 | * Precondition: private key must be exportable. 29 | */ 30 | SerializedPrivateKeyLen(privateKey *RawPrivateKey) uint 31 | 32 | /* 33 | * Serialize given private key to an interchangeable format. 34 | * 35 | * Precondition: private key must be exportable. 36 | */ 37 | SerializePrivateKey(privateKey *RawPrivateKey) ([]byte, error) 38 | 39 | /* 40 | * Release underlying C context. 41 | */ 42 | Delete() 43 | } 44 | -------------------------------------------------------------------------------- /crypto/wrapper/foundation/key_signer.go: -------------------------------------------------------------------------------- 1 | package foundation 2 | 3 | import "C" 4 | 5 | /* 6 | * Provide an interface for signing and verifying data digest 7 | * with asymmetric keys. 8 | */ 9 | type KeySigner interface { 10 | context 11 | 12 | /* 13 | * Check if algorithm can sign data digest with a given key. 14 | */ 15 | CanSign(privateKey PrivateKey) bool 16 | 17 | /* 18 | * Return length in bytes required to hold signature. 19 | * Return zero if a given private key can not produce signatures. 20 | */ 21 | SignatureLen(privateKey PrivateKey) uint 22 | 23 | /* 24 | * Sign data digest with a given private key. 25 | */ 26 | SignHash(privateKey PrivateKey, hashId AlgId, digest []byte) ([]byte, error) 27 | 28 | /* 29 | * Check if algorithm can verify data digest with a given key. 30 | */ 31 | CanVerify(publicKey PublicKey) bool 32 | 33 | /* 34 | * Verify data digest with a given public key and signature. 35 | */ 36 | VerifyHash(publicKey PublicKey, hashId AlgId, digest []byte, signature []byte) bool 37 | 38 | /* 39 | * Release underlying C context. 40 | */ 41 | Delete() 42 | } 43 | -------------------------------------------------------------------------------- /crypto/wrapper/foundation/mac.go: -------------------------------------------------------------------------------- 1 | package foundation 2 | 3 | import "C" 4 | 5 | /* 6 | * Provides interface to the stateless MAC (message authentication code) algorithms. 7 | */ 8 | type Mac interface { 9 | context 10 | 11 | /* 12 | * Size of the digest (mac output) in bytes. 13 | */ 14 | DigestLen() uint 15 | 16 | /* 17 | * Calculate MAC over given data. 18 | */ 19 | Mac(key []byte, data []byte) []byte 20 | 21 | /* 22 | * Start a new MAC. 23 | */ 24 | Start(key []byte) 25 | 26 | /* 27 | * Add given data to the MAC. 28 | */ 29 | Update(data []byte) 30 | 31 | /* 32 | * Accomplish MAC and return it's result (a message digest). 33 | */ 34 | Finish() []byte 35 | 36 | /* 37 | * Prepare to authenticate a new message with the same key 38 | * as the previous MAC operation. 39 | */ 40 | Reset() 41 | 42 | /* 43 | * Release underlying C context. 44 | */ 45 | Delete() 46 | } 47 | -------------------------------------------------------------------------------- /crypto/wrapper/foundation/message_info_footer_serializer.go: -------------------------------------------------------------------------------- 1 | package foundation 2 | 3 | import "C" 4 | 5 | /* 6 | * Provide interface for "message info footer" class serialization. 7 | */ 8 | type MessageInfoFooterSerializer interface { 9 | context 10 | 11 | /* 12 | * Return buffer size enough to hold serialized message info footer. 13 | */ 14 | SerializedFooterLen(messageInfoFooter *MessageInfoFooter) uint 15 | 16 | /* 17 | * Serialize class "message info footer". 18 | */ 19 | SerializeFooter(messageInfoFooter *MessageInfoFooter) []byte 20 | 21 | /* 22 | * Deserialize class "message info footer". 23 | */ 24 | DeserializeFooter(data []byte) (*MessageInfoFooter, error) 25 | 26 | /* 27 | * Release underlying C context. 28 | */ 29 | Delete() 30 | } 31 | -------------------------------------------------------------------------------- /crypto/wrapper/foundation/message_info_serializer.go: -------------------------------------------------------------------------------- 1 | package foundation 2 | 3 | import "C" 4 | 5 | /* 6 | * Provide interface for "message info" class serialization. 7 | */ 8 | type MessageInfoSerializer interface { 9 | context 10 | 11 | GetPrefixLen() uint 12 | 13 | /* 14 | * Return buffer size enough to hold serialized message info. 15 | */ 16 | SerializedLen(messageInfo *MessageInfo) uint 17 | 18 | /* 19 | * Serialize class "message info". 20 | */ 21 | Serialize(messageInfo *MessageInfo) []byte 22 | 23 | /* 24 | * Read message info prefix from the given data, and if it is valid, 25 | * return a length of bytes of the whole message info. 26 | * 27 | * Zero returned if length can not be determined from the given data, 28 | * and this means that there is no message info at the data beginning. 29 | */ 30 | ReadPrefix(data []byte) uint 31 | 32 | /* 33 | * Deserialize class "message info". 34 | */ 35 | Deserialize(data []byte) (*MessageInfo, error) 36 | 37 | /* 38 | * Release underlying C context. 39 | */ 40 | Delete() 41 | } 42 | -------------------------------------------------------------------------------- /crypto/wrapper/foundation/oid.go: -------------------------------------------------------------------------------- 1 | package foundation 2 | 3 | // #include 4 | import "C" 5 | 6 | /* 7 | * Provide conversion logic between OID and algorithm tags. 8 | */ 9 | type Oid struct { 10 | } 11 | 12 | /* 13 | * Return OID for given algorithm identifier. 14 | */ 15 | func OidFromAlgId(algId AlgId) []byte { 16 | proxyResult := /*pr4*/ C.vscf_oid_from_alg_id(C.vscf_alg_id_t(algId) /*pa7*/) 17 | 18 | return helperExtractData(proxyResult) /* r1 */ 19 | } 20 | 21 | /* 22 | * Return algorithm identifier for given OID. 23 | */ 24 | func OidToAlgId(oid []byte) AlgId { 25 | oidData := helperWrapData(oid) 26 | 27 | proxyResult := /*pr4*/ C.vscf_oid_to_alg_id(oidData) 28 | 29 | return AlgId(proxyResult) /* r8 */ 30 | } 31 | 32 | /* 33 | * Return OID for a given identifier. 34 | */ 35 | func OidFromId(oidId OidId) []byte { 36 | proxyResult := /*pr4*/ C.vscf_oid_from_id(C.vscf_oid_id_t(oidId) /*pa7*/) 37 | 38 | return helperExtractData(proxyResult) /* r1 */ 39 | } 40 | 41 | /* 42 | * Return identifier for a given OID. 43 | */ 44 | func OidToId(oid []byte) OidId { 45 | oidData := helperWrapData(oid) 46 | 47 | proxyResult := /*pr4*/ C.vscf_oid_to_id(oidData) 48 | 49 | return OidId(proxyResult) /* r8 */ 50 | } 51 | 52 | /* 53 | * Map oid identifier to the algorithm identifier. 54 | */ 55 | func OidIdToAlgId(oidId OidId) AlgId { 56 | proxyResult := /*pr4*/ C.vscf_oid_id_to_alg_id(C.vscf_oid_id_t(oidId) /*pa7*/) 57 | 58 | return AlgId(proxyResult) /* r8 */ 59 | } 60 | 61 | /* 62 | * Return true if given OIDs are equal. 63 | */ 64 | func OidEqual(lhs []byte, rhs []byte) bool { 65 | lhsData := helperWrapData(lhs) 66 | rhsData := helperWrapData(rhs) 67 | 68 | proxyResult := /*pr4*/ C.vscf_oid_equal(lhsData, rhsData) 69 | 70 | return bool(proxyResult) /* r9 */ 71 | } 72 | -------------------------------------------------------------------------------- /crypto/wrapper/foundation/oid_id.go: -------------------------------------------------------------------------------- 1 | package foundation 2 | 3 | import "C" 4 | 5 | type OidId int 6 | 7 | const ( 8 | OidIdNone OidId = 0 9 | OidIdRsa OidId = 1 10 | OidIdEd25519 OidId = 2 11 | OidIdCurve25519 OidId = 3 12 | OidIdSha224 OidId = 4 13 | OidIdSha256 OidId = 5 14 | OidIdSha384 OidId = 6 15 | OidIdSha512 OidId = 7 16 | OidIdKdf1 OidId = 8 17 | OidIdKdf2 OidId = 9 18 | OidIdAes256Gcm OidId = 10 19 | OidIdAes256Cbc OidId = 11 20 | OidIdPkcs5Pbkdf2 OidId = 12 21 | OidIdPkcs5Pbes2 OidId = 13 22 | OidIdCmsData OidId = 14 23 | OidIdCmsEnvelopedData OidId = 15 24 | OidIdHkdfWithSha256 OidId = 16 25 | OidIdHkdfWithSha384 OidId = 17 26 | OidIdHkdfWithSha512 OidId = 18 27 | OidIdHmacWithSha224 OidId = 19 28 | OidIdHmacWithSha256 OidId = 20 29 | OidIdHmacWithSha384 OidId = 21 30 | OidIdHmacWithSha512 OidId = 22 31 | OidIdEcGenericKey OidId = 23 32 | OidIdEcDomainSecp256r1 OidId = 24 33 | OidIdCompoundKey OidId = 25 34 | OidIdHybridKey OidId = 26 35 | OidIdFalcon OidId = 27 36 | OidIdRound5Nd1cca5d OidId = 28 37 | OidIdRandomPadding OidId = 29 38 | ) 39 | -------------------------------------------------------------------------------- /crypto/wrapper/foundation/padding.go: -------------------------------------------------------------------------------- 1 | package foundation 2 | 3 | import "C" 4 | 5 | /* 6 | * Provide an interface to add and remove data padding. 7 | */ 8 | type Padding interface { 9 | context 10 | 11 | /* 12 | * Set new padding parameters. 13 | */ 14 | Configure(params *PaddingParams) 15 | 16 | /* 17 | * Return length in bytes of a data with a padding. 18 | */ 19 | PaddedDataLen(dataLen uint) uint 20 | 21 | /* 22 | * Return an actual number of padding in bytes. 23 | * Note, this method might be called right before "finish data processing". 24 | */ 25 | Len() uint 26 | 27 | /* 28 | * Return a maximum number of padding in bytes. 29 | */ 30 | LenMax() uint 31 | 32 | /* 33 | * Prepare the algorithm to process data. 34 | */ 35 | StartDataProcessing() 36 | 37 | /* 38 | * Only data length is needed to produce padding later. 39 | * Return data that should be further proceeded. 40 | */ 41 | ProcessData(data []byte) []byte 42 | 43 | /* 44 | * Accomplish data processing and return padding. 45 | */ 46 | FinishDataProcessing() ([]byte, error) 47 | 48 | /* 49 | * Prepare the algorithm to process padded data. 50 | */ 51 | StartPaddedDataProcessing() 52 | 53 | /* 54 | * Process padded data. 55 | * Return filtered data without padding. 56 | */ 57 | ProcessPaddedData(data []byte) []byte 58 | 59 | /* 60 | * Return length in bytes required hold output of the method 61 | * "finish padded data processing". 62 | */ 63 | FinishPaddedDataProcessingOutLen() uint 64 | 65 | /* 66 | * Accomplish padded data processing and return left data without a padding. 67 | */ 68 | FinishPaddedDataProcessing() ([]byte, error) 69 | 70 | /* 71 | * Release underlying C context. 72 | */ 73 | Delete() 74 | } 75 | -------------------------------------------------------------------------------- /crypto/wrapper/foundation/platform.go: -------------------------------------------------------------------------------- 1 | package foundation 2 | 3 | // #cgo darwin CFLAGS: -I${SRCDIR}/../pkg/darwin_amd64/include/ 4 | // #cgo darwin LDFLAGS: -L${SRCDIR}/../pkg/darwin_amd64/lib -lvsc_foundation -lvsc_foundation_pb -led25519 -lprotobuf-nanopb -lvsc_common -lmbedcrypto -lround5 -lfalcon 5 | // #cgo linux,!legacy CFLAGS: -I${SRCDIR}/../pkg/linux_amd64/include/ 6 | // #cgo linux,!legacy LDFLAGS: -L${SRCDIR}/../pkg/linux_amd64/lib -lvsc_foundation -lvsc_foundation_pb -led25519 -lprotobuf-nanopb -lvsc_common -lmbedcrypto -lround5 -lfalcon -lpthread 7 | // #cgo linux,legacy CFLAGS: -I${SRCDIR}/../pkg/linux_amd64__legacy_os/include/ 8 | // #cgo linux,legacy LDFLAGS: -L${SRCDIR}/../pkg/linux_amd64__legacy_os/lib -lvsc_foundation -lvsc_foundation_pb -led25519 -lprotobuf-nanopb -lvsc_common -lmbedcrypto -lround5 -lfalcon -lpthread 9 | // #cgo windows CFLAGS: -I${SRCDIR}/../pkg/windows_amd64/include/ 10 | // #cgo windows LDFLAGS: -L${SRCDIR}/../pkg/windows_amd64/lib -lvsc_foundation -lvsc_foundation_pb -led25519 -lprotobuf-nanopb -lvsc_common -lmbedcrypto -lround5 -lfalcon 11 | import "C" 12 | -------------------------------------------------------------------------------- /crypto/wrapper/foundation/private_key.go: -------------------------------------------------------------------------------- 1 | package foundation 2 | 3 | import "C" 4 | 5 | /* 6 | * Contains private part of the key. 7 | */ 8 | type PrivateKey interface { 9 | context 10 | 11 | /* 12 | * Extract public key from the private key. 13 | */ 14 | ExtractPublicKey() (PublicKey, error) 15 | 16 | /* 17 | * Release underlying C context. 18 | */ 19 | Delete() 20 | } 21 | -------------------------------------------------------------------------------- /crypto/wrapper/foundation/public_key.go: -------------------------------------------------------------------------------- 1 | package foundation 2 | 3 | import "C" 4 | 5 | /* 6 | * Contains public part of the key. 7 | */ 8 | type PublicKey interface { 9 | context 10 | 11 | /* 12 | * Release underlying C context. 13 | */ 14 | Delete() 15 | } 16 | -------------------------------------------------------------------------------- /crypto/wrapper/foundation/random.go: -------------------------------------------------------------------------------- 1 | package foundation 2 | 3 | import "C" 4 | 5 | /* 6 | * Common interface to get random data. 7 | */ 8 | type Random interface { 9 | context 10 | 11 | /* 12 | * Generate random bytes. 13 | * All RNG implementations must be thread-safe. 14 | */ 15 | Random(dataLen uint) ([]byte, error) 16 | 17 | /* 18 | * Retrieve new seed data from the entropy sources. 19 | */ 20 | Reseed() error 21 | 22 | /* 23 | * Release underlying C context. 24 | */ 25 | Delete() 26 | } 27 | -------------------------------------------------------------------------------- /crypto/wrapper/foundation/salted_kdf.go: -------------------------------------------------------------------------------- 1 | package foundation 2 | 3 | import "C" 4 | 5 | /* 6 | * Provides interface to the key derivation function (KDF) algorithms 7 | * that use salt and teration count. 8 | */ 9 | type SaltedKdf interface { 10 | context 11 | 12 | /* 13 | * Prepare algorithm to derive new key. 14 | */ 15 | Reset(salt []byte, iterationCount uint) 16 | 17 | /* 18 | * Setup application specific information (optional). 19 | * Can be empty. 20 | */ 21 | SetInfo(info []byte) 22 | 23 | /* 24 | * Release underlying C context. 25 | */ 26 | Delete() 27 | } 28 | -------------------------------------------------------------------------------- /crypto/wrapper/foundation/signed_data_info.go: -------------------------------------------------------------------------------- 1 | package foundation 2 | 3 | // #include 4 | import "C" 5 | import unsafe "unsafe" 6 | import "runtime" 7 | 8 | /* 9 | * Handle meta information about signed data. 10 | */ 11 | type SignedDataInfo struct { 12 | cCtx *C.vscf_signed_data_info_t /*ct2*/ 13 | } 14 | 15 | /* Handle underlying C context. */ 16 | func (obj *SignedDataInfo) Ctx() uintptr { 17 | return uintptr(unsafe.Pointer(obj.cCtx)) 18 | } 19 | 20 | func NewSignedDataInfo() *SignedDataInfo { 21 | ctx := C.vscf_signed_data_info_new() 22 | obj := &SignedDataInfo{ 23 | cCtx: ctx, 24 | } 25 | runtime.SetFinalizer(obj, (*SignedDataInfo).Delete) 26 | return obj 27 | } 28 | 29 | /* Acquire C context. 30 | * Note. This method is used in generated code only, and SHOULD NOT be used in another way. 31 | */ 32 | func newSignedDataInfoWithCtx(ctx *C.vscf_signed_data_info_t /*ct2*/) *SignedDataInfo { 33 | obj := &SignedDataInfo{ 34 | cCtx: ctx, 35 | } 36 | runtime.SetFinalizer(obj, (*SignedDataInfo).Delete) 37 | return obj 38 | } 39 | 40 | /* Acquire retained C context. 41 | * Note. This method is used in generated code only, and SHOULD NOT be used in another way. 42 | */ 43 | func newSignedDataInfoCopy(ctx *C.vscf_signed_data_info_t /*ct2*/) *SignedDataInfo { 44 | obj := &SignedDataInfo{ 45 | cCtx: C.vscf_signed_data_info_shallow_copy(ctx), 46 | } 47 | runtime.SetFinalizer(obj, (*SignedDataInfo).Delete) 48 | return obj 49 | } 50 | 51 | /* 52 | * Release underlying C context. 53 | */ 54 | func (obj *SignedDataInfo) Delete() { 55 | if obj == nil { 56 | return 57 | } 58 | runtime.SetFinalizer(obj, nil) 59 | obj.delete() 60 | } 61 | 62 | /* 63 | * Release underlying C context. 64 | */ 65 | func (obj *SignedDataInfo) delete() { 66 | C.vscf_signed_data_info_delete(obj.cCtx) 67 | } 68 | 69 | /* 70 | * Return information about algorithm that was used to produce data digest. 71 | */ 72 | func (obj *SignedDataInfo) HashAlgInfo() (AlgInfo, error) { 73 | proxyResult := /*pr4*/ C.vscf_signed_data_info_hash_alg_info(obj.cCtx) 74 | 75 | runtime.KeepAlive(obj) 76 | 77 | return FoundationImplementationWrapAlgInfoCopy(proxyResult) /* r4.1 */ 78 | } 79 | -------------------------------------------------------------------------------- /crypto/wrapper/foundation/simple_alg_info_test.go: -------------------------------------------------------------------------------- 1 | // Copyright (C) 2015-2020 Virgil Security, Inc. 2 | // 3 | // All rights reserved. 4 | // 5 | // Redistribution and use in source and binary forms, with or without 6 | // modification, are permitted provided that the following conditions are 7 | // met: 8 | // 9 | // (1) Redistributions of source code must retain the above copyright 10 | // notice, this list of conditions and the following disclaimer. 11 | // 12 | // (2) Redistributions in binary form must reproduce the above copyright 13 | // notice, this list of conditions and the following disclaimer in 14 | // the documentation and/or other materials provided with the 15 | // distribution. 16 | // 17 | // (3) Neither the name of the copyright holder nor the names of its 18 | // contributors may be used to endorse or promote products derived from 19 | // this software without specific prior written permission. 20 | // 21 | // THIS SOFTWARE IS PROVIDED BY THE AUTHOR ''AS IS'' AND ANY EXPRESS OR 22 | // IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED 23 | // WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE 24 | // DISCLAIMED. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, 25 | // INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES 26 | // (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR 27 | // SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) 28 | // HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, 29 | // STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING 30 | // IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE 31 | // POSSIBILITY OF SUCH DAMAGE. 32 | // 33 | // Lead Maintainer: Virgil Security Inc. 34 | 35 | package foundation 36 | 37 | import ( 38 | "github.com/stretchr/testify/require" 39 | "testing" 40 | ) 41 | 42 | func TestNewSimpleAlgInfoWithAlgId(t *testing.T) { 43 | simpleAlgInfo := NewSimpleAlgInfoWithAlgId(AlgIdAes256Cbc) 44 | 45 | require.Equal(t, AlgIdAes256Cbc, simpleAlgInfo.AlgId()) 46 | } 47 | 48 | func TestSimpleAlgInfo_AlgId(t *testing.T) { 49 | simpleAlgInfo := NewSimpleAlgInfo() 50 | 51 | require.Equal(t, AlgIdNone, simpleAlgInfo.AlgId()) 52 | } 53 | -------------------------------------------------------------------------------- /crypto/wrapper/phe/context.go: -------------------------------------------------------------------------------- 1 | package phe 2 | 3 | // #include 4 | import "C" 5 | 6 | type context interface { 7 | 8 | /* Get C context */ 9 | Ctx() uintptr 10 | } 11 | -------------------------------------------------------------------------------- /crypto/wrapper/phe/helper.go: -------------------------------------------------------------------------------- 1 | package phe 2 | 3 | // #include 4 | import "C" 5 | import unsafe "unsafe" 6 | 7 | type helper struct { 8 | } 9 | 10 | func helperBytesToBytePtr(data []byte) *C.uint8_t { 11 | return (*C.uint8_t)(&data[0]) 12 | } 13 | 14 | func helperWrapData(data []byte) C.vsc_data_t { 15 | if len(data) == 0 { 16 | return C.vsc_data_empty() 17 | } 18 | return C.vsc_data((*C.uint8_t)(&data[0]), C.size_t(len(data))) 19 | } 20 | 21 | func helperExtractData(data C.vsc_data_t) []byte { 22 | newSize := data.len 23 | //FIXME Verify data is not corrupted 24 | //if newSize < len(data.bytes) { 25 | // panic("Underlying C buffer corrupt the memory.") 26 | //} 27 | return C.GoBytes(unsafe.Pointer(data.bytes), C.int(newSize)) 28 | } 29 | 30 | type buffer struct { 31 | memory []byte 32 | ctx *C.vsc_buffer_t 33 | data []byte 34 | } 35 | 36 | func newBuffer(cap int) (*buffer, error) { 37 | capacity := C.size_t(cap) 38 | if capacity == 0 { 39 | return nil, &PheError{-1, "Buffer with zero capacity is not allowed."} 40 | } 41 | 42 | ctxLen := C.vsc_buffer_ctx_size() 43 | memory := make([]byte, int(ctxLen+capacity)) 44 | ctx := (*C.vsc_buffer_t)(unsafe.Pointer(&memory[0])) 45 | data := memory[int(ctxLen):] 46 | 47 | C.vsc_buffer_init(ctx) 48 | C.vsc_buffer_use(ctx, (*C.byte)(unsafe.Pointer(&data[0])), capacity) 49 | 50 | return &buffer{ 51 | memory: memory, 52 | ctx: ctx, 53 | data: data, 54 | }, nil 55 | } 56 | 57 | func (obj *buffer) getData() []byte { 58 | newSize := int(C.vsc_buffer_len(obj.ctx)) 59 | if newSize > len(obj.data) { 60 | panic("Underlying C buffer corrupt the memory.") 61 | } 62 | return obj.data[:newSize] 63 | } 64 | 65 | func (obj *buffer) cap() int { 66 | return int(C.vsc_buffer_capacity(obj.ctx)) 67 | } 68 | 69 | func (obj *buffer) len() int { 70 | return int(C.vsc_buffer_len(obj.ctx)) 71 | } 72 | 73 | /* 74 | * Release underlying C context. 75 | */ 76 | func (obj *buffer) delete() { 77 | C.vsc_buffer_delete(obj.ctx) 78 | } 79 | -------------------------------------------------------------------------------- /crypto/wrapper/phe/phe_common.go: -------------------------------------------------------------------------------- 1 | package phe 2 | 3 | // #include 4 | import "C" 5 | 6 | type PheCommon struct { 7 | } 8 | 9 | const ( 10 | /* 11 | * PHE elliptic curve point binary length 12 | */ 13 | PheCommonPhePointLength uint = 65 14 | /* 15 | * PHE max password length 16 | */ 17 | PheCommonPheMaxPasswordLength uint = 128 18 | /* 19 | * PHE server identifier length 20 | */ 21 | PheCommonPheServerIdentifierLength uint = 32 22 | /* 23 | * PHE client identifier length 24 | */ 25 | PheCommonPheClientIdentifierLength uint = 32 26 | /* 27 | * PHE account key length 28 | */ 29 | PheCommonPheAccountKeyLength uint = 32 30 | /* 31 | * PHE private key length 32 | */ 33 | PheCommonPhePrivateKeyLength uint = 32 34 | /* 35 | * PHE public key length 36 | */ 37 | PheCommonPhePublicKeyLength uint = 65 38 | /* 39 | * PHE hash length 40 | */ 41 | PheCommonPheHashLen uint = 32 42 | /* 43 | * Maximum data size to encrypt 44 | */ 45 | PheCommonPheMaxEncryptLen uint = 1024*1024 - 64 46 | /* 47 | * Maximum data size to decrypt 48 | */ 49 | PheCommonPheMaxDecryptLen uint = 1024 * 1024 50 | /* 51 | * Maximum data to authenticate 52 | */ 53 | PheCommonPheMaxAuthLen uint = 1024 54 | ) 55 | -------------------------------------------------------------------------------- /crypto/wrapper/phe/phe_error.go: -------------------------------------------------------------------------------- 1 | package phe 2 | 3 | // #include 4 | import "C" 5 | import "fmt" 6 | 7 | /* 8 | * Defines the library status codes. 9 | */ 10 | type PheError struct { 11 | Code int 12 | Message string 13 | } 14 | 15 | const ( 16 | /* 17 | * Success proof check failed. 18 | */ 19 | PheErrorErrorInvalidSuccessProof int = -1 20 | /* 21 | * Failure proof check failed. 22 | */ 23 | PheErrorErrorInvalidFailProof int = -2 24 | /* 25 | * RNG returned error. 26 | */ 27 | PheErrorErrorRNGFailed int = -3 28 | /* 29 | * Protobuf decode failed. 30 | */ 31 | PheErrorErrorProtobufDecodeFailed int = -4 32 | /* 33 | * Invalid public key. 34 | */ 35 | PheErrorErrorInvalidPublicKey int = -5 36 | /* 37 | * Invalid private key. 38 | */ 39 | PheErrorErrorInvalidPrivateKey int = -6 40 | /* 41 | * AES error occurred. 42 | */ 43 | PheErrorErrorAESFailed int = -7 44 | ) 45 | 46 | func (obj *PheError) Error() string { 47 | return fmt.Sprintf("PheError{code: %v message: %s}", obj.Code, obj.Message) 48 | } 49 | 50 | /* Check given C status, and if it's not "success" then raise correspond error. */ 51 | func PheErrorHandleStatus(status C.vsce_status_t) error { 52 | if status != C.vsce_status_SUCCESS { 53 | switch status { 54 | case C.vsce_status_ERROR_INVALID_SUCCESS_PROOF: 55 | return &PheError{int(status), "Success proof check failed."} 56 | case C.vsce_status_ERROR_INVALID_FAIL_PROOF: 57 | return &PheError{int(status), "Failure proof check failed."} 58 | case C.vsce_status_ERROR_RNG_FAILED: 59 | return &PheError{int(status), "RNG returned error."} 60 | case C.vsce_status_ERROR_PROTOBUF_DECODE_FAILED: 61 | return &PheError{int(status), "Protobuf decode failed."} 62 | case C.vsce_status_ERROR_INVALID_PUBLIC_KEY: 63 | return &PheError{int(status), "Invalid public key."} 64 | case C.vsce_status_ERROR_INVALID_PRIVATE_KEY: 65 | return &PheError{int(status), "Invalid private key."} 66 | case C.vsce_status_ERROR_AES_FAILED: 67 | return &PheError{int(status), "AES error occurred."} 68 | } 69 | } 70 | return nil 71 | } 72 | 73 | type wrapError struct { 74 | err error 75 | msg string 76 | } 77 | 78 | func (obj *wrapError) Error() string { 79 | return fmt.Sprintf("%s: %v", obj.msg, obj.err) 80 | } 81 | 82 | func (obj *wrapError) Unwrap() error { 83 | return obj.err 84 | } 85 | -------------------------------------------------------------------------------- /crypto/wrapper/phe/phe_implementation.go: -------------------------------------------------------------------------------- 1 | package phe 2 | 3 | // #include 4 | import "C" 5 | 6 | type PheImplementation struct { 7 | } 8 | -------------------------------------------------------------------------------- /crypto/wrapper/phe/phe_server_test.go: -------------------------------------------------------------------------------- 1 | // Copyright (C) 2015-2020 Virgil Security, Inc. 2 | // 3 | // All rights reserved. 4 | // 5 | // Redistribution and use in source and binary forms, with or without 6 | // modification, are permitted provided that the following conditions are 7 | // met: 8 | // 9 | // (1) Redistributions of source code must retain the above copyright 10 | // notice, this list of conditions and the following disclaimer. 11 | // 12 | // (2) Redistributions in binary form must reproduce the above copyright 13 | // notice, this list of conditions and the following disclaimer in 14 | // the documentation and/or other materials provided with the 15 | // distribution. 16 | // 17 | // (3) Neither the name of the copyright holder nor the names of its 18 | // contributors may be used to endorse or promote products derived from 19 | // this software without specific prior written permission. 20 | // 21 | // THIS SOFTWARE IS PROVIDED BY THE AUTHOR ''AS IS'' AND ANY EXPRESS OR 22 | // IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED 23 | // WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE 24 | // DISCLAIMED. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, 25 | // INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES 26 | // (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR 27 | // SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) 28 | // HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, 29 | // STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING 30 | // IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE 31 | // POSSIBILITY OF SUCH DAMAGE. 32 | // 33 | // Lead Maintainer: Virgil Security Inc. 34 | 35 | package phe 36 | 37 | import ( 38 | "github.com/stretchr/testify/require" 39 | "testing" 40 | ) 41 | 42 | func TestNewPheServer(t *testing.T) { 43 | server := NewPheServer() 44 | require.NotNil(t, server) 45 | 46 | server.Delete() 47 | } 48 | 49 | func newPheServer() *PheServer { 50 | server := NewPheServer() 51 | _ = server.SetupDefaults() 52 | 53 | return server 54 | } 55 | -------------------------------------------------------------------------------- /crypto/wrapper/phe/platform.go: -------------------------------------------------------------------------------- 1 | package phe 2 | 3 | // #cgo darwin CFLAGS: -I${SRCDIR}/../pkg/darwin_amd64/include/ 4 | // #cgo darwin LDFLAGS: -L${SRCDIR}/../pkg/darwin_amd64/lib -lvsc_phe -lvsc_phe_pb -lvsc_foundation -lvsc_foundation_pb -led25519 -lprotobuf-nanopb -lvsc_common -lmbedcrypto 5 | // #cgo linux,!legacy CFLAGS: -I${SRCDIR}/../pkg/linux_amd64/include/ 6 | // #cgo linux,!legacy LDFLAGS: -L${SRCDIR}/../pkg/linux_amd64/lib -lvsc_phe -lvsc_phe_pb -lvsc_foundation -lvsc_foundation_pb -led25519 -lprotobuf-nanopb -lvsc_common -lmbedcrypto 7 | // #cgo linux,legacy CFLAGS: -I${SRCDIR}/../pkg/linux_amd64__legacy_os/include/ 8 | // #cgo linux,legacy LDFLAGS: -L${SRCDIR}/../pkg/linux_amd64__legacy_os/lib -lvsc_phe -lvsc_phe_pb -lvsc_foundation -lvsc_foundation_pb -led25519 -lprotobuf-nanopb -lvsc_common -lmbedcrypto 9 | // #cgo windows CFLAGS: -I${SRCDIR}/../pkg/windows_amd64/include/ 10 | // #cgo windows LDFLAGS: -L${SRCDIR}/../pkg/windows_amd64/lib -lvsc_phe -lvsc_phe_pb -lvsc_foundation -lvsc_foundation_pb -led25519 -lprotobuf-nanopb -lvsc_common -lmbedcrypto 11 | import "C" 12 | -------------------------------------------------------------------------------- /crypto/wrapper/pkg/darwin_amd64/include/mbedtls/fake_alt.h: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/VirgilSecurity/virgil-sdk-go/296d175bd33a209f8b4faa42042173dd4dd63648/crypto/wrapper/pkg/darwin_amd64/include/mbedtls/fake_alt.h -------------------------------------------------------------------------------- /crypto/wrapper/pkg/darwin_amd64/include/mbedtls/havege.h: -------------------------------------------------------------------------------- 1 | /** 2 | * \file havege.h 3 | * 4 | * \brief HAVEGE: HArdware Volatile Entropy Gathering and Expansion 5 | */ 6 | /* 7 | * Copyright (C) 2006-2015, ARM Limited, All Rights Reserved 8 | * SPDX-License-Identifier: Apache-2.0 9 | * 10 | * Licensed under the Apache License, Version 2.0 (the "License"); you may 11 | * not use this file except in compliance with the License. 12 | * You may obtain a copy of the License at 13 | * 14 | * http://www.apache.org/licenses/LICENSE-2.0 15 | * 16 | * Unless required by applicable law or agreed to in writing, software 17 | * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT 18 | * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 19 | * See the License for the specific language governing permissions and 20 | * limitations under the License. 21 | * 22 | * This file is part of mbed TLS (https://tls.mbed.org) 23 | */ 24 | #ifndef MBEDTLS_HAVEGE_H 25 | #define MBEDTLS_HAVEGE_H 26 | 27 | #include 28 | 29 | #define MBEDTLS_HAVEGE_COLLECT_SIZE 1024 30 | 31 | #ifdef __cplusplus 32 | extern "C" { 33 | #endif 34 | 35 | /** 36 | * \brief HAVEGE state structure 37 | */ 38 | typedef struct mbedtls_havege_state 39 | { 40 | int PT1, PT2, offset[2]; 41 | int pool[MBEDTLS_HAVEGE_COLLECT_SIZE]; 42 | int WALK[8192]; 43 | } 44 | mbedtls_havege_state; 45 | 46 | /** 47 | * \brief HAVEGE initialization 48 | * 49 | * \param hs HAVEGE state to be initialized 50 | */ 51 | void mbedtls_havege_init( mbedtls_havege_state *hs ); 52 | 53 | /** 54 | * \brief Clear HAVEGE state 55 | * 56 | * \param hs HAVEGE state to be cleared 57 | */ 58 | void mbedtls_havege_free( mbedtls_havege_state *hs ); 59 | 60 | /** 61 | * \brief HAVEGE rand function 62 | * 63 | * \param p_rng A HAVEGE state 64 | * \param output Buffer to fill 65 | * \param len Length of buffer 66 | * 67 | * \return 0 68 | */ 69 | int mbedtls_havege_random( void *p_rng, unsigned char *output, size_t len ); 70 | 71 | #ifdef __cplusplus 72 | } 73 | #endif 74 | 75 | #endif /* havege.h */ 76 | -------------------------------------------------------------------------------- /crypto/wrapper/pkg/darwin_amd64/include/mbedtls/net.h: -------------------------------------------------------------------------------- 1 | /** 2 | * \file net.h 3 | * 4 | * \brief Deprecated header file that includes net_sockets.h 5 | * 6 | * \deprecated Superseded by mbedtls/net_sockets.h 7 | */ 8 | /* 9 | * Copyright (C) 2006-2016, ARM Limited, All Rights Reserved 10 | * SPDX-License-Identifier: Apache-2.0 11 | * 12 | * Licensed under the Apache License, Version 2.0 (the "License"); you may 13 | * not use this file except in compliance with the License. 14 | * You may obtain a copy of the License at 15 | * 16 | * http://www.apache.org/licenses/LICENSE-2.0 17 | * 18 | * Unless required by applicable law or agreed to in writing, software 19 | * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT 20 | * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 21 | * See the License for the specific language governing permissions and 22 | * limitations under the License. 23 | * 24 | * This file is part of mbed TLS (https://tls.mbed.org) 25 | */ 26 | 27 | #if !defined(MBEDTLS_DEPRECATED_REMOVED) 28 | #include "net_sockets.h" 29 | #if defined(MBEDTLS_DEPRECATED_WARNING) 30 | #warning "Deprecated header file: Superseded by mbedtls/net_sockets.h" 31 | #endif /* MBEDTLS_DEPRECATED_WARNING */ 32 | #endif /* !MBEDTLS_DEPRECATED_REMOVED */ 33 | -------------------------------------------------------------------------------- /crypto/wrapper/pkg/darwin_amd64/include/pb_common.h: -------------------------------------------------------------------------------- 1 | /* pb_common.h: Common support functions for pb_encode.c and pb_decode.c. 2 | * These functions are rarely needed by applications directly. 3 | */ 4 | 5 | #ifndef PB_COMMON_H_INCLUDED 6 | #define PB_COMMON_H_INCLUDED 7 | 8 | #include "pb.h" 9 | 10 | #ifdef __cplusplus 11 | extern "C" { 12 | #endif 13 | 14 | /* Iterator for pb_field_t list */ 15 | struct pb_field_iter_s { 16 | const pb_field_t *start; /* Start of the pb_field_t array */ 17 | const pb_field_t *pos; /* Current position of the iterator */ 18 | unsigned required_field_index; /* Zero-based index that counts only the required fields */ 19 | void *dest_struct; /* Pointer to start of the structure */ 20 | void *pData; /* Pointer to current field value */ 21 | void *pSize; /* Pointer to count/has field */ 22 | }; 23 | typedef struct pb_field_iter_s pb_field_iter_t; 24 | 25 | /* Initialize the field iterator structure to beginning. 26 | * Returns false if the message type is empty. */ 27 | bool pb_field_iter_begin(pb_field_iter_t *iter, const pb_field_t *fields, void *dest_struct); 28 | 29 | /* Advance the iterator to the next field. 30 | * Returns false when the iterator wraps back to the first field. */ 31 | bool pb_field_iter_next(pb_field_iter_t *iter); 32 | 33 | /* Advance the iterator until it points at a field with the given tag. 34 | * Returns false if no such field exists. */ 35 | bool pb_field_iter_find(pb_field_iter_t *iter, uint32_t tag); 36 | 37 | #ifdef __cplusplus 38 | } /* extern "C" */ 39 | #endif 40 | 41 | #endif 42 | 43 | -------------------------------------------------------------------------------- /crypto/wrapper/pkg/darwin_amd64/include/round5/a_fixed.h: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 2018, Koninklijke Philips N.V. 3 | */ 4 | 5 | /** 6 | * @file 7 | * Declaration of the fixed A matrix as well as the function to generate it. 8 | */ 9 | 10 | #ifndef A_FIXED_H 11 | #define A_FIXED_H 12 | 13 | #include "r5_parameter_sets.h" 14 | 15 | #if PARAMS_TAU == 1 16 | /** 17 | * The fixed A matrix for use inside with the non-ring algorithm when τ=1. 18 | * This matrix is generated by `create_A_fixed()`. 19 | */ 20 | extern modq_t A_fixed[PARAMS_D * 2 * PARAMS_K]; 21 | #endif 22 | 23 | #ifdef __cplusplus 24 | extern "C" { 25 | #endif 26 | 27 | /** 28 | * Function to generate a fixed A matrix from the given seed and algorithm parameters. 29 | * 30 | * @param[in] seed the seed to use to generate the fixed A matrix (KAPPA_BYTES bytes) 31 | * @return __0__ in case of success 32 | */ 33 | int create_A_fixed(const unsigned char *seed); 34 | 35 | #ifdef __cplusplus 36 | } 37 | #endif 38 | 39 | #endif /* A_FIXED_H */ 40 | -------------------------------------------------------------------------------- /crypto/wrapper/pkg/darwin_amd64/include/round5/a_random.h: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 2018, Koninklijke Philips N.V. 3 | */ 4 | 5 | /** 6 | * @file 7 | * Declaration of the random A matrix creation function. 8 | */ 9 | 10 | #ifndef A_RANDOM_H 11 | #define A_RANDOM_H 12 | 13 | #include "r5_parameter_sets.h" 14 | 15 | #ifdef __cplusplus 16 | extern "C" { 17 | #endif 18 | 19 | /** 20 | * Creates A random for the given seed and algorithm parameters. 21 | * 22 | * @param[out] A_random the random A to create 23 | * @param[in] seed the seed (PARAMS_KAPPA_BYTES bytes) 24 | */ 25 | void create_A_random(modq_t *A_random, const unsigned char *seed); 26 | 27 | #ifdef __cplusplus 28 | } 29 | #endif 30 | 31 | #endif /* A_RANDOM_H */ 32 | -------------------------------------------------------------------------------- /crypto/wrapper/pkg/darwin_amd64/include/round5/checkPublicParameter.h: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 2020, Koninklijke Philips N.V. 3 | */ 4 | 5 | 6 | //#ifndef checkPublicParameter_h 7 | //#define checkPublicParameter_h 8 | 9 | #include "r5_parameter_sets.h" 10 | 11 | #ifdef CM_MALFORMED 12 | int checkPublicParameter(modp_t *public_param, uint16_t num_vectors); 13 | #endif 14 | 15 | 16 | //#endif /* checkPublicParameter_h */ 17 | -------------------------------------------------------------------------------- /crypto/wrapper/pkg/darwin_amd64/include/round5/chooseparameters.h: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 2020, Koninklijke Philips N.V. 3 | */ 4 | 5 | #define PARAMETERCONSTANT 6 | 7 | #define SHAKE128_RATE 168 8 | // 168 bytes as a bytesequence = 1344 bits as a bitsequence 9 | 10 | #define SHAKE256_RATE 136 11 | // 136 bytes as a bytesequence = 1088 bits as a bitsequence 12 | 13 | #ifdef PARAMETERCONSTANT 14 | 15 | #include "r5_parameter_sets.h" 16 | 17 | #define Parameters 18 | #define Params 19 | #define useParams 20 | 21 | #if (PARAMS_KAPPA_BYTES > 16) 22 | #define RATE SHAKE256_RATE 23 | #else 24 | #define RATE SHAKE128_RATE 25 | #endif 26 | 27 | #define DeclareParameters 28 | 29 | #else 30 | 31 | #include "parameters.h" 32 | 33 | #define Parameters , const parameters * params 34 | #define Params , params 35 | #define useParams params = params ; 36 | 37 | #define DeclareParameters\ 38 | parameters * params; \ 39 | if ((params = set_parameters_from_api()) == NULL) \ 40 | exit(EXIT_FAILURE) 41 | 42 | 43 | #define RATE (params->kappa_bytes > 16 ? SHAKE256_RATE : SHAKE128_RATE ) 44 | #define PARAMS_B_BITS (params->b_bits) 45 | #define PARAMS_T_BITS (params->t_bits) 46 | #define PARAMS_P_BITS (params->p_bits) 47 | #define PARAMS_Q_BITS (params->q_bits) 48 | #define PARAMS_CT_SIZE (params->ct_size) 49 | #define PARAMS_PK_SIZE (params->pk_size) 50 | #define PARAMS_D (params->d) 51 | #define PARAMS_Q (params->q) 52 | #define PARAMS_H (params->h) 53 | #define PARAMS_H1 (params->h1) 54 | #define PARAMS_H2 (params->h2) 55 | #define PARAMS_H3 (params->h3) 56 | #define PARAMS_F (params->f) 57 | #define PARAMS_K (params->k) 58 | #define PARAMS_N (params->n) 59 | #define PARAMS_N_BAR (params->n_bar) 60 | #define PARAMS_M (params->m) 61 | #define PARAMS_MU (params->mu) 62 | #define PARAMS_M_BAR (params->m_bar) 63 | #define PARAMS_P (params->p) 64 | #define PARAMS_TAU (params->tau) 65 | #define PARAMS_TAU2_LEN (params->tau2_len) 66 | #define PARAMS_KAPPA (params->kappa) 67 | #define PARAMS_KAPPA_BYTES (params->kappa_bytes) 68 | #define PARAMS_CT_SIZE (params->ct_size) 69 | #define PARAMS_XE (params->xe) 70 | 71 | #endif 72 | 73 | -------------------------------------------------------------------------------- /crypto/wrapper/pkg/darwin_amd64/include/round5/keccakf1600.h: -------------------------------------------------------------------------------- 1 | #ifndef _KECCAKF1600_H_ 2 | #define _KECCAKF1600_H_ 3 | 4 | // Importing, build upon: 5 | #include 6 | #include 7 | 8 | #ifdef AVX2 9 | #include 10 | #endif 11 | 12 | #include "chooseparameters.h" 13 | 14 | // Reduction of public domain sources. 15 | 16 | void KeccakF1600_StateExtractBytes ( uint64_t *state, uint8_t *data Parameters ); 17 | 18 | void KeccakF1600_StateXORBytes ( uint64_t *state, const uint8_t *data Parameters ); 19 | 20 | void KeccakF1600_StatePermute( uint64_t *state ); 21 | 22 | #ifdef AVX2 23 | void KeccakF1600_StateExtractBytes_4x(__m256i *state, 24 | uint8_t *data0, 25 | uint8_t *data1, 26 | uint8_t *data2, 27 | uint8_t *data3 28 | Parameters ); 29 | 30 | void KeccakF1600_StateXORBytes_4x (__m256i *state, 31 | const uint8_t *data0, 32 | const uint8_t *data1, 33 | const uint8_t *data2, 34 | const uint8_t *data3 35 | Parameters ); 36 | #endif 37 | 38 | #endif /* _KECCAKF1600_H_ */ 39 | 40 | 41 | -------------------------------------------------------------------------------- /crypto/wrapper/pkg/darwin_amd64/include/round5/matmul.h: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 2020, Koninklijke Philips N.V. 3 | */ 4 | 5 | #ifndef _MATMUL_H_ 6 | #define _MATMUL_H_ 7 | 8 | #include "r5_parameter_sets.h" 9 | 10 | #if PARAMS_K != 1 11 | 12 | //#if !defined(CM_CT) || !defined(CM_CACHE) 13 | //void create_secret_matrix_s_t(tern_secret_s secret_vector, const uint8_t *seed); 14 | //void create_secret_matrix_r_t(tern_secret_r secret_vector, const uint8_t *seed); 15 | //#endif 16 | 17 | #if PARAMS_TAU == 0 18 | void matmul_as_q(modq_t d[PARAMS_D][PARAMS_N_BAR], modq_t a[PARAMS_D][PARAMS_D], tern_secret_s secret_vector); 19 | void matmul_rta_q(modq_t d[PARAMS_M_BAR][PARAMS_D], modq_t a[PARAMS_D][PARAMS_D], tern_secret_r secret_vector); 20 | #elif PARAMS_TAU == 1 21 | void matmul_as_q(modq_t d[PARAMS_D][PARAMS_N_BAR], modq_t a[2 * PARAMS_D * PARAMS_D], uint32_t a_permutation[PARAMS_D], tern_secret_s secret_vector); 22 | void matmul_rta_q(modq_t d[PARAMS_M_BAR][PARAMS_D], modq_t a[2 * PARAMS_D * PARAMS_D], uint32_t a_permutation[PARAMS_D], tern_secret_r secret_vector); 23 | #else 24 | void matmul_as_q(modq_t d[PARAMS_D][PARAMS_N_BAR], modq_t a[PARAMS_TAU2_LEN + PARAMS_D], uint16_t a_permutation[PARAMS_D], tern_secret_s secret_vector); 25 | void matmul_rta_q(modq_t d[PARAMS_M_BAR][PARAMS_D], modq_t a[PARAMS_TAU2_LEN + PARAMS_D], uint16_t a_permutation[PARAMS_D], tern_secret_r secret_vector); 26 | #endif 27 | 28 | void matmul_stu_p(modp_t d[PARAMS_MU], modp_t u_t[PARAMS_M_BAR][PARAMS_D], tern_secret_s secret_vector); 29 | 30 | void matmul_btr_p(modp_t d[PARAMS_MU], modp_t b[PARAMS_D][PARAMS_N_BAR], tern_secret_r secret_vector); 31 | 32 | #endif /* PARAMS_K != 1 */ 33 | 34 | #endif /* _MATMUL_H_ */ 35 | -------------------------------------------------------------------------------- /crypto/wrapper/pkg/darwin_amd64/include/round5/pack.h: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 2020, Koninklijke Philips N.V. 3 | */ 4 | 5 | #include 6 | #include "r5_parameter_sets.h" 7 | 8 | void pack_qp(uint8_t *pv, const modq_t *vq, const modq_t rounding_constant, size_t num_coeff, size_t size); 9 | void unpack_p(modp_t *vp, const uint8_t *pv, size_t num_coeff); 10 | 11 | 12 | -------------------------------------------------------------------------------- /crypto/wrapper/pkg/darwin_amd64/include/round5/r5_cca_kem.h: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 2018, PQShield and Koninklijke Philips N.V. 3 | * Markku-Juhani O. Saarinen, Koninklijke Philips N.V. 4 | */ 5 | 6 | #ifndef R5_CCA_KEM_H 7 | #define R5_CCA_KEM_H 8 | 9 | #ifdef __cplusplus 10 | extern "C" { 11 | #endif 12 | 13 | /** 14 | * Generates a CCA KEM key pair. Uses the parameters as specified. 15 | * 16 | * @param[out] pk public key 17 | * @param[out] sk secret key 18 | * @return __0__ in case of success 19 | */ 20 | int r5_cca_kem_keygen(unsigned char *pk, unsigned char *sk); 21 | 22 | /** 23 | * CCA KEM encapsulate. Uses the parameters as specified. 24 | * 25 | * @param[out] ct key encapsulation message (important: the size of `ct` is `ct_size` + `kappa_bytes`!) 26 | * @param[out] k shared secret 27 | * @param[in] pk public key with which the message is encapsulated 28 | * @return __0__ in case of success 29 | */ 30 | int r5_cca_kem_encapsulate(unsigned char *ct, unsigned char *k, const unsigned char *pk); 31 | 32 | /** 33 | * CCA KEM de-capsulate. Uses the parameters as specified. 34 | * 35 | * @param[out] k shared secret 36 | * @param[in] ct key encapsulation message (important: the size of `ct` is `ct_size` + `kappa_bytes`!) 37 | * @param[in] sk secret key with which the message is to be de-capsulated (important: the size of `sk` is `sk_size` + `kappa_bytes` + `pk_size`!) 38 | * @return __0__ in case of success 39 | */ 40 | int r5_cca_kem_decapsulate(unsigned char *k, const unsigned char *ct, const unsigned char *sk); 41 | 42 | #ifdef __cplusplus 43 | } 44 | #endif 45 | 46 | #endif /* R5_CCA_KEM_H */ 47 | -------------------------------------------------------------------------------- /crypto/wrapper/pkg/darwin_amd64/include/round5/r5_cca_pke.h: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 2018, Koninklijke Philips N.V. 3 | */ 4 | 5 | /** 6 | * @file 7 | * Declaration of the encrypt and decrypt functions based on the CCA KEM 8 | * algorithm. 9 | */ 10 | 11 | #ifndef _R5_CCA_PKE_H_ 12 | #define _R5_CCA_PKE_H_ 13 | 14 | #ifdef __cplusplus 15 | extern "C" { 16 | #endif 17 | 18 | /** 19 | * Generates an ENCRYPT key pair. Uses the parameters as specified. 20 | * 21 | * @param[out] pk public key 22 | * @param[out] sk secret key (important: the size of `sk` is `sk_size` + `kappa_bytes` + `pk_size`!) 23 | * @return __0__ in case of success 24 | */ 25 | int r5_cca_pke_keygen(unsigned char *pk, unsigned char *sk); 26 | 27 | /** 28 | * Encrypts a message. Uses the parameters as specified. 29 | * 30 | * @param[out] ct the encrypted message 31 | * @param[out] ct_len the length of the encrypted message (`mlen` + `ct_size` + `kappa_bytes` + 16) 32 | * @param[in] m the message to encrypt 33 | * @param[in] m_len the length of the message to encrypt 34 | * @param[in] pk the public key to use for the encryption 35 | * @return __0__ in case of success 36 | */ 37 | int r5_cca_pke_encrypt(unsigned char *ct, unsigned long long *ct_len, const unsigned char *m, const unsigned long long m_len, const unsigned char *pk); 38 | 39 | /** 40 | * Decrypts a message. Uses the parameters as specified. 41 | * 42 | * @param[out] m the decrypted message 43 | * @param[out] m_len the length of the decrypted message (`ct_len` - `ct_size` - `kappa_bytes` - 16) 44 | * @param[in] ct the message to decrypt 45 | * @param[in] ct_len the length of the message to decrypt 46 | * @param[in] sk the secret key to use for the decryption 47 | * @return __0__ in case of success 48 | */ 49 | int r5_cca_pke_decrypt(unsigned char *m, unsigned long long *m_len, const unsigned char *ct, const unsigned long long ct_len, const unsigned char *sk); 50 | 51 | #ifdef __cplusplus 52 | } 53 | #endif 54 | 55 | #endif /* _R5_CCA_PKE_H_ */ 56 | -------------------------------------------------------------------------------- /crypto/wrapper/pkg/darwin_amd64/include/round5/r5_cpa_kem.h: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 2018, Koninklijke Philips N.V. 3 | */ 4 | 5 | /** 6 | * @file 7 | * Declaration of the CPA KEM functions. 8 | */ 9 | 10 | #ifndef R5_CPA_KEM_H 11 | #define R5_CPA_KEM_H 12 | 13 | #ifdef __cplusplus 14 | extern "C" { 15 | #endif 16 | 17 | /** 18 | * Generates a CPA KEM key pair. Uses the parameters as specified. 19 | * 20 | * @param[out] pk public key 21 | * @param[out] sk secret key 22 | * @return __0__ in case of success 23 | */ 24 | int r5_cpa_kem_keygen(unsigned char *pk, unsigned char *sk); 25 | 26 | /** 27 | * CPA KEM encapsulate. Uses the parameters as specified. 28 | * 29 | * @param[out] ct key encapsulation message 30 | * @param[out] k shared secret 31 | * @return __0__ in case of success 32 | */ 33 | int r5_cpa_kem_encapsulate(unsigned char *ct, unsigned char *k, const unsigned char *pk); 34 | 35 | /** 36 | * CPA KEM de-capsulate. Uses the parameters as specified. 37 | * 38 | * @param[out] k shared secret 39 | * @param[in] ct key encapsulation message 40 | * @param[in] sk secret key with which the message is to be de-capsulated 41 | * @return __0__ in case of success 42 | */ 43 | int r5_cpa_kem_decapsulate(unsigned char *k, const unsigned char *ct, const unsigned char *sk); 44 | 45 | #ifdef __cplusplus 46 | } 47 | #endif 48 | 49 | #endif /* R5_CPA_KEM_H */ 50 | -------------------------------------------------------------------------------- /crypto/wrapper/pkg/darwin_amd64/include/round5/r5_cpa_pke.h: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 2018, PQShield and Koninklijke Philips N.V. 3 | * Markku-Juhani O. Saarinen, Koninklijke Philips N.V. 4 | */ 5 | 6 | #ifndef _R5_CPA_PKE_H_ 7 | #define _R5_CPA_PKE_H_ 8 | 9 | #include 10 | 11 | int r5_cpa_pke_keygen(uint8_t *pk, uint8_t *sk); 12 | 13 | int r5_cpa_pke_encrypt(uint8_t *ct, const uint8_t *pk, const uint8_t *m, const uint8_t *rho); 14 | 15 | int r5_cpa_pke_decrypt(uint8_t *m, const uint8_t *sk, const uint8_t *ct); 16 | 17 | #endif /* _R5_CPA_PKE_H_ */ 18 | -------------------------------------------------------------------------------- /crypto/wrapper/pkg/darwin_amd64/include/round5/r5_dem.h: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 2018, Koninklijke Philips N.V. 3 | */ 4 | 5 | /** 6 | * @file 7 | * Declaration of the DEM functions used by the Round5 CCA KEM-based encrypt algorithm. 8 | */ 9 | 10 | #ifndef PST_DEM_H 11 | #define PST_DEM_H 12 | 13 | #include 14 | 15 | #ifdef __cplusplus 16 | extern "C" { 17 | #endif 18 | 19 | /** 20 | * Applies a DEM to the given message using the specified key. 21 | * 22 | * @param[out] c2 the encapsulated message 23 | * @param[out] c2_len the length of the encapsulated message (`m_len` + 16 bytes) 24 | * @param[in] key the key to use for the encapsulation 25 | * @param[in] m the message to encapsulate 26 | * @param[in] m_len the length of the message 27 | * @return __0__ in case of success 28 | */ 29 | int round5_dem(unsigned char *c2, unsigned long long *c2_len, const unsigned char *key, const unsigned char *m, const unsigned long long m_len); 30 | 31 | /** 32 | * Inverses the application of a DEM to a message. 33 | * 34 | * @param[out] m the original message 35 | * @param[out] m_len the length of the decapsulated message (`c2_len` - 16) 36 | * @param[in] key the key to use for the encapsulation 37 | * @param[in] c2 the encapsulated message 38 | * @param[in] c2_len the length of the encapsulated message 39 | * @return __0__ in case of success 40 | */ 41 | int round5_dem_inverse(unsigned char *m, unsigned long long *m_len, const unsigned char *key, const unsigned char *c2, const unsigned long long c2_len); 42 | 43 | #ifdef __cplusplus 44 | } 45 | #endif 46 | 47 | #endif /* PST_DEM_H */ 48 | -------------------------------------------------------------------------------- /crypto/wrapper/pkg/darwin_amd64/include/round5/r5_hash.h: -------------------------------------------------------------------------------- 1 | #ifndef _R5_HASH_H_ 2 | #define _R5_HASH_H_ 3 | 4 | /* 5 | * Copyright (c) 2020, Koninklijke Philips N.V. 6 | */ 7 | 8 | /** 9 | * @file 10 | * Definition of the hash function as used within Round5. 11 | */ 12 | 13 | #include "f202sp800185.h" 14 | 15 | #ifdef __cplusplus 16 | extern "C" { 17 | #endif 18 | 19 | extern void HCPAKEM 20 | ( uint8_t *output, uint32_t outputLength, 21 | const uint8_t *firstInput, uint16_t firstInputLength, 22 | const uint8_t *secondInput, uint32_t secondInputLength 23 | Parameters ); 24 | 25 | extern void HCCAKEM 26 | ( uint8_t *output, uint32_t outputLength, 27 | const uint8_t *firstInput, uint16_t firstInputLength, 28 | const uint8_t *secondInput, uint32_t secondInputLength 29 | Parameters ); 30 | 31 | extern void GCCAKEM 32 | ( uint8_t *output, uint32_t outputLength, 33 | const uint8_t *firstInput, uint16_t firstInputLength, 34 | const uint8_t *secondInput, uint32_t secondInputLength 35 | Parameters ); 36 | 37 | extern void HashR5DEM 38 | ( uint8_t *output, uint32_t outputLength, 39 | const uint8_t *firstInput, uint16_t firstInputLength 40 | Parameters ); 41 | 42 | #ifdef __cplusplus 43 | } 44 | #endif 45 | 46 | #endif /* _R5_HASH_H_ */ 47 | -------------------------------------------------------------------------------- /crypto/wrapper/pkg/darwin_amd64/include/round5/r5_secretkeygen.h: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 2020, PQShield and Koninklijke Philips N.V. 3 | * Markku-Juhani O. Saarinen, Koninklijke Philips N.V. 4 | */ 5 | 6 | #ifndef secretkeygen_h 7 | #define secretkeygen_h 8 | 9 | #include "r5_parameter_sets.h" 10 | 11 | void create_secret_vector_s(tern_secret secret_vector, const uint8_t *seed); 12 | void create_secret_vector_r(tern_secret secret_vector, const uint8_t *seed); 13 | void create_secret_matrix_s_t(tern_secret_s secret_vector, const uint8_t *seed); 14 | void create_secret_matrix_r_t(tern_secret_r secret_vector, const uint8_t *seed); 15 | 16 | #endif /* secretkeygen_h */ 17 | 18 | -------------------------------------------------------------------------------- /crypto/wrapper/pkg/darwin_amd64/include/round5/ringmul.h: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 2018, PQShield and Koninklijke Philips N.V. 3 | * Markku-Juhani O. Saarinen, Koninklijke Philips N.V. 4 | */ 5 | 6 | #ifndef _RINGMUL_H_ 7 | #define _RINGMUL_H_ 8 | 9 | #include "r5_parameter_sets.h" 10 | 11 | #if PARAMS_K == 1 12 | 13 | // multiplication mod q, result length n 14 | void ringmul_q(modq_t d[PARAMS_N], modq_t a[PARAMS_N], tern_secret idx); 15 | 16 | // multiplication mod p, result length mu 17 | void ringmul_p(modp_t d[PARAMS_MU], modp_t a[PARAMS_N], tern_secret idx); 18 | 19 | #endif 20 | 21 | #endif /* _RINGMUL_H_ */ 22 | -------------------------------------------------------------------------------- /crypto/wrapper/pkg/darwin_amd64/include/round5/rng.h: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 2018, Koninklijke Philips N.V. 3 | */ 4 | 5 | /** 6 | * @file 7 | * Declaration of the random bytes functions. 8 | */ 9 | 10 | #ifndef RNG_H 11 | #define RNG_H 12 | 13 | #ifdef __cplusplus 14 | extern "C" { 15 | #endif 16 | 17 | // /** 18 | // * Initializes the random number generator used for generating the random 19 | // * bytes. 20 | // * 21 | // * @param[in] entropy_input the bytes to use as input entropy (48 bytes) 22 | // * @param[in] personalization_string an optional personalization string (48 bytes) 23 | // * @param[in] security_strength parameter to specify the security strength of the random bytes 24 | // */ 25 | void randombytes_init(unsigned char *entropy_input, unsigned char *personalization_string, int security_strength); 26 | 27 | /** 28 | * Generates a sequence of random bytes. 29 | * 30 | * @param[out] x destination of the random bytes 31 | * @param[in] xlen the number of random bytes 32 | * @return _0_ in case of success, non-zero otherwise 33 | */ 34 | int randombytes(unsigned char *x, unsigned long long xlen); 35 | 36 | #ifdef __cplusplus 37 | } 38 | #endif 39 | 40 | #endif /* RNG_H */ 41 | -------------------------------------------------------------------------------- /crypto/wrapper/pkg/darwin_amd64/include/round5/xef.h: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 2018, PQShield 3 | * Markku-Juhani O. Saarinen 4 | */ 5 | 6 | // Generic prototypes for error correction code 7 | 8 | #ifndef _XEF_H_ 9 | #define _XEF_H_ 10 | 11 | #include 12 | #include 13 | 14 | // Parametrized versions. f = 0..5, number of errors fixed 15 | 16 | // Computes the parity code, XORs it at the end of payload 17 | // len = payload (bytes). Returns (payload | xef) length in *bits*. 18 | size_t xef_compute(void *block, size_t len, unsigned f); 19 | 20 | // Fixes errors based on parity code. Call xef_compute() first to get delta. 21 | // len = payload (bytes). Returns (payload | xef) length in *bits*. 22 | size_t xef_fixerr(void *block, size_t len, unsigned f); 23 | 24 | 25 | // specific code from optimized implementations 26 | 27 | void xe2_53_compute(void *block); // xe2_c16.c 28 | void xe2_53_fixerr(void *block); 29 | 30 | void xe4_163_compute(void *block); // xe4_c64.c 31 | void xe4_163_fixerr(void *block); 32 | 33 | void xe5_190_compute(void *block); // xe5_c64.c 34 | void xe5_190_fixerr(void *block); 35 | void xe5_218_compute(void *block); 36 | void xe5_218_fixerr(void *block); 37 | void xe5_234_compute(void *block); 38 | void xe5_234_fixerr(void *block); 39 | 40 | #endif /* _XEF_H_ */ 41 | -------------------------------------------------------------------------------- /crypto/wrapper/pkg/darwin_amd64/include/virgil/crypto/phe/UOKMSModels.pb.h: -------------------------------------------------------------------------------- 1 | /* Automatically generated nanopb header */ 2 | /* Generated by nanopb-0.3.9.4 at Wed May 13 03:05:36 2020. */ 3 | 4 | #ifndef PB_UOKMSMODELS_PB_H_INCLUDED 5 | #define PB_UOKMSMODELS_PB_H_INCLUDED 6 | #include 7 | 8 | /* @@protoc_insertion_point(includes) */ 9 | #if PB_PROTO_HEADER_VERSION != 30 10 | #error Regenerate this file with the current version of nanopb generator. 11 | #endif 12 | 13 | #ifdef __cplusplus 14 | extern "C" { 15 | #endif 16 | 17 | /* Struct definitions */ 18 | typedef struct _UOKMSProofOfSuccess { 19 | pb_byte_t term1[65]; 20 | pb_byte_t term2[65]; 21 | pb_byte_t blind_x[32]; 22 | /* @@protoc_insertion_point(struct:UOKMSProofOfSuccess) */ 23 | } UOKMSProofOfSuccess; 24 | 25 | typedef struct _DecryptResponse { 26 | pb_byte_t v[65]; 27 | UOKMSProofOfSuccess proof; 28 | /* @@protoc_insertion_point(struct:DecryptResponse) */ 29 | } DecryptResponse; 30 | 31 | /* Default values for struct fields */ 32 | 33 | /* Initializer values for message structs */ 34 | #define UOKMSProofOfSuccess_init_default {{0}, {0}, {0}} 35 | #define DecryptResponse_init_default {{0}, UOKMSProofOfSuccess_init_default} 36 | #define UOKMSProofOfSuccess_init_zero {{0}, {0}, {0}} 37 | #define DecryptResponse_init_zero {{0}, UOKMSProofOfSuccess_init_zero} 38 | 39 | /* Field tags (for use in manual encoding/decoding) */ 40 | #define UOKMSProofOfSuccess_term1_tag 1 41 | #define UOKMSProofOfSuccess_term2_tag 2 42 | #define UOKMSProofOfSuccess_blind_x_tag 3 43 | #define DecryptResponse_v_tag 1 44 | #define DecryptResponse_proof_tag 2 45 | 46 | /* Struct field encoding specification for nanopb */ 47 | extern const pb_field_t UOKMSProofOfSuccess_fields[4]; 48 | extern const pb_field_t DecryptResponse_fields[3]; 49 | 50 | /* Maximum encoded size of messages (where known) */ 51 | #define UOKMSProofOfSuccess_size 168 52 | #define DecryptResponse_size 238 53 | 54 | /* Message IDs (where set with "msgid" option) */ 55 | #ifdef PB_MSGID 56 | 57 | #define UOKMSMODELS_MESSAGES \ 58 | 59 | 60 | #endif 61 | 62 | #ifdef __cplusplus 63 | } /* extern "C" */ 64 | #endif 65 | /* @@protoc_insertion_point(eof) */ 66 | 67 | #endif 68 | -------------------------------------------------------------------------------- /crypto/wrapper/pkg/darwin_amd64/lib/libed25519.a: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/VirgilSecurity/virgil-sdk-go/296d175bd33a209f8b4faa42042173dd4dd63648/crypto/wrapper/pkg/darwin_amd64/lib/libed25519.a -------------------------------------------------------------------------------- /crypto/wrapper/pkg/darwin_amd64/lib/libfalcon.a: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/VirgilSecurity/virgil-sdk-go/296d175bd33a209f8b4faa42042173dd4dd63648/crypto/wrapper/pkg/darwin_amd64/lib/libfalcon.a -------------------------------------------------------------------------------- /crypto/wrapper/pkg/darwin_amd64/lib/libmbedcrypto.a: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/VirgilSecurity/virgil-sdk-go/296d175bd33a209f8b4faa42042173dd4dd63648/crypto/wrapper/pkg/darwin_amd64/lib/libmbedcrypto.a -------------------------------------------------------------------------------- /crypto/wrapper/pkg/darwin_amd64/lib/libprotobuf-nanopb.a: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/VirgilSecurity/virgil-sdk-go/296d175bd33a209f8b4faa42042173dd4dd63648/crypto/wrapper/pkg/darwin_amd64/lib/libprotobuf-nanopb.a -------------------------------------------------------------------------------- /crypto/wrapper/pkg/darwin_amd64/lib/libround5.a: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/VirgilSecurity/virgil-sdk-go/296d175bd33a209f8b4faa42042173dd4dd63648/crypto/wrapper/pkg/darwin_amd64/lib/libround5.a -------------------------------------------------------------------------------- /crypto/wrapper/pkg/darwin_amd64/lib/libvsc_common.a: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/VirgilSecurity/virgil-sdk-go/296d175bd33a209f8b4faa42042173dd4dd63648/crypto/wrapper/pkg/darwin_amd64/lib/libvsc_common.a -------------------------------------------------------------------------------- /crypto/wrapper/pkg/darwin_amd64/lib/libvsc_foundation.a: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/VirgilSecurity/virgil-sdk-go/296d175bd33a209f8b4faa42042173dd4dd63648/crypto/wrapper/pkg/darwin_amd64/lib/libvsc_foundation.a -------------------------------------------------------------------------------- /crypto/wrapper/pkg/darwin_amd64/lib/libvsc_foundation_pb.a: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/VirgilSecurity/virgil-sdk-go/296d175bd33a209f8b4faa42042173dd4dd63648/crypto/wrapper/pkg/darwin_amd64/lib/libvsc_foundation_pb.a -------------------------------------------------------------------------------- /crypto/wrapper/pkg/darwin_amd64/lib/libvsc_phe.a: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/VirgilSecurity/virgil-sdk-go/296d175bd33a209f8b4faa42042173dd4dd63648/crypto/wrapper/pkg/darwin_amd64/lib/libvsc_phe.a -------------------------------------------------------------------------------- /crypto/wrapper/pkg/darwin_amd64/lib/libvsc_phe_pb.a: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/VirgilSecurity/virgil-sdk-go/296d175bd33a209f8b4faa42042173dd4dd63648/crypto/wrapper/pkg/darwin_amd64/lib/libvsc_phe_pb.a -------------------------------------------------------------------------------- /crypto/wrapper/pkg/linux_amd64/include/mbedtls/fake_alt.h: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/VirgilSecurity/virgil-sdk-go/296d175bd33a209f8b4faa42042173dd4dd63648/crypto/wrapper/pkg/linux_amd64/include/mbedtls/fake_alt.h -------------------------------------------------------------------------------- /crypto/wrapper/pkg/linux_amd64/include/mbedtls/havege.h: -------------------------------------------------------------------------------- 1 | /** 2 | * \file havege.h 3 | * 4 | * \brief HAVEGE: HArdware Volatile Entropy Gathering and Expansion 5 | */ 6 | /* 7 | * Copyright (C) 2006-2015, ARM Limited, All Rights Reserved 8 | * SPDX-License-Identifier: Apache-2.0 9 | * 10 | * Licensed under the Apache License, Version 2.0 (the "License"); you may 11 | * not use this file except in compliance with the License. 12 | * You may obtain a copy of the License at 13 | * 14 | * http://www.apache.org/licenses/LICENSE-2.0 15 | * 16 | * Unless required by applicable law or agreed to in writing, software 17 | * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT 18 | * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 19 | * See the License for the specific language governing permissions and 20 | * limitations under the License. 21 | * 22 | * This file is part of mbed TLS (https://tls.mbed.org) 23 | */ 24 | #ifndef MBEDTLS_HAVEGE_H 25 | #define MBEDTLS_HAVEGE_H 26 | 27 | #include 28 | 29 | #define MBEDTLS_HAVEGE_COLLECT_SIZE 1024 30 | 31 | #ifdef __cplusplus 32 | extern "C" { 33 | #endif 34 | 35 | /** 36 | * \brief HAVEGE state structure 37 | */ 38 | typedef struct mbedtls_havege_state 39 | { 40 | int PT1, PT2, offset[2]; 41 | int pool[MBEDTLS_HAVEGE_COLLECT_SIZE]; 42 | int WALK[8192]; 43 | } 44 | mbedtls_havege_state; 45 | 46 | /** 47 | * \brief HAVEGE initialization 48 | * 49 | * \param hs HAVEGE state to be initialized 50 | */ 51 | void mbedtls_havege_init( mbedtls_havege_state *hs ); 52 | 53 | /** 54 | * \brief Clear HAVEGE state 55 | * 56 | * \param hs HAVEGE state to be cleared 57 | */ 58 | void mbedtls_havege_free( mbedtls_havege_state *hs ); 59 | 60 | /** 61 | * \brief HAVEGE rand function 62 | * 63 | * \param p_rng A HAVEGE state 64 | * \param output Buffer to fill 65 | * \param len Length of buffer 66 | * 67 | * \return 0 68 | */ 69 | int mbedtls_havege_random( void *p_rng, unsigned char *output, size_t len ); 70 | 71 | #ifdef __cplusplus 72 | } 73 | #endif 74 | 75 | #endif /* havege.h */ 76 | -------------------------------------------------------------------------------- /crypto/wrapper/pkg/linux_amd64/include/mbedtls/net.h: -------------------------------------------------------------------------------- 1 | /** 2 | * \file net.h 3 | * 4 | * \brief Deprecated header file that includes net_sockets.h 5 | * 6 | * \deprecated Superseded by mbedtls/net_sockets.h 7 | */ 8 | /* 9 | * Copyright (C) 2006-2016, ARM Limited, All Rights Reserved 10 | * SPDX-License-Identifier: Apache-2.0 11 | * 12 | * Licensed under the Apache License, Version 2.0 (the "License"); you may 13 | * not use this file except in compliance with the License. 14 | * You may obtain a copy of the License at 15 | * 16 | * http://www.apache.org/licenses/LICENSE-2.0 17 | * 18 | * Unless required by applicable law or agreed to in writing, software 19 | * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT 20 | * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 21 | * See the License for the specific language governing permissions and 22 | * limitations under the License. 23 | * 24 | * This file is part of mbed TLS (https://tls.mbed.org) 25 | */ 26 | 27 | #if !defined(MBEDTLS_DEPRECATED_REMOVED) 28 | #include "net_sockets.h" 29 | #if defined(MBEDTLS_DEPRECATED_WARNING) 30 | #warning "Deprecated header file: Superseded by mbedtls/net_sockets.h" 31 | #endif /* MBEDTLS_DEPRECATED_WARNING */ 32 | #endif /* !MBEDTLS_DEPRECATED_REMOVED */ 33 | -------------------------------------------------------------------------------- /crypto/wrapper/pkg/linux_amd64/include/pb_common.h: -------------------------------------------------------------------------------- 1 | /* pb_common.h: Common support functions for pb_encode.c and pb_decode.c. 2 | * These functions are rarely needed by applications directly. 3 | */ 4 | 5 | #ifndef PB_COMMON_H_INCLUDED 6 | #define PB_COMMON_H_INCLUDED 7 | 8 | #include "pb.h" 9 | 10 | #ifdef __cplusplus 11 | extern "C" { 12 | #endif 13 | 14 | /* Iterator for pb_field_t list */ 15 | struct pb_field_iter_s { 16 | const pb_field_t *start; /* Start of the pb_field_t array */ 17 | const pb_field_t *pos; /* Current position of the iterator */ 18 | unsigned required_field_index; /* Zero-based index that counts only the required fields */ 19 | void *dest_struct; /* Pointer to start of the structure */ 20 | void *pData; /* Pointer to current field value */ 21 | void *pSize; /* Pointer to count/has field */ 22 | }; 23 | typedef struct pb_field_iter_s pb_field_iter_t; 24 | 25 | /* Initialize the field iterator structure to beginning. 26 | * Returns false if the message type is empty. */ 27 | bool pb_field_iter_begin(pb_field_iter_t *iter, const pb_field_t *fields, void *dest_struct); 28 | 29 | /* Advance the iterator to the next field. 30 | * Returns false when the iterator wraps back to the first field. */ 31 | bool pb_field_iter_next(pb_field_iter_t *iter); 32 | 33 | /* Advance the iterator until it points at a field with the given tag. 34 | * Returns false if no such field exists. */ 35 | bool pb_field_iter_find(pb_field_iter_t *iter, uint32_t tag); 36 | 37 | #ifdef __cplusplus 38 | } /* extern "C" */ 39 | #endif 40 | 41 | #endif 42 | 43 | -------------------------------------------------------------------------------- /crypto/wrapper/pkg/linux_amd64/include/round5/a_fixed.h: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 2018, Koninklijke Philips N.V. 3 | */ 4 | 5 | /** 6 | * @file 7 | * Declaration of the fixed A matrix as well as the function to generate it. 8 | */ 9 | 10 | #ifndef A_FIXED_H 11 | #define A_FIXED_H 12 | 13 | #include "r5_parameter_sets.h" 14 | 15 | #if PARAMS_TAU == 1 16 | /** 17 | * The fixed A matrix for use inside with the non-ring algorithm when τ=1. 18 | * This matrix is generated by `create_A_fixed()`. 19 | */ 20 | extern modq_t A_fixed[PARAMS_D * 2 * PARAMS_K]; 21 | #endif 22 | 23 | #ifdef __cplusplus 24 | extern "C" { 25 | #endif 26 | 27 | /** 28 | * Function to generate a fixed A matrix from the given seed and algorithm parameters. 29 | * 30 | * @param[in] seed the seed to use to generate the fixed A matrix (KAPPA_BYTES bytes) 31 | * @return __0__ in case of success 32 | */ 33 | int create_A_fixed(const unsigned char *seed); 34 | 35 | #ifdef __cplusplus 36 | } 37 | #endif 38 | 39 | #endif /* A_FIXED_H */ 40 | -------------------------------------------------------------------------------- /crypto/wrapper/pkg/linux_amd64/include/round5/a_random.h: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 2018, Koninklijke Philips N.V. 3 | */ 4 | 5 | /** 6 | * @file 7 | * Declaration of the random A matrix creation function. 8 | */ 9 | 10 | #ifndef A_RANDOM_H 11 | #define A_RANDOM_H 12 | 13 | #include "r5_parameter_sets.h" 14 | 15 | #ifdef __cplusplus 16 | extern "C" { 17 | #endif 18 | 19 | /** 20 | * Creates A random for the given seed and algorithm parameters. 21 | * 22 | * @param[out] A_random the random A to create 23 | * @param[in] seed the seed (PARAMS_KAPPA_BYTES bytes) 24 | */ 25 | void create_A_random(modq_t *A_random, const unsigned char *seed); 26 | 27 | #ifdef __cplusplus 28 | } 29 | #endif 30 | 31 | #endif /* A_RANDOM_H */ 32 | -------------------------------------------------------------------------------- /crypto/wrapper/pkg/linux_amd64/include/round5/checkPublicParameter.h: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 2020, Koninklijke Philips N.V. 3 | */ 4 | 5 | 6 | //#ifndef checkPublicParameter_h 7 | //#define checkPublicParameter_h 8 | 9 | #include "r5_parameter_sets.h" 10 | 11 | #ifdef CM_MALFORMED 12 | int checkPublicParameter(modp_t *public_param, uint16_t num_vectors); 13 | #endif 14 | 15 | 16 | //#endif /* checkPublicParameter_h */ 17 | -------------------------------------------------------------------------------- /crypto/wrapper/pkg/linux_amd64/include/round5/chooseparameters.h: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 2020, Koninklijke Philips N.V. 3 | */ 4 | 5 | #define PARAMETERCONSTANT 6 | 7 | #define SHAKE128_RATE 168 8 | // 168 bytes as a bytesequence = 1344 bits as a bitsequence 9 | 10 | #define SHAKE256_RATE 136 11 | // 136 bytes as a bytesequence = 1088 bits as a bitsequence 12 | 13 | #ifdef PARAMETERCONSTANT 14 | 15 | #include "r5_parameter_sets.h" 16 | 17 | #define Parameters 18 | #define Params 19 | #define useParams 20 | 21 | #if (PARAMS_KAPPA_BYTES > 16) 22 | #define RATE SHAKE256_RATE 23 | #else 24 | #define RATE SHAKE128_RATE 25 | #endif 26 | 27 | #define DeclareParameters 28 | 29 | #else 30 | 31 | #include "parameters.h" 32 | 33 | #define Parameters , const parameters * params 34 | #define Params , params 35 | #define useParams params = params ; 36 | 37 | #define DeclareParameters\ 38 | parameters * params; \ 39 | if ((params = set_parameters_from_api()) == NULL) \ 40 | exit(EXIT_FAILURE) 41 | 42 | 43 | #define RATE (params->kappa_bytes > 16 ? SHAKE256_RATE : SHAKE128_RATE ) 44 | #define PARAMS_B_BITS (params->b_bits) 45 | #define PARAMS_T_BITS (params->t_bits) 46 | #define PARAMS_P_BITS (params->p_bits) 47 | #define PARAMS_Q_BITS (params->q_bits) 48 | #define PARAMS_CT_SIZE (params->ct_size) 49 | #define PARAMS_PK_SIZE (params->pk_size) 50 | #define PARAMS_D (params->d) 51 | #define PARAMS_Q (params->q) 52 | #define PARAMS_H (params->h) 53 | #define PARAMS_H1 (params->h1) 54 | #define PARAMS_H2 (params->h2) 55 | #define PARAMS_H3 (params->h3) 56 | #define PARAMS_F (params->f) 57 | #define PARAMS_K (params->k) 58 | #define PARAMS_N (params->n) 59 | #define PARAMS_N_BAR (params->n_bar) 60 | #define PARAMS_M (params->m) 61 | #define PARAMS_MU (params->mu) 62 | #define PARAMS_M_BAR (params->m_bar) 63 | #define PARAMS_P (params->p) 64 | #define PARAMS_TAU (params->tau) 65 | #define PARAMS_TAU2_LEN (params->tau2_len) 66 | #define PARAMS_KAPPA (params->kappa) 67 | #define PARAMS_KAPPA_BYTES (params->kappa_bytes) 68 | #define PARAMS_CT_SIZE (params->ct_size) 69 | #define PARAMS_XE (params->xe) 70 | 71 | #endif 72 | 73 | -------------------------------------------------------------------------------- /crypto/wrapper/pkg/linux_amd64/include/round5/keccakf1600.h: -------------------------------------------------------------------------------- 1 | #ifndef _KECCAKF1600_H_ 2 | #define _KECCAKF1600_H_ 3 | 4 | // Importing, build upon: 5 | #include 6 | #include 7 | 8 | #ifdef AVX2 9 | #include 10 | #endif 11 | 12 | #include "chooseparameters.h" 13 | 14 | // Reduction of public domain sources. 15 | 16 | void KeccakF1600_StateExtractBytes ( uint64_t *state, uint8_t *data Parameters ); 17 | 18 | void KeccakF1600_StateXORBytes ( uint64_t *state, const uint8_t *data Parameters ); 19 | 20 | void KeccakF1600_StatePermute( uint64_t *state ); 21 | 22 | #ifdef AVX2 23 | void KeccakF1600_StateExtractBytes_4x(__m256i *state, 24 | uint8_t *data0, 25 | uint8_t *data1, 26 | uint8_t *data2, 27 | uint8_t *data3 28 | Parameters ); 29 | 30 | void KeccakF1600_StateXORBytes_4x (__m256i *state, 31 | const uint8_t *data0, 32 | const uint8_t *data1, 33 | const uint8_t *data2, 34 | const uint8_t *data3 35 | Parameters ); 36 | #endif 37 | 38 | #endif /* _KECCAKF1600_H_ */ 39 | 40 | 41 | -------------------------------------------------------------------------------- /crypto/wrapper/pkg/linux_amd64/include/round5/matmul.h: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 2020, Koninklijke Philips N.V. 3 | */ 4 | 5 | #ifndef _MATMUL_H_ 6 | #define _MATMUL_H_ 7 | 8 | #include "r5_parameter_sets.h" 9 | 10 | #if PARAMS_K != 1 11 | 12 | //#if !defined(CM_CT) || !defined(CM_CACHE) 13 | //void create_secret_matrix_s_t(tern_secret_s secret_vector, const uint8_t *seed); 14 | //void create_secret_matrix_r_t(tern_secret_r secret_vector, const uint8_t *seed); 15 | //#endif 16 | 17 | #if PARAMS_TAU == 0 18 | void matmul_as_q(modq_t d[PARAMS_D][PARAMS_N_BAR], modq_t a[PARAMS_D][PARAMS_D], tern_secret_s secret_vector); 19 | void matmul_rta_q(modq_t d[PARAMS_M_BAR][PARAMS_D], modq_t a[PARAMS_D][PARAMS_D], tern_secret_r secret_vector); 20 | #elif PARAMS_TAU == 1 21 | void matmul_as_q(modq_t d[PARAMS_D][PARAMS_N_BAR], modq_t a[2 * PARAMS_D * PARAMS_D], uint32_t a_permutation[PARAMS_D], tern_secret_s secret_vector); 22 | void matmul_rta_q(modq_t d[PARAMS_M_BAR][PARAMS_D], modq_t a[2 * PARAMS_D * PARAMS_D], uint32_t a_permutation[PARAMS_D], tern_secret_r secret_vector); 23 | #else 24 | void matmul_as_q(modq_t d[PARAMS_D][PARAMS_N_BAR], modq_t a[PARAMS_TAU2_LEN + PARAMS_D], uint16_t a_permutation[PARAMS_D], tern_secret_s secret_vector); 25 | void matmul_rta_q(modq_t d[PARAMS_M_BAR][PARAMS_D], modq_t a[PARAMS_TAU2_LEN + PARAMS_D], uint16_t a_permutation[PARAMS_D], tern_secret_r secret_vector); 26 | #endif 27 | 28 | void matmul_stu_p(modp_t d[PARAMS_MU], modp_t u_t[PARAMS_M_BAR][PARAMS_D], tern_secret_s secret_vector); 29 | 30 | void matmul_btr_p(modp_t d[PARAMS_MU], modp_t b[PARAMS_D][PARAMS_N_BAR], tern_secret_r secret_vector); 31 | 32 | #endif /* PARAMS_K != 1 */ 33 | 34 | #endif /* _MATMUL_H_ */ 35 | -------------------------------------------------------------------------------- /crypto/wrapper/pkg/linux_amd64/include/round5/pack.h: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 2020, Koninklijke Philips N.V. 3 | */ 4 | 5 | #include 6 | #include "r5_parameter_sets.h" 7 | 8 | void pack_qp(uint8_t *pv, const modq_t *vq, const modq_t rounding_constant, size_t num_coeff, size_t size); 9 | void unpack_p(modp_t *vp, const uint8_t *pv, size_t num_coeff); 10 | 11 | 12 | -------------------------------------------------------------------------------- /crypto/wrapper/pkg/linux_amd64/include/round5/r5_cca_kem.h: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 2018, PQShield and Koninklijke Philips N.V. 3 | * Markku-Juhani O. Saarinen, Koninklijke Philips N.V. 4 | */ 5 | 6 | #ifndef R5_CCA_KEM_H 7 | #define R5_CCA_KEM_H 8 | 9 | #ifdef __cplusplus 10 | extern "C" { 11 | #endif 12 | 13 | /** 14 | * Generates a CCA KEM key pair. Uses the parameters as specified. 15 | * 16 | * @param[out] pk public key 17 | * @param[out] sk secret key 18 | * @return __0__ in case of success 19 | */ 20 | int r5_cca_kem_keygen(unsigned char *pk, unsigned char *sk); 21 | 22 | /** 23 | * CCA KEM encapsulate. Uses the parameters as specified. 24 | * 25 | * @param[out] ct key encapsulation message (important: the size of `ct` is `ct_size` + `kappa_bytes`!) 26 | * @param[out] k shared secret 27 | * @param[in] pk public key with which the message is encapsulated 28 | * @return __0__ in case of success 29 | */ 30 | int r5_cca_kem_encapsulate(unsigned char *ct, unsigned char *k, const unsigned char *pk); 31 | 32 | /** 33 | * CCA KEM de-capsulate. Uses the parameters as specified. 34 | * 35 | * @param[out] k shared secret 36 | * @param[in] ct key encapsulation message (important: the size of `ct` is `ct_size` + `kappa_bytes`!) 37 | * @param[in] sk secret key with which the message is to be de-capsulated (important: the size of `sk` is `sk_size` + `kappa_bytes` + `pk_size`!) 38 | * @return __0__ in case of success 39 | */ 40 | int r5_cca_kem_decapsulate(unsigned char *k, const unsigned char *ct, const unsigned char *sk); 41 | 42 | #ifdef __cplusplus 43 | } 44 | #endif 45 | 46 | #endif /* R5_CCA_KEM_H */ 47 | -------------------------------------------------------------------------------- /crypto/wrapper/pkg/linux_amd64/include/round5/r5_cca_pke.h: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 2018, Koninklijke Philips N.V. 3 | */ 4 | 5 | /** 6 | * @file 7 | * Declaration of the encrypt and decrypt functions based on the CCA KEM 8 | * algorithm. 9 | */ 10 | 11 | #ifndef _R5_CCA_PKE_H_ 12 | #define _R5_CCA_PKE_H_ 13 | 14 | #ifdef __cplusplus 15 | extern "C" { 16 | #endif 17 | 18 | /** 19 | * Generates an ENCRYPT key pair. Uses the parameters as specified. 20 | * 21 | * @param[out] pk public key 22 | * @param[out] sk secret key (important: the size of `sk` is `sk_size` + `kappa_bytes` + `pk_size`!) 23 | * @return __0__ in case of success 24 | */ 25 | int r5_cca_pke_keygen(unsigned char *pk, unsigned char *sk); 26 | 27 | /** 28 | * Encrypts a message. Uses the parameters as specified. 29 | * 30 | * @param[out] ct the encrypted message 31 | * @param[out] ct_len the length of the encrypted message (`mlen` + `ct_size` + `kappa_bytes` + 16) 32 | * @param[in] m the message to encrypt 33 | * @param[in] m_len the length of the message to encrypt 34 | * @param[in] pk the public key to use for the encryption 35 | * @return __0__ in case of success 36 | */ 37 | int r5_cca_pke_encrypt(unsigned char *ct, unsigned long long *ct_len, const unsigned char *m, const unsigned long long m_len, const unsigned char *pk); 38 | 39 | /** 40 | * Decrypts a message. Uses the parameters as specified. 41 | * 42 | * @param[out] m the decrypted message 43 | * @param[out] m_len the length of the decrypted message (`ct_len` - `ct_size` - `kappa_bytes` - 16) 44 | * @param[in] ct the message to decrypt 45 | * @param[in] ct_len the length of the message to decrypt 46 | * @param[in] sk the secret key to use for the decryption 47 | * @return __0__ in case of success 48 | */ 49 | int r5_cca_pke_decrypt(unsigned char *m, unsigned long long *m_len, const unsigned char *ct, const unsigned long long ct_len, const unsigned char *sk); 50 | 51 | #ifdef __cplusplus 52 | } 53 | #endif 54 | 55 | #endif /* _R5_CCA_PKE_H_ */ 56 | -------------------------------------------------------------------------------- /crypto/wrapper/pkg/linux_amd64/include/round5/r5_cpa_kem.h: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 2018, Koninklijke Philips N.V. 3 | */ 4 | 5 | /** 6 | * @file 7 | * Declaration of the CPA KEM functions. 8 | */ 9 | 10 | #ifndef R5_CPA_KEM_H 11 | #define R5_CPA_KEM_H 12 | 13 | #ifdef __cplusplus 14 | extern "C" { 15 | #endif 16 | 17 | /** 18 | * Generates a CPA KEM key pair. Uses the parameters as specified. 19 | * 20 | * @param[out] pk public key 21 | * @param[out] sk secret key 22 | * @return __0__ in case of success 23 | */ 24 | int r5_cpa_kem_keygen(unsigned char *pk, unsigned char *sk); 25 | 26 | /** 27 | * CPA KEM encapsulate. Uses the parameters as specified. 28 | * 29 | * @param[out] ct key encapsulation message 30 | * @param[out] k shared secret 31 | * @return __0__ in case of success 32 | */ 33 | int r5_cpa_kem_encapsulate(unsigned char *ct, unsigned char *k, const unsigned char *pk); 34 | 35 | /** 36 | * CPA KEM de-capsulate. Uses the parameters as specified. 37 | * 38 | * @param[out] k shared secret 39 | * @param[in] ct key encapsulation message 40 | * @param[in] sk secret key with which the message is to be de-capsulated 41 | * @return __0__ in case of success 42 | */ 43 | int r5_cpa_kem_decapsulate(unsigned char *k, const unsigned char *ct, const unsigned char *sk); 44 | 45 | #ifdef __cplusplus 46 | } 47 | #endif 48 | 49 | #endif /* R5_CPA_KEM_H */ 50 | -------------------------------------------------------------------------------- /crypto/wrapper/pkg/linux_amd64/include/round5/r5_cpa_pke.h: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 2018, PQShield and Koninklijke Philips N.V. 3 | * Markku-Juhani O. Saarinen, Koninklijke Philips N.V. 4 | */ 5 | 6 | #ifndef _R5_CPA_PKE_H_ 7 | #define _R5_CPA_PKE_H_ 8 | 9 | #include 10 | 11 | int r5_cpa_pke_keygen(uint8_t *pk, uint8_t *sk); 12 | 13 | int r5_cpa_pke_encrypt(uint8_t *ct, const uint8_t *pk, const uint8_t *m, const uint8_t *rho); 14 | 15 | int r5_cpa_pke_decrypt(uint8_t *m, const uint8_t *sk, const uint8_t *ct); 16 | 17 | #endif /* _R5_CPA_PKE_H_ */ 18 | -------------------------------------------------------------------------------- /crypto/wrapper/pkg/linux_amd64/include/round5/r5_dem.h: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 2018, Koninklijke Philips N.V. 3 | */ 4 | 5 | /** 6 | * @file 7 | * Declaration of the DEM functions used by the Round5 CCA KEM-based encrypt algorithm. 8 | */ 9 | 10 | #ifndef PST_DEM_H 11 | #define PST_DEM_H 12 | 13 | #include 14 | 15 | #ifdef __cplusplus 16 | extern "C" { 17 | #endif 18 | 19 | /** 20 | * Applies a DEM to the given message using the specified key. 21 | * 22 | * @param[out] c2 the encapsulated message 23 | * @param[out] c2_len the length of the encapsulated message (`m_len` + 16 bytes) 24 | * @param[in] key the key to use for the encapsulation 25 | * @param[in] m the message to encapsulate 26 | * @param[in] m_len the length of the message 27 | * @return __0__ in case of success 28 | */ 29 | int round5_dem(unsigned char *c2, unsigned long long *c2_len, const unsigned char *key, const unsigned char *m, const unsigned long long m_len); 30 | 31 | /** 32 | * Inverses the application of a DEM to a message. 33 | * 34 | * @param[out] m the original message 35 | * @param[out] m_len the length of the decapsulated message (`c2_len` - 16) 36 | * @param[in] key the key to use for the encapsulation 37 | * @param[in] c2 the encapsulated message 38 | * @param[in] c2_len the length of the encapsulated message 39 | * @return __0__ in case of success 40 | */ 41 | int round5_dem_inverse(unsigned char *m, unsigned long long *m_len, const unsigned char *key, const unsigned char *c2, const unsigned long long c2_len); 42 | 43 | #ifdef __cplusplus 44 | } 45 | #endif 46 | 47 | #endif /* PST_DEM_H */ 48 | -------------------------------------------------------------------------------- /crypto/wrapper/pkg/linux_amd64/include/round5/r5_hash.h: -------------------------------------------------------------------------------- 1 | #ifndef _R5_HASH_H_ 2 | #define _R5_HASH_H_ 3 | 4 | /* 5 | * Copyright (c) 2020, Koninklijke Philips N.V. 6 | */ 7 | 8 | /** 9 | * @file 10 | * Definition of the hash function as used within Round5. 11 | */ 12 | 13 | #include "f202sp800185.h" 14 | 15 | #ifdef __cplusplus 16 | extern "C" { 17 | #endif 18 | 19 | extern void HCPAKEM 20 | ( uint8_t *output, uint32_t outputLength, 21 | const uint8_t *firstInput, uint16_t firstInputLength, 22 | const uint8_t *secondInput, uint32_t secondInputLength 23 | Parameters ); 24 | 25 | extern void HCCAKEM 26 | ( uint8_t *output, uint32_t outputLength, 27 | const uint8_t *firstInput, uint16_t firstInputLength, 28 | const uint8_t *secondInput, uint32_t secondInputLength 29 | Parameters ); 30 | 31 | extern void GCCAKEM 32 | ( uint8_t *output, uint32_t outputLength, 33 | const uint8_t *firstInput, uint16_t firstInputLength, 34 | const uint8_t *secondInput, uint32_t secondInputLength 35 | Parameters ); 36 | 37 | extern void HashR5DEM 38 | ( uint8_t *output, uint32_t outputLength, 39 | const uint8_t *firstInput, uint16_t firstInputLength 40 | Parameters ); 41 | 42 | #ifdef __cplusplus 43 | } 44 | #endif 45 | 46 | #endif /* _R5_HASH_H_ */ 47 | -------------------------------------------------------------------------------- /crypto/wrapper/pkg/linux_amd64/include/round5/r5_secretkeygen.h: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 2020, PQShield and Koninklijke Philips N.V. 3 | * Markku-Juhani O. Saarinen, Koninklijke Philips N.V. 4 | */ 5 | 6 | #ifndef secretkeygen_h 7 | #define secretkeygen_h 8 | 9 | #include "r5_parameter_sets.h" 10 | 11 | void create_secret_vector_s(tern_secret secret_vector, const uint8_t *seed); 12 | void create_secret_vector_r(tern_secret secret_vector, const uint8_t *seed); 13 | void create_secret_matrix_s_t(tern_secret_s secret_vector, const uint8_t *seed); 14 | void create_secret_matrix_r_t(tern_secret_r secret_vector, const uint8_t *seed); 15 | 16 | #endif /* secretkeygen_h */ 17 | 18 | -------------------------------------------------------------------------------- /crypto/wrapper/pkg/linux_amd64/include/round5/ringmul.h: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 2018, PQShield and Koninklijke Philips N.V. 3 | * Markku-Juhani O. Saarinen, Koninklijke Philips N.V. 4 | */ 5 | 6 | #ifndef _RINGMUL_H_ 7 | #define _RINGMUL_H_ 8 | 9 | #include "r5_parameter_sets.h" 10 | 11 | #if PARAMS_K == 1 12 | 13 | // multiplication mod q, result length n 14 | void ringmul_q(modq_t d[PARAMS_N], modq_t a[PARAMS_N], tern_secret idx); 15 | 16 | // multiplication mod p, result length mu 17 | void ringmul_p(modp_t d[PARAMS_MU], modp_t a[PARAMS_N], tern_secret idx); 18 | 19 | #endif 20 | 21 | #endif /* _RINGMUL_H_ */ 22 | -------------------------------------------------------------------------------- /crypto/wrapper/pkg/linux_amd64/include/round5/rng.h: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 2018, Koninklijke Philips N.V. 3 | */ 4 | 5 | /** 6 | * @file 7 | * Declaration of the random bytes functions. 8 | */ 9 | 10 | #ifndef RNG_H 11 | #define RNG_H 12 | 13 | #ifdef __cplusplus 14 | extern "C" { 15 | #endif 16 | 17 | // /** 18 | // * Initializes the random number generator used for generating the random 19 | // * bytes. 20 | // * 21 | // * @param[in] entropy_input the bytes to use as input entropy (48 bytes) 22 | // * @param[in] personalization_string an optional personalization string (48 bytes) 23 | // * @param[in] security_strength parameter to specify the security strength of the random bytes 24 | // */ 25 | void randombytes_init(unsigned char *entropy_input, unsigned char *personalization_string, int security_strength); 26 | 27 | /** 28 | * Generates a sequence of random bytes. 29 | * 30 | * @param[out] x destination of the random bytes 31 | * @param[in] xlen the number of random bytes 32 | * @return _0_ in case of success, non-zero otherwise 33 | */ 34 | int randombytes(unsigned char *x, unsigned long long xlen); 35 | 36 | #ifdef __cplusplus 37 | } 38 | #endif 39 | 40 | #endif /* RNG_H */ 41 | -------------------------------------------------------------------------------- /crypto/wrapper/pkg/linux_amd64/include/round5/xef.h: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 2018, PQShield 3 | * Markku-Juhani O. Saarinen 4 | */ 5 | 6 | // Generic prototypes for error correction code 7 | 8 | #ifndef _XEF_H_ 9 | #define _XEF_H_ 10 | 11 | #include 12 | #include 13 | 14 | // Parametrized versions. f = 0..5, number of errors fixed 15 | 16 | // Computes the parity code, XORs it at the end of payload 17 | // len = payload (bytes). Returns (payload | xef) length in *bits*. 18 | size_t xef_compute(void *block, size_t len, unsigned f); 19 | 20 | // Fixes errors based on parity code. Call xef_compute() first to get delta. 21 | // len = payload (bytes). Returns (payload | xef) length in *bits*. 22 | size_t xef_fixerr(void *block, size_t len, unsigned f); 23 | 24 | 25 | // specific code from optimized implementations 26 | 27 | void xe2_53_compute(void *block); // xe2_c16.c 28 | void xe2_53_fixerr(void *block); 29 | 30 | void xe4_163_compute(void *block); // xe4_c64.c 31 | void xe4_163_fixerr(void *block); 32 | 33 | void xe5_190_compute(void *block); // xe5_c64.c 34 | void xe5_190_fixerr(void *block); 35 | void xe5_218_compute(void *block); 36 | void xe5_218_fixerr(void *block); 37 | void xe5_234_compute(void *block); 38 | void xe5_234_fixerr(void *block); 39 | 40 | #endif /* _XEF_H_ */ 41 | -------------------------------------------------------------------------------- /crypto/wrapper/pkg/linux_amd64/include/virgil/crypto/phe/UOKMSModels.pb.h: -------------------------------------------------------------------------------- 1 | /* Automatically generated nanopb header */ 2 | /* Generated by nanopb-0.3.9.4 at Wed May 13 09:41:36 2020. */ 3 | 4 | #ifndef PB_UOKMSMODELS_PB_H_INCLUDED 5 | #define PB_UOKMSMODELS_PB_H_INCLUDED 6 | #include 7 | 8 | /* @@protoc_insertion_point(includes) */ 9 | #if PB_PROTO_HEADER_VERSION != 30 10 | #error Regenerate this file with the current version of nanopb generator. 11 | #endif 12 | 13 | #ifdef __cplusplus 14 | extern "C" { 15 | #endif 16 | 17 | /* Struct definitions */ 18 | typedef struct _UOKMSProofOfSuccess { 19 | pb_byte_t term1[65]; 20 | pb_byte_t term2[65]; 21 | pb_byte_t blind_x[32]; 22 | /* @@protoc_insertion_point(struct:UOKMSProofOfSuccess) */ 23 | } UOKMSProofOfSuccess; 24 | 25 | typedef struct _DecryptResponse { 26 | pb_byte_t v[65]; 27 | UOKMSProofOfSuccess proof; 28 | /* @@protoc_insertion_point(struct:DecryptResponse) */ 29 | } DecryptResponse; 30 | 31 | /* Default values for struct fields */ 32 | 33 | /* Initializer values for message structs */ 34 | #define UOKMSProofOfSuccess_init_default {{0}, {0}, {0}} 35 | #define DecryptResponse_init_default {{0}, UOKMSProofOfSuccess_init_default} 36 | #define UOKMSProofOfSuccess_init_zero {{0}, {0}, {0}} 37 | #define DecryptResponse_init_zero {{0}, UOKMSProofOfSuccess_init_zero} 38 | 39 | /* Field tags (for use in manual encoding/decoding) */ 40 | #define UOKMSProofOfSuccess_term1_tag 1 41 | #define UOKMSProofOfSuccess_term2_tag 2 42 | #define UOKMSProofOfSuccess_blind_x_tag 3 43 | #define DecryptResponse_v_tag 1 44 | #define DecryptResponse_proof_tag 2 45 | 46 | /* Struct field encoding specification for nanopb */ 47 | extern const pb_field_t UOKMSProofOfSuccess_fields[4]; 48 | extern const pb_field_t DecryptResponse_fields[3]; 49 | 50 | /* Maximum encoded size of messages (where known) */ 51 | #define UOKMSProofOfSuccess_size 168 52 | #define DecryptResponse_size 238 53 | 54 | /* Message IDs (where set with "msgid" option) */ 55 | #ifdef PB_MSGID 56 | 57 | #define UOKMSMODELS_MESSAGES \ 58 | 59 | 60 | #endif 61 | 62 | #ifdef __cplusplus 63 | } /* extern "C" */ 64 | #endif 65 | /* @@protoc_insertion_point(eof) */ 66 | 67 | #endif 68 | -------------------------------------------------------------------------------- /crypto/wrapper/pkg/linux_amd64/lib/libed25519.a: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/VirgilSecurity/virgil-sdk-go/296d175bd33a209f8b4faa42042173dd4dd63648/crypto/wrapper/pkg/linux_amd64/lib/libed25519.a -------------------------------------------------------------------------------- /crypto/wrapper/pkg/linux_amd64/lib/libfalcon.a: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/VirgilSecurity/virgil-sdk-go/296d175bd33a209f8b4faa42042173dd4dd63648/crypto/wrapper/pkg/linux_amd64/lib/libfalcon.a -------------------------------------------------------------------------------- /crypto/wrapper/pkg/linux_amd64/lib/libmbedcrypto.a: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/VirgilSecurity/virgil-sdk-go/296d175bd33a209f8b4faa42042173dd4dd63648/crypto/wrapper/pkg/linux_amd64/lib/libmbedcrypto.a -------------------------------------------------------------------------------- /crypto/wrapper/pkg/linux_amd64/lib/libprotobuf-nanopb.a: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/VirgilSecurity/virgil-sdk-go/296d175bd33a209f8b4faa42042173dd4dd63648/crypto/wrapper/pkg/linux_amd64/lib/libprotobuf-nanopb.a -------------------------------------------------------------------------------- /crypto/wrapper/pkg/linux_amd64/lib/libround5.a: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/VirgilSecurity/virgil-sdk-go/296d175bd33a209f8b4faa42042173dd4dd63648/crypto/wrapper/pkg/linux_amd64/lib/libround5.a -------------------------------------------------------------------------------- /crypto/wrapper/pkg/linux_amd64/lib/libvsc_common.a: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/VirgilSecurity/virgil-sdk-go/296d175bd33a209f8b4faa42042173dd4dd63648/crypto/wrapper/pkg/linux_amd64/lib/libvsc_common.a -------------------------------------------------------------------------------- /crypto/wrapper/pkg/linux_amd64/lib/libvsc_foundation.a: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/VirgilSecurity/virgil-sdk-go/296d175bd33a209f8b4faa42042173dd4dd63648/crypto/wrapper/pkg/linux_amd64/lib/libvsc_foundation.a -------------------------------------------------------------------------------- /crypto/wrapper/pkg/linux_amd64/lib/libvsc_foundation_pb.a: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/VirgilSecurity/virgil-sdk-go/296d175bd33a209f8b4faa42042173dd4dd63648/crypto/wrapper/pkg/linux_amd64/lib/libvsc_foundation_pb.a -------------------------------------------------------------------------------- /crypto/wrapper/pkg/linux_amd64/lib/libvsc_phe.a: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/VirgilSecurity/virgil-sdk-go/296d175bd33a209f8b4faa42042173dd4dd63648/crypto/wrapper/pkg/linux_amd64/lib/libvsc_phe.a -------------------------------------------------------------------------------- /crypto/wrapper/pkg/linux_amd64/lib/libvsc_phe_pb.a: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/VirgilSecurity/virgil-sdk-go/296d175bd33a209f8b4faa42042173dd4dd63648/crypto/wrapper/pkg/linux_amd64/lib/libvsc_phe_pb.a -------------------------------------------------------------------------------- /crypto/wrapper/pkg/linux_amd64__legacy_os/include/mbedtls/fake_alt.h: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/VirgilSecurity/virgil-sdk-go/296d175bd33a209f8b4faa42042173dd4dd63648/crypto/wrapper/pkg/linux_amd64__legacy_os/include/mbedtls/fake_alt.h -------------------------------------------------------------------------------- /crypto/wrapper/pkg/linux_amd64__legacy_os/include/mbedtls/havege.h: -------------------------------------------------------------------------------- 1 | /** 2 | * \file havege.h 3 | * 4 | * \brief HAVEGE: HArdware Volatile Entropy Gathering and Expansion 5 | */ 6 | /* 7 | * Copyright (C) 2006-2015, ARM Limited, All Rights Reserved 8 | * SPDX-License-Identifier: Apache-2.0 9 | * 10 | * Licensed under the Apache License, Version 2.0 (the "License"); you may 11 | * not use this file except in compliance with the License. 12 | * You may obtain a copy of the License at 13 | * 14 | * http://www.apache.org/licenses/LICENSE-2.0 15 | * 16 | * Unless required by applicable law or agreed to in writing, software 17 | * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT 18 | * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 19 | * See the License for the specific language governing permissions and 20 | * limitations under the License. 21 | * 22 | * This file is part of mbed TLS (https://tls.mbed.org) 23 | */ 24 | #ifndef MBEDTLS_HAVEGE_H 25 | #define MBEDTLS_HAVEGE_H 26 | 27 | #include 28 | 29 | #define MBEDTLS_HAVEGE_COLLECT_SIZE 1024 30 | 31 | #ifdef __cplusplus 32 | extern "C" { 33 | #endif 34 | 35 | /** 36 | * \brief HAVEGE state structure 37 | */ 38 | typedef struct mbedtls_havege_state 39 | { 40 | int PT1, PT2, offset[2]; 41 | int pool[MBEDTLS_HAVEGE_COLLECT_SIZE]; 42 | int WALK[8192]; 43 | } 44 | mbedtls_havege_state; 45 | 46 | /** 47 | * \brief HAVEGE initialization 48 | * 49 | * \param hs HAVEGE state to be initialized 50 | */ 51 | void mbedtls_havege_init( mbedtls_havege_state *hs ); 52 | 53 | /** 54 | * \brief Clear HAVEGE state 55 | * 56 | * \param hs HAVEGE state to be cleared 57 | */ 58 | void mbedtls_havege_free( mbedtls_havege_state *hs ); 59 | 60 | /** 61 | * \brief HAVEGE rand function 62 | * 63 | * \param p_rng A HAVEGE state 64 | * \param output Buffer to fill 65 | * \param len Length of buffer 66 | * 67 | * \return 0 68 | */ 69 | int mbedtls_havege_random( void *p_rng, unsigned char *output, size_t len ); 70 | 71 | #ifdef __cplusplus 72 | } 73 | #endif 74 | 75 | #endif /* havege.h */ 76 | -------------------------------------------------------------------------------- /crypto/wrapper/pkg/linux_amd64__legacy_os/include/mbedtls/net.h: -------------------------------------------------------------------------------- 1 | /** 2 | * \file net.h 3 | * 4 | * \brief Deprecated header file that includes net_sockets.h 5 | * 6 | * \deprecated Superseded by mbedtls/net_sockets.h 7 | */ 8 | /* 9 | * Copyright (C) 2006-2016, ARM Limited, All Rights Reserved 10 | * SPDX-License-Identifier: Apache-2.0 11 | * 12 | * Licensed under the Apache License, Version 2.0 (the "License"); you may 13 | * not use this file except in compliance with the License. 14 | * You may obtain a copy of the License at 15 | * 16 | * http://www.apache.org/licenses/LICENSE-2.0 17 | * 18 | * Unless required by applicable law or agreed to in writing, software 19 | * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT 20 | * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 21 | * See the License for the specific language governing permissions and 22 | * limitations under the License. 23 | * 24 | * This file is part of mbed TLS (https://tls.mbed.org) 25 | */ 26 | 27 | #if !defined(MBEDTLS_DEPRECATED_REMOVED) 28 | #include "net_sockets.h" 29 | #if defined(MBEDTLS_DEPRECATED_WARNING) 30 | #warning "Deprecated header file: Superseded by mbedtls/net_sockets.h" 31 | #endif /* MBEDTLS_DEPRECATED_WARNING */ 32 | #endif /* !MBEDTLS_DEPRECATED_REMOVED */ 33 | -------------------------------------------------------------------------------- /crypto/wrapper/pkg/linux_amd64__legacy_os/include/pb_common.h: -------------------------------------------------------------------------------- 1 | /* pb_common.h: Common support functions for pb_encode.c and pb_decode.c. 2 | * These functions are rarely needed by applications directly. 3 | */ 4 | 5 | #ifndef PB_COMMON_H_INCLUDED 6 | #define PB_COMMON_H_INCLUDED 7 | 8 | #include "pb.h" 9 | 10 | #ifdef __cplusplus 11 | extern "C" { 12 | #endif 13 | 14 | /* Iterator for pb_field_t list */ 15 | struct pb_field_iter_s { 16 | const pb_field_t *start; /* Start of the pb_field_t array */ 17 | const pb_field_t *pos; /* Current position of the iterator */ 18 | unsigned required_field_index; /* Zero-based index that counts only the required fields */ 19 | void *dest_struct; /* Pointer to start of the structure */ 20 | void *pData; /* Pointer to current field value */ 21 | void *pSize; /* Pointer to count/has field */ 22 | }; 23 | typedef struct pb_field_iter_s pb_field_iter_t; 24 | 25 | /* Initialize the field iterator structure to beginning. 26 | * Returns false if the message type is empty. */ 27 | bool pb_field_iter_begin(pb_field_iter_t *iter, const pb_field_t *fields, void *dest_struct); 28 | 29 | /* Advance the iterator to the next field. 30 | * Returns false when the iterator wraps back to the first field. */ 31 | bool pb_field_iter_next(pb_field_iter_t *iter); 32 | 33 | /* Advance the iterator until it points at a field with the given tag. 34 | * Returns false if no such field exists. */ 35 | bool pb_field_iter_find(pb_field_iter_t *iter, uint32_t tag); 36 | 37 | #ifdef __cplusplus 38 | } /* extern "C" */ 39 | #endif 40 | 41 | #endif 42 | 43 | -------------------------------------------------------------------------------- /crypto/wrapper/pkg/linux_amd64__legacy_os/include/round5/a_fixed.h: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 2018, Koninklijke Philips N.V. 3 | */ 4 | 5 | /** 6 | * @file 7 | * Declaration of the fixed A matrix as well as the function to generate it. 8 | */ 9 | 10 | #ifndef A_FIXED_H 11 | #define A_FIXED_H 12 | 13 | #include "r5_parameter_sets.h" 14 | 15 | #if PARAMS_TAU == 1 16 | /** 17 | * The fixed A matrix for use inside with the non-ring algorithm when τ=1. 18 | * This matrix is generated by `create_A_fixed()`. 19 | */ 20 | extern modq_t A_fixed[PARAMS_D * 2 * PARAMS_K]; 21 | #endif 22 | 23 | #ifdef __cplusplus 24 | extern "C" { 25 | #endif 26 | 27 | /** 28 | * Function to generate a fixed A matrix from the given seed and algorithm parameters. 29 | * 30 | * @param[in] seed the seed to use to generate the fixed A matrix (KAPPA_BYTES bytes) 31 | * @return __0__ in case of success 32 | */ 33 | int create_A_fixed(const unsigned char *seed); 34 | 35 | #ifdef __cplusplus 36 | } 37 | #endif 38 | 39 | #endif /* A_FIXED_H */ 40 | -------------------------------------------------------------------------------- /crypto/wrapper/pkg/linux_amd64__legacy_os/include/round5/a_random.h: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 2018, Koninklijke Philips N.V. 3 | */ 4 | 5 | /** 6 | * @file 7 | * Declaration of the random A matrix creation function. 8 | */ 9 | 10 | #ifndef A_RANDOM_H 11 | #define A_RANDOM_H 12 | 13 | #include "r5_parameter_sets.h" 14 | 15 | #ifdef __cplusplus 16 | extern "C" { 17 | #endif 18 | 19 | /** 20 | * Creates A random for the given seed and algorithm parameters. 21 | * 22 | * @param[out] A_random the random A to create 23 | * @param[in] seed the seed (PARAMS_KAPPA_BYTES bytes) 24 | */ 25 | void create_A_random(modq_t *A_random, const unsigned char *seed); 26 | 27 | #ifdef __cplusplus 28 | } 29 | #endif 30 | 31 | #endif /* A_RANDOM_H */ 32 | -------------------------------------------------------------------------------- /crypto/wrapper/pkg/linux_amd64__legacy_os/include/round5/checkPublicParameter.h: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 2020, Koninklijke Philips N.V. 3 | */ 4 | 5 | 6 | //#ifndef checkPublicParameter_h 7 | //#define checkPublicParameter_h 8 | 9 | #include "r5_parameter_sets.h" 10 | 11 | #ifdef CM_MALFORMED 12 | int checkPublicParameter(modp_t *public_param, uint16_t num_vectors); 13 | #endif 14 | 15 | 16 | //#endif /* checkPublicParameter_h */ 17 | -------------------------------------------------------------------------------- /crypto/wrapper/pkg/linux_amd64__legacy_os/include/round5/chooseparameters.h: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 2020, Koninklijke Philips N.V. 3 | */ 4 | 5 | #define PARAMETERCONSTANT 6 | 7 | #define SHAKE128_RATE 168 8 | // 168 bytes as a bytesequence = 1344 bits as a bitsequence 9 | 10 | #define SHAKE256_RATE 136 11 | // 136 bytes as a bytesequence = 1088 bits as a bitsequence 12 | 13 | #ifdef PARAMETERCONSTANT 14 | 15 | #include "r5_parameter_sets.h" 16 | 17 | #define Parameters 18 | #define Params 19 | #define useParams 20 | 21 | #if (PARAMS_KAPPA_BYTES > 16) 22 | #define RATE SHAKE256_RATE 23 | #else 24 | #define RATE SHAKE128_RATE 25 | #endif 26 | 27 | #define DeclareParameters 28 | 29 | #else 30 | 31 | #include "parameters.h" 32 | 33 | #define Parameters , const parameters * params 34 | #define Params , params 35 | #define useParams params = params ; 36 | 37 | #define DeclareParameters\ 38 | parameters * params; \ 39 | if ((params = set_parameters_from_api()) == NULL) \ 40 | exit(EXIT_FAILURE) 41 | 42 | 43 | #define RATE (params->kappa_bytes > 16 ? SHAKE256_RATE : SHAKE128_RATE ) 44 | #define PARAMS_B_BITS (params->b_bits) 45 | #define PARAMS_T_BITS (params->t_bits) 46 | #define PARAMS_P_BITS (params->p_bits) 47 | #define PARAMS_Q_BITS (params->q_bits) 48 | #define PARAMS_CT_SIZE (params->ct_size) 49 | #define PARAMS_PK_SIZE (params->pk_size) 50 | #define PARAMS_D (params->d) 51 | #define PARAMS_Q (params->q) 52 | #define PARAMS_H (params->h) 53 | #define PARAMS_H1 (params->h1) 54 | #define PARAMS_H2 (params->h2) 55 | #define PARAMS_H3 (params->h3) 56 | #define PARAMS_F (params->f) 57 | #define PARAMS_K (params->k) 58 | #define PARAMS_N (params->n) 59 | #define PARAMS_N_BAR (params->n_bar) 60 | #define PARAMS_M (params->m) 61 | #define PARAMS_MU (params->mu) 62 | #define PARAMS_M_BAR (params->m_bar) 63 | #define PARAMS_P (params->p) 64 | #define PARAMS_TAU (params->tau) 65 | #define PARAMS_TAU2_LEN (params->tau2_len) 66 | #define PARAMS_KAPPA (params->kappa) 67 | #define PARAMS_KAPPA_BYTES (params->kappa_bytes) 68 | #define PARAMS_CT_SIZE (params->ct_size) 69 | #define PARAMS_XE (params->xe) 70 | 71 | #endif 72 | 73 | -------------------------------------------------------------------------------- /crypto/wrapper/pkg/linux_amd64__legacy_os/include/round5/keccakf1600.h: -------------------------------------------------------------------------------- 1 | #ifndef _KECCAKF1600_H_ 2 | #define _KECCAKF1600_H_ 3 | 4 | // Importing, build upon: 5 | #include 6 | #include 7 | 8 | #ifdef AVX2 9 | #include 10 | #endif 11 | 12 | #include "chooseparameters.h" 13 | 14 | // Reduction of public domain sources. 15 | 16 | void KeccakF1600_StateExtractBytes ( uint64_t *state, uint8_t *data Parameters ); 17 | 18 | void KeccakF1600_StateXORBytes ( uint64_t *state, const uint8_t *data Parameters ); 19 | 20 | void KeccakF1600_StatePermute( uint64_t *state ); 21 | 22 | #ifdef AVX2 23 | void KeccakF1600_StateExtractBytes_4x(__m256i *state, 24 | uint8_t *data0, 25 | uint8_t *data1, 26 | uint8_t *data2, 27 | uint8_t *data3 28 | Parameters ); 29 | 30 | void KeccakF1600_StateXORBytes_4x (__m256i *state, 31 | const uint8_t *data0, 32 | const uint8_t *data1, 33 | const uint8_t *data2, 34 | const uint8_t *data3 35 | Parameters ); 36 | #endif 37 | 38 | #endif /* _KECCAKF1600_H_ */ 39 | 40 | 41 | -------------------------------------------------------------------------------- /crypto/wrapper/pkg/linux_amd64__legacy_os/include/round5/matmul.h: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 2020, Koninklijke Philips N.V. 3 | */ 4 | 5 | #ifndef _MATMUL_H_ 6 | #define _MATMUL_H_ 7 | 8 | #include "r5_parameter_sets.h" 9 | 10 | #if PARAMS_K != 1 11 | 12 | //#if !defined(CM_CT) || !defined(CM_CACHE) 13 | //void create_secret_matrix_s_t(tern_secret_s secret_vector, const uint8_t *seed); 14 | //void create_secret_matrix_r_t(tern_secret_r secret_vector, const uint8_t *seed); 15 | //#endif 16 | 17 | #if PARAMS_TAU == 0 18 | void matmul_as_q(modq_t d[PARAMS_D][PARAMS_N_BAR], modq_t a[PARAMS_D][PARAMS_D], tern_secret_s secret_vector); 19 | void matmul_rta_q(modq_t d[PARAMS_M_BAR][PARAMS_D], modq_t a[PARAMS_D][PARAMS_D], tern_secret_r secret_vector); 20 | #elif PARAMS_TAU == 1 21 | void matmul_as_q(modq_t d[PARAMS_D][PARAMS_N_BAR], modq_t a[2 * PARAMS_D * PARAMS_D], uint32_t a_permutation[PARAMS_D], tern_secret_s secret_vector); 22 | void matmul_rta_q(modq_t d[PARAMS_M_BAR][PARAMS_D], modq_t a[2 * PARAMS_D * PARAMS_D], uint32_t a_permutation[PARAMS_D], tern_secret_r secret_vector); 23 | #else 24 | void matmul_as_q(modq_t d[PARAMS_D][PARAMS_N_BAR], modq_t a[PARAMS_TAU2_LEN + PARAMS_D], uint16_t a_permutation[PARAMS_D], tern_secret_s secret_vector); 25 | void matmul_rta_q(modq_t d[PARAMS_M_BAR][PARAMS_D], modq_t a[PARAMS_TAU2_LEN + PARAMS_D], uint16_t a_permutation[PARAMS_D], tern_secret_r secret_vector); 26 | #endif 27 | 28 | void matmul_stu_p(modp_t d[PARAMS_MU], modp_t u_t[PARAMS_M_BAR][PARAMS_D], tern_secret_s secret_vector); 29 | 30 | void matmul_btr_p(modp_t d[PARAMS_MU], modp_t b[PARAMS_D][PARAMS_N_BAR], tern_secret_r secret_vector); 31 | 32 | #endif /* PARAMS_K != 1 */ 33 | 34 | #endif /* _MATMUL_H_ */ 35 | -------------------------------------------------------------------------------- /crypto/wrapper/pkg/linux_amd64__legacy_os/include/round5/pack.h: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 2020, Koninklijke Philips N.V. 3 | */ 4 | 5 | #include 6 | #include "r5_parameter_sets.h" 7 | 8 | void pack_qp(uint8_t *pv, const modq_t *vq, const modq_t rounding_constant, size_t num_coeff, size_t size); 9 | void unpack_p(modp_t *vp, const uint8_t *pv, size_t num_coeff); 10 | 11 | 12 | -------------------------------------------------------------------------------- /crypto/wrapper/pkg/linux_amd64__legacy_os/include/round5/r5_cca_kem.h: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 2018, PQShield and Koninklijke Philips N.V. 3 | * Markku-Juhani O. Saarinen, Koninklijke Philips N.V. 4 | */ 5 | 6 | #ifndef R5_CCA_KEM_H 7 | #define R5_CCA_KEM_H 8 | 9 | #ifdef __cplusplus 10 | extern "C" { 11 | #endif 12 | 13 | /** 14 | * Generates a CCA KEM key pair. Uses the parameters as specified. 15 | * 16 | * @param[out] pk public key 17 | * @param[out] sk secret key 18 | * @return __0__ in case of success 19 | */ 20 | int r5_cca_kem_keygen(unsigned char *pk, unsigned char *sk); 21 | 22 | /** 23 | * CCA KEM encapsulate. Uses the parameters as specified. 24 | * 25 | * @param[out] ct key encapsulation message (important: the size of `ct` is `ct_size` + `kappa_bytes`!) 26 | * @param[out] k shared secret 27 | * @param[in] pk public key with which the message is encapsulated 28 | * @return __0__ in case of success 29 | */ 30 | int r5_cca_kem_encapsulate(unsigned char *ct, unsigned char *k, const unsigned char *pk); 31 | 32 | /** 33 | * CCA KEM de-capsulate. Uses the parameters as specified. 34 | * 35 | * @param[out] k shared secret 36 | * @param[in] ct key encapsulation message (important: the size of `ct` is `ct_size` + `kappa_bytes`!) 37 | * @param[in] sk secret key with which the message is to be de-capsulated (important: the size of `sk` is `sk_size` + `kappa_bytes` + `pk_size`!) 38 | * @return __0__ in case of success 39 | */ 40 | int r5_cca_kem_decapsulate(unsigned char *k, const unsigned char *ct, const unsigned char *sk); 41 | 42 | #ifdef __cplusplus 43 | } 44 | #endif 45 | 46 | #endif /* R5_CCA_KEM_H */ 47 | -------------------------------------------------------------------------------- /crypto/wrapper/pkg/linux_amd64__legacy_os/include/round5/r5_cca_pke.h: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 2018, Koninklijke Philips N.V. 3 | */ 4 | 5 | /** 6 | * @file 7 | * Declaration of the encrypt and decrypt functions based on the CCA KEM 8 | * algorithm. 9 | */ 10 | 11 | #ifndef _R5_CCA_PKE_H_ 12 | #define _R5_CCA_PKE_H_ 13 | 14 | #ifdef __cplusplus 15 | extern "C" { 16 | #endif 17 | 18 | /** 19 | * Generates an ENCRYPT key pair. Uses the parameters as specified. 20 | * 21 | * @param[out] pk public key 22 | * @param[out] sk secret key (important: the size of `sk` is `sk_size` + `kappa_bytes` + `pk_size`!) 23 | * @return __0__ in case of success 24 | */ 25 | int r5_cca_pke_keygen(unsigned char *pk, unsigned char *sk); 26 | 27 | /** 28 | * Encrypts a message. Uses the parameters as specified. 29 | * 30 | * @param[out] ct the encrypted message 31 | * @param[out] ct_len the length of the encrypted message (`mlen` + `ct_size` + `kappa_bytes` + 16) 32 | * @param[in] m the message to encrypt 33 | * @param[in] m_len the length of the message to encrypt 34 | * @param[in] pk the public key to use for the encryption 35 | * @return __0__ in case of success 36 | */ 37 | int r5_cca_pke_encrypt(unsigned char *ct, unsigned long long *ct_len, const unsigned char *m, const unsigned long long m_len, const unsigned char *pk); 38 | 39 | /** 40 | * Decrypts a message. Uses the parameters as specified. 41 | * 42 | * @param[out] m the decrypted message 43 | * @param[out] m_len the length of the decrypted message (`ct_len` - `ct_size` - `kappa_bytes` - 16) 44 | * @param[in] ct the message to decrypt 45 | * @param[in] ct_len the length of the message to decrypt 46 | * @param[in] sk the secret key to use for the decryption 47 | * @return __0__ in case of success 48 | */ 49 | int r5_cca_pke_decrypt(unsigned char *m, unsigned long long *m_len, const unsigned char *ct, const unsigned long long ct_len, const unsigned char *sk); 50 | 51 | #ifdef __cplusplus 52 | } 53 | #endif 54 | 55 | #endif /* _R5_CCA_PKE_H_ */ 56 | -------------------------------------------------------------------------------- /crypto/wrapper/pkg/linux_amd64__legacy_os/include/round5/r5_cpa_kem.h: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 2018, Koninklijke Philips N.V. 3 | */ 4 | 5 | /** 6 | * @file 7 | * Declaration of the CPA KEM functions. 8 | */ 9 | 10 | #ifndef R5_CPA_KEM_H 11 | #define R5_CPA_KEM_H 12 | 13 | #ifdef __cplusplus 14 | extern "C" { 15 | #endif 16 | 17 | /** 18 | * Generates a CPA KEM key pair. Uses the parameters as specified. 19 | * 20 | * @param[out] pk public key 21 | * @param[out] sk secret key 22 | * @return __0__ in case of success 23 | */ 24 | int r5_cpa_kem_keygen(unsigned char *pk, unsigned char *sk); 25 | 26 | /** 27 | * CPA KEM encapsulate. Uses the parameters as specified. 28 | * 29 | * @param[out] ct key encapsulation message 30 | * @param[out] k shared secret 31 | * @return __0__ in case of success 32 | */ 33 | int r5_cpa_kem_encapsulate(unsigned char *ct, unsigned char *k, const unsigned char *pk); 34 | 35 | /** 36 | * CPA KEM de-capsulate. Uses the parameters as specified. 37 | * 38 | * @param[out] k shared secret 39 | * @param[in] ct key encapsulation message 40 | * @param[in] sk secret key with which the message is to be de-capsulated 41 | * @return __0__ in case of success 42 | */ 43 | int r5_cpa_kem_decapsulate(unsigned char *k, const unsigned char *ct, const unsigned char *sk); 44 | 45 | #ifdef __cplusplus 46 | } 47 | #endif 48 | 49 | #endif /* R5_CPA_KEM_H */ 50 | -------------------------------------------------------------------------------- /crypto/wrapper/pkg/linux_amd64__legacy_os/include/round5/r5_cpa_pke.h: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 2018, PQShield and Koninklijke Philips N.V. 3 | * Markku-Juhani O. Saarinen, Koninklijke Philips N.V. 4 | */ 5 | 6 | #ifndef _R5_CPA_PKE_H_ 7 | #define _R5_CPA_PKE_H_ 8 | 9 | #include 10 | 11 | int r5_cpa_pke_keygen(uint8_t *pk, uint8_t *sk); 12 | 13 | int r5_cpa_pke_encrypt(uint8_t *ct, const uint8_t *pk, const uint8_t *m, const uint8_t *rho); 14 | 15 | int r5_cpa_pke_decrypt(uint8_t *m, const uint8_t *sk, const uint8_t *ct); 16 | 17 | #endif /* _R5_CPA_PKE_H_ */ 18 | -------------------------------------------------------------------------------- /crypto/wrapper/pkg/linux_amd64__legacy_os/include/round5/r5_dem.h: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 2018, Koninklijke Philips N.V. 3 | */ 4 | 5 | /** 6 | * @file 7 | * Declaration of the DEM functions used by the Round5 CCA KEM-based encrypt algorithm. 8 | */ 9 | 10 | #ifndef PST_DEM_H 11 | #define PST_DEM_H 12 | 13 | #include 14 | 15 | #ifdef __cplusplus 16 | extern "C" { 17 | #endif 18 | 19 | /** 20 | * Applies a DEM to the given message using the specified key. 21 | * 22 | * @param[out] c2 the encapsulated message 23 | * @param[out] c2_len the length of the encapsulated message (`m_len` + 16 bytes) 24 | * @param[in] key the key to use for the encapsulation 25 | * @param[in] m the message to encapsulate 26 | * @param[in] m_len the length of the message 27 | * @return __0__ in case of success 28 | */ 29 | int round5_dem(unsigned char *c2, unsigned long long *c2_len, const unsigned char *key, const unsigned char *m, const unsigned long long m_len); 30 | 31 | /** 32 | * Inverses the application of a DEM to a message. 33 | * 34 | * @param[out] m the original message 35 | * @param[out] m_len the length of the decapsulated message (`c2_len` - 16) 36 | * @param[in] key the key to use for the encapsulation 37 | * @param[in] c2 the encapsulated message 38 | * @param[in] c2_len the length of the encapsulated message 39 | * @return __0__ in case of success 40 | */ 41 | int round5_dem_inverse(unsigned char *m, unsigned long long *m_len, const unsigned char *key, const unsigned char *c2, const unsigned long long c2_len); 42 | 43 | #ifdef __cplusplus 44 | } 45 | #endif 46 | 47 | #endif /* PST_DEM_H */ 48 | -------------------------------------------------------------------------------- /crypto/wrapper/pkg/linux_amd64__legacy_os/include/round5/r5_hash.h: -------------------------------------------------------------------------------- 1 | #ifndef _R5_HASH_H_ 2 | #define _R5_HASH_H_ 3 | 4 | /* 5 | * Copyright (c) 2020, Koninklijke Philips N.V. 6 | */ 7 | 8 | /** 9 | * @file 10 | * Definition of the hash function as used within Round5. 11 | */ 12 | 13 | #include "f202sp800185.h" 14 | 15 | #ifdef __cplusplus 16 | extern "C" { 17 | #endif 18 | 19 | extern void HCPAKEM 20 | ( uint8_t *output, uint32_t outputLength, 21 | const uint8_t *firstInput, uint16_t firstInputLength, 22 | const uint8_t *secondInput, uint32_t secondInputLength 23 | Parameters ); 24 | 25 | extern void HCCAKEM 26 | ( uint8_t *output, uint32_t outputLength, 27 | const uint8_t *firstInput, uint16_t firstInputLength, 28 | const uint8_t *secondInput, uint32_t secondInputLength 29 | Parameters ); 30 | 31 | extern void GCCAKEM 32 | ( uint8_t *output, uint32_t outputLength, 33 | const uint8_t *firstInput, uint16_t firstInputLength, 34 | const uint8_t *secondInput, uint32_t secondInputLength 35 | Parameters ); 36 | 37 | extern void HashR5DEM 38 | ( uint8_t *output, uint32_t outputLength, 39 | const uint8_t *firstInput, uint16_t firstInputLength 40 | Parameters ); 41 | 42 | #ifdef __cplusplus 43 | } 44 | #endif 45 | 46 | #endif /* _R5_HASH_H_ */ 47 | -------------------------------------------------------------------------------- /crypto/wrapper/pkg/linux_amd64__legacy_os/include/round5/r5_secretkeygen.h: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 2020, PQShield and Koninklijke Philips N.V. 3 | * Markku-Juhani O. Saarinen, Koninklijke Philips N.V. 4 | */ 5 | 6 | #ifndef secretkeygen_h 7 | #define secretkeygen_h 8 | 9 | #include "r5_parameter_sets.h" 10 | 11 | void create_secret_vector_s(tern_secret secret_vector, const uint8_t *seed); 12 | void create_secret_vector_r(tern_secret secret_vector, const uint8_t *seed); 13 | void create_secret_matrix_s_t(tern_secret_s secret_vector, const uint8_t *seed); 14 | void create_secret_matrix_r_t(tern_secret_r secret_vector, const uint8_t *seed); 15 | 16 | #endif /* secretkeygen_h */ 17 | 18 | -------------------------------------------------------------------------------- /crypto/wrapper/pkg/linux_amd64__legacy_os/include/round5/ringmul.h: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 2018, PQShield and Koninklijke Philips N.V. 3 | * Markku-Juhani O. Saarinen, Koninklijke Philips N.V. 4 | */ 5 | 6 | #ifndef _RINGMUL_H_ 7 | #define _RINGMUL_H_ 8 | 9 | #include "r5_parameter_sets.h" 10 | 11 | #if PARAMS_K == 1 12 | 13 | // multiplication mod q, result length n 14 | void ringmul_q(modq_t d[PARAMS_N], modq_t a[PARAMS_N], tern_secret idx); 15 | 16 | // multiplication mod p, result length mu 17 | void ringmul_p(modp_t d[PARAMS_MU], modp_t a[PARAMS_N], tern_secret idx); 18 | 19 | #endif 20 | 21 | #endif /* _RINGMUL_H_ */ 22 | -------------------------------------------------------------------------------- /crypto/wrapper/pkg/linux_amd64__legacy_os/include/round5/rng.h: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 2018, Koninklijke Philips N.V. 3 | */ 4 | 5 | /** 6 | * @file 7 | * Declaration of the random bytes functions. 8 | */ 9 | 10 | #ifndef RNG_H 11 | #define RNG_H 12 | 13 | #ifdef __cplusplus 14 | extern "C" { 15 | #endif 16 | 17 | // /** 18 | // * Initializes the random number generator used for generating the random 19 | // * bytes. 20 | // * 21 | // * @param[in] entropy_input the bytes to use as input entropy (48 bytes) 22 | // * @param[in] personalization_string an optional personalization string (48 bytes) 23 | // * @param[in] security_strength parameter to specify the security strength of the random bytes 24 | // */ 25 | void randombytes_init(unsigned char *entropy_input, unsigned char *personalization_string, int security_strength); 26 | 27 | /** 28 | * Generates a sequence of random bytes. 29 | * 30 | * @param[out] x destination of the random bytes 31 | * @param[in] xlen the number of random bytes 32 | * @return _0_ in case of success, non-zero otherwise 33 | */ 34 | int randombytes(unsigned char *x, unsigned long long xlen); 35 | 36 | #ifdef __cplusplus 37 | } 38 | #endif 39 | 40 | #endif /* RNG_H */ 41 | -------------------------------------------------------------------------------- /crypto/wrapper/pkg/linux_amd64__legacy_os/include/round5/xef.h: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 2018, PQShield 3 | * Markku-Juhani O. Saarinen 4 | */ 5 | 6 | // Generic prototypes for error correction code 7 | 8 | #ifndef _XEF_H_ 9 | #define _XEF_H_ 10 | 11 | #include 12 | #include 13 | 14 | // Parametrized versions. f = 0..5, number of errors fixed 15 | 16 | // Computes the parity code, XORs it at the end of payload 17 | // len = payload (bytes). Returns (payload | xef) length in *bits*. 18 | size_t xef_compute(void *block, size_t len, unsigned f); 19 | 20 | // Fixes errors based on parity code. Call xef_compute() first to get delta. 21 | // len = payload (bytes). Returns (payload | xef) length in *bits*. 22 | size_t xef_fixerr(void *block, size_t len, unsigned f); 23 | 24 | 25 | // specific code from optimized implementations 26 | 27 | void xe2_53_compute(void *block); // xe2_c16.c 28 | void xe2_53_fixerr(void *block); 29 | 30 | void xe4_163_compute(void *block); // xe4_c64.c 31 | void xe4_163_fixerr(void *block); 32 | 33 | void xe5_190_compute(void *block); // xe5_c64.c 34 | void xe5_190_fixerr(void *block); 35 | void xe5_218_compute(void *block); 36 | void xe5_218_fixerr(void *block); 37 | void xe5_234_compute(void *block); 38 | void xe5_234_fixerr(void *block); 39 | 40 | #endif /* _XEF_H_ */ 41 | -------------------------------------------------------------------------------- /crypto/wrapper/pkg/linux_amd64__legacy_os/include/virgil/crypto/phe/UOKMSModels.pb.h: -------------------------------------------------------------------------------- 1 | /* Automatically generated nanopb header */ 2 | /* Generated by nanopb-0.3.9.4 at Wed May 13 09:34:47 2020. */ 3 | 4 | #ifndef PB_UOKMSMODELS_PB_H_INCLUDED 5 | #define PB_UOKMSMODELS_PB_H_INCLUDED 6 | #include 7 | 8 | /* @@protoc_insertion_point(includes) */ 9 | #if PB_PROTO_HEADER_VERSION != 30 10 | #error Regenerate this file with the current version of nanopb generator. 11 | #endif 12 | 13 | #ifdef __cplusplus 14 | extern "C" { 15 | #endif 16 | 17 | /* Struct definitions */ 18 | typedef struct _UOKMSProofOfSuccess { 19 | pb_byte_t term1[65]; 20 | pb_byte_t term2[65]; 21 | pb_byte_t blind_x[32]; 22 | /* @@protoc_insertion_point(struct:UOKMSProofOfSuccess) */ 23 | } UOKMSProofOfSuccess; 24 | 25 | typedef struct _DecryptResponse { 26 | pb_byte_t v[65]; 27 | UOKMSProofOfSuccess proof; 28 | /* @@protoc_insertion_point(struct:DecryptResponse) */ 29 | } DecryptResponse; 30 | 31 | /* Default values for struct fields */ 32 | 33 | /* Initializer values for message structs */ 34 | #define UOKMSProofOfSuccess_init_default {{0}, {0}, {0}} 35 | #define DecryptResponse_init_default {{0}, UOKMSProofOfSuccess_init_default} 36 | #define UOKMSProofOfSuccess_init_zero {{0}, {0}, {0}} 37 | #define DecryptResponse_init_zero {{0}, UOKMSProofOfSuccess_init_zero} 38 | 39 | /* Field tags (for use in manual encoding/decoding) */ 40 | #define UOKMSProofOfSuccess_term1_tag 1 41 | #define UOKMSProofOfSuccess_term2_tag 2 42 | #define UOKMSProofOfSuccess_blind_x_tag 3 43 | #define DecryptResponse_v_tag 1 44 | #define DecryptResponse_proof_tag 2 45 | 46 | /* Struct field encoding specification for nanopb */ 47 | extern const pb_field_t UOKMSProofOfSuccess_fields[4]; 48 | extern const pb_field_t DecryptResponse_fields[3]; 49 | 50 | /* Maximum encoded size of messages (where known) */ 51 | #define UOKMSProofOfSuccess_size 168 52 | #define DecryptResponse_size 238 53 | 54 | /* Message IDs (where set with "msgid" option) */ 55 | #ifdef PB_MSGID 56 | 57 | #define UOKMSMODELS_MESSAGES \ 58 | 59 | 60 | #endif 61 | 62 | #ifdef __cplusplus 63 | } /* extern "C" */ 64 | #endif 65 | /* @@protoc_insertion_point(eof) */ 66 | 67 | #endif 68 | -------------------------------------------------------------------------------- /crypto/wrapper/pkg/linux_amd64__legacy_os/lib/libed25519.a: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/VirgilSecurity/virgil-sdk-go/296d175bd33a209f8b4faa42042173dd4dd63648/crypto/wrapper/pkg/linux_amd64__legacy_os/lib/libed25519.a -------------------------------------------------------------------------------- /crypto/wrapper/pkg/linux_amd64__legacy_os/lib/libfalcon.a: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/VirgilSecurity/virgil-sdk-go/296d175bd33a209f8b4faa42042173dd4dd63648/crypto/wrapper/pkg/linux_amd64__legacy_os/lib/libfalcon.a -------------------------------------------------------------------------------- /crypto/wrapper/pkg/linux_amd64__legacy_os/lib/libmbedcrypto.a: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/VirgilSecurity/virgil-sdk-go/296d175bd33a209f8b4faa42042173dd4dd63648/crypto/wrapper/pkg/linux_amd64__legacy_os/lib/libmbedcrypto.a -------------------------------------------------------------------------------- /crypto/wrapper/pkg/linux_amd64__legacy_os/lib/libprotobuf-nanopb.a: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/VirgilSecurity/virgil-sdk-go/296d175bd33a209f8b4faa42042173dd4dd63648/crypto/wrapper/pkg/linux_amd64__legacy_os/lib/libprotobuf-nanopb.a -------------------------------------------------------------------------------- /crypto/wrapper/pkg/linux_amd64__legacy_os/lib/libround5.a: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/VirgilSecurity/virgil-sdk-go/296d175bd33a209f8b4faa42042173dd4dd63648/crypto/wrapper/pkg/linux_amd64__legacy_os/lib/libround5.a -------------------------------------------------------------------------------- /crypto/wrapper/pkg/linux_amd64__legacy_os/lib/libvsc_common.a: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/VirgilSecurity/virgil-sdk-go/296d175bd33a209f8b4faa42042173dd4dd63648/crypto/wrapper/pkg/linux_amd64__legacy_os/lib/libvsc_common.a -------------------------------------------------------------------------------- /crypto/wrapper/pkg/linux_amd64__legacy_os/lib/libvsc_foundation.a: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/VirgilSecurity/virgil-sdk-go/296d175bd33a209f8b4faa42042173dd4dd63648/crypto/wrapper/pkg/linux_amd64__legacy_os/lib/libvsc_foundation.a -------------------------------------------------------------------------------- /crypto/wrapper/pkg/linux_amd64__legacy_os/lib/libvsc_foundation_pb.a: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/VirgilSecurity/virgil-sdk-go/296d175bd33a209f8b4faa42042173dd4dd63648/crypto/wrapper/pkg/linux_amd64__legacy_os/lib/libvsc_foundation_pb.a -------------------------------------------------------------------------------- /crypto/wrapper/pkg/linux_amd64__legacy_os/lib/libvsc_phe.a: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/VirgilSecurity/virgil-sdk-go/296d175bd33a209f8b4faa42042173dd4dd63648/crypto/wrapper/pkg/linux_amd64__legacy_os/lib/libvsc_phe.a -------------------------------------------------------------------------------- /crypto/wrapper/pkg/linux_amd64__legacy_os/lib/libvsc_phe_pb.a: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/VirgilSecurity/virgil-sdk-go/296d175bd33a209f8b4faa42042173dd4dd63648/crypto/wrapper/pkg/linux_amd64__legacy_os/lib/libvsc_phe_pb.a -------------------------------------------------------------------------------- /crypto/wrapper/pkg/windows_amd64/include/mbedtls/fake_alt.h: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/VirgilSecurity/virgil-sdk-go/296d175bd33a209f8b4faa42042173dd4dd63648/crypto/wrapper/pkg/windows_amd64/include/mbedtls/fake_alt.h -------------------------------------------------------------------------------- /crypto/wrapper/pkg/windows_amd64/include/mbedtls/havege.h: -------------------------------------------------------------------------------- 1 | /** 2 | * \file havege.h 3 | * 4 | * \brief HAVEGE: HArdware Volatile Entropy Gathering and Expansion 5 | */ 6 | /* 7 | * Copyright (C) 2006-2015, ARM Limited, All Rights Reserved 8 | * SPDX-License-Identifier: Apache-2.0 9 | * 10 | * Licensed under the Apache License, Version 2.0 (the "License"); you may 11 | * not use this file except in compliance with the License. 12 | * You may obtain a copy of the License at 13 | * 14 | * http://www.apache.org/licenses/LICENSE-2.0 15 | * 16 | * Unless required by applicable law or agreed to in writing, software 17 | * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT 18 | * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 19 | * See the License for the specific language governing permissions and 20 | * limitations under the License. 21 | * 22 | * This file is part of mbed TLS (https://tls.mbed.org) 23 | */ 24 | #ifndef MBEDTLS_HAVEGE_H 25 | #define MBEDTLS_HAVEGE_H 26 | 27 | #include 28 | 29 | #define MBEDTLS_HAVEGE_COLLECT_SIZE 1024 30 | 31 | #ifdef __cplusplus 32 | extern "C" { 33 | #endif 34 | 35 | /** 36 | * \brief HAVEGE state structure 37 | */ 38 | typedef struct mbedtls_havege_state 39 | { 40 | int PT1, PT2, offset[2]; 41 | int pool[MBEDTLS_HAVEGE_COLLECT_SIZE]; 42 | int WALK[8192]; 43 | } 44 | mbedtls_havege_state; 45 | 46 | /** 47 | * \brief HAVEGE initialization 48 | * 49 | * \param hs HAVEGE state to be initialized 50 | */ 51 | void mbedtls_havege_init( mbedtls_havege_state *hs ); 52 | 53 | /** 54 | * \brief Clear HAVEGE state 55 | * 56 | * \param hs HAVEGE state to be cleared 57 | */ 58 | void mbedtls_havege_free( mbedtls_havege_state *hs ); 59 | 60 | /** 61 | * \brief HAVEGE rand function 62 | * 63 | * \param p_rng A HAVEGE state 64 | * \param output Buffer to fill 65 | * \param len Length of buffer 66 | * 67 | * \return 0 68 | */ 69 | int mbedtls_havege_random( void *p_rng, unsigned char *output, size_t len ); 70 | 71 | #ifdef __cplusplus 72 | } 73 | #endif 74 | 75 | #endif /* havege.h */ 76 | -------------------------------------------------------------------------------- /crypto/wrapper/pkg/windows_amd64/include/mbedtls/net.h: -------------------------------------------------------------------------------- 1 | /** 2 | * \file net.h 3 | * 4 | * \brief Deprecated header file that includes net_sockets.h 5 | * 6 | * \deprecated Superseded by mbedtls/net_sockets.h 7 | */ 8 | /* 9 | * Copyright (C) 2006-2016, ARM Limited, All Rights Reserved 10 | * SPDX-License-Identifier: Apache-2.0 11 | * 12 | * Licensed under the Apache License, Version 2.0 (the "License"); you may 13 | * not use this file except in compliance with the License. 14 | * You may obtain a copy of the License at 15 | * 16 | * http://www.apache.org/licenses/LICENSE-2.0 17 | * 18 | * Unless required by applicable law or agreed to in writing, software 19 | * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT 20 | * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 21 | * See the License for the specific language governing permissions and 22 | * limitations under the License. 23 | * 24 | * This file is part of mbed TLS (https://tls.mbed.org) 25 | */ 26 | 27 | #if !defined(MBEDTLS_DEPRECATED_REMOVED) 28 | #include "net_sockets.h" 29 | #if defined(MBEDTLS_DEPRECATED_WARNING) 30 | #warning "Deprecated header file: Superseded by mbedtls/net_sockets.h" 31 | #endif /* MBEDTLS_DEPRECATED_WARNING */ 32 | #endif /* !MBEDTLS_DEPRECATED_REMOVED */ 33 | -------------------------------------------------------------------------------- /crypto/wrapper/pkg/windows_amd64/include/pb_common.h: -------------------------------------------------------------------------------- 1 | /* pb_common.h: Common support functions for pb_encode.c and pb_decode.c. 2 | * These functions are rarely needed by applications directly. 3 | */ 4 | 5 | #ifndef PB_COMMON_H_INCLUDED 6 | #define PB_COMMON_H_INCLUDED 7 | 8 | #include "pb.h" 9 | 10 | #ifdef __cplusplus 11 | extern "C" { 12 | #endif 13 | 14 | /* Iterator for pb_field_t list */ 15 | struct pb_field_iter_s { 16 | const pb_field_t *start; /* Start of the pb_field_t array */ 17 | const pb_field_t *pos; /* Current position of the iterator */ 18 | unsigned required_field_index; /* Zero-based index that counts only the required fields */ 19 | void *dest_struct; /* Pointer to start of the structure */ 20 | void *pData; /* Pointer to current field value */ 21 | void *pSize; /* Pointer to count/has field */ 22 | }; 23 | typedef struct pb_field_iter_s pb_field_iter_t; 24 | 25 | /* Initialize the field iterator structure to beginning. 26 | * Returns false if the message type is empty. */ 27 | bool pb_field_iter_begin(pb_field_iter_t *iter, const pb_field_t *fields, void *dest_struct); 28 | 29 | /* Advance the iterator to the next field. 30 | * Returns false when the iterator wraps back to the first field. */ 31 | bool pb_field_iter_next(pb_field_iter_t *iter); 32 | 33 | /* Advance the iterator until it points at a field with the given tag. 34 | * Returns false if no such field exists. */ 35 | bool pb_field_iter_find(pb_field_iter_t *iter, uint32_t tag); 36 | 37 | #ifdef __cplusplus 38 | } /* extern "C" */ 39 | #endif 40 | 41 | #endif 42 | 43 | -------------------------------------------------------------------------------- /crypto/wrapper/pkg/windows_amd64/include/round5/a_fixed.h: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 2018, Koninklijke Philips N.V. 3 | */ 4 | 5 | /** 6 | * @file 7 | * Declaration of the fixed A matrix as well as the function to generate it. 8 | */ 9 | 10 | #ifndef A_FIXED_H 11 | #define A_FIXED_H 12 | 13 | #include "r5_parameter_sets.h" 14 | 15 | #if PARAMS_TAU == 1 16 | /** 17 | * The fixed A matrix for use inside with the non-ring algorithm when τ=1. 18 | * This matrix is generated by `create_A_fixed()`. 19 | */ 20 | extern modq_t A_fixed[PARAMS_D * 2 * PARAMS_K]; 21 | #endif 22 | 23 | #ifdef __cplusplus 24 | extern "C" { 25 | #endif 26 | 27 | /** 28 | * Function to generate a fixed A matrix from the given seed and algorithm parameters. 29 | * 30 | * @param[in] seed the seed to use to generate the fixed A matrix (KAPPA_BYTES bytes) 31 | * @return __0__ in case of success 32 | */ 33 | int create_A_fixed(const unsigned char *seed); 34 | 35 | #ifdef __cplusplus 36 | } 37 | #endif 38 | 39 | #endif /* A_FIXED_H */ 40 | -------------------------------------------------------------------------------- /crypto/wrapper/pkg/windows_amd64/include/round5/a_random.h: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 2018, Koninklijke Philips N.V. 3 | */ 4 | 5 | /** 6 | * @file 7 | * Declaration of the random A matrix creation function. 8 | */ 9 | 10 | #ifndef A_RANDOM_H 11 | #define A_RANDOM_H 12 | 13 | #include "r5_parameter_sets.h" 14 | 15 | #ifdef __cplusplus 16 | extern "C" { 17 | #endif 18 | 19 | /** 20 | * Creates A random for the given seed and algorithm parameters. 21 | * 22 | * @param[out] A_random the random A to create 23 | * @param[in] seed the seed (PARAMS_KAPPA_BYTES bytes) 24 | */ 25 | void create_A_random(modq_t *A_random, const unsigned char *seed); 26 | 27 | #ifdef __cplusplus 28 | } 29 | #endif 30 | 31 | #endif /* A_RANDOM_H */ 32 | -------------------------------------------------------------------------------- /crypto/wrapper/pkg/windows_amd64/include/round5/checkPublicParameter.h: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 2020, Koninklijke Philips N.V. 3 | */ 4 | 5 | 6 | //#ifndef checkPublicParameter_h 7 | //#define checkPublicParameter_h 8 | 9 | #include "r5_parameter_sets.h" 10 | 11 | #ifdef CM_MALFORMED 12 | int checkPublicParameter(modp_t *public_param, uint16_t num_vectors); 13 | #endif 14 | 15 | 16 | //#endif /* checkPublicParameter_h */ 17 | -------------------------------------------------------------------------------- /crypto/wrapper/pkg/windows_amd64/include/round5/chooseparameters.h: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 2020, Koninklijke Philips N.V. 3 | */ 4 | 5 | #define PARAMETERCONSTANT 6 | 7 | #define SHAKE128_RATE 168 8 | // 168 bytes as a bytesequence = 1344 bits as a bitsequence 9 | 10 | #define SHAKE256_RATE 136 11 | // 136 bytes as a bytesequence = 1088 bits as a bitsequence 12 | 13 | #ifdef PARAMETERCONSTANT 14 | 15 | #include "r5_parameter_sets.h" 16 | 17 | #define Parameters 18 | #define Params 19 | #define useParams 20 | 21 | #if (PARAMS_KAPPA_BYTES > 16) 22 | #define RATE SHAKE256_RATE 23 | #else 24 | #define RATE SHAKE128_RATE 25 | #endif 26 | 27 | #define DeclareParameters 28 | 29 | #else 30 | 31 | #include "parameters.h" 32 | 33 | #define Parameters , const parameters * params 34 | #define Params , params 35 | #define useParams params = params ; 36 | 37 | #define DeclareParameters\ 38 | parameters * params; \ 39 | if ((params = set_parameters_from_api()) == NULL) \ 40 | exit(EXIT_FAILURE) 41 | 42 | 43 | #define RATE (params->kappa_bytes > 16 ? SHAKE256_RATE : SHAKE128_RATE ) 44 | #define PARAMS_B_BITS (params->b_bits) 45 | #define PARAMS_T_BITS (params->t_bits) 46 | #define PARAMS_P_BITS (params->p_bits) 47 | #define PARAMS_Q_BITS (params->q_bits) 48 | #define PARAMS_CT_SIZE (params->ct_size) 49 | #define PARAMS_PK_SIZE (params->pk_size) 50 | #define PARAMS_D (params->d) 51 | #define PARAMS_Q (params->q) 52 | #define PARAMS_H (params->h) 53 | #define PARAMS_H1 (params->h1) 54 | #define PARAMS_H2 (params->h2) 55 | #define PARAMS_H3 (params->h3) 56 | #define PARAMS_F (params->f) 57 | #define PARAMS_K (params->k) 58 | #define PARAMS_N (params->n) 59 | #define PARAMS_N_BAR (params->n_bar) 60 | #define PARAMS_M (params->m) 61 | #define PARAMS_MU (params->mu) 62 | #define PARAMS_M_BAR (params->m_bar) 63 | #define PARAMS_P (params->p) 64 | #define PARAMS_TAU (params->tau) 65 | #define PARAMS_TAU2_LEN (params->tau2_len) 66 | #define PARAMS_KAPPA (params->kappa) 67 | #define PARAMS_KAPPA_BYTES (params->kappa_bytes) 68 | #define PARAMS_CT_SIZE (params->ct_size) 69 | #define PARAMS_XE (params->xe) 70 | 71 | #endif 72 | 73 | -------------------------------------------------------------------------------- /crypto/wrapper/pkg/windows_amd64/include/round5/keccakf1600.h: -------------------------------------------------------------------------------- 1 | #ifndef _KECCAKF1600_H_ 2 | #define _KECCAKF1600_H_ 3 | 4 | // Importing, build upon: 5 | #include 6 | #include 7 | 8 | #ifdef AVX2 9 | #include 10 | #endif 11 | 12 | #include "chooseparameters.h" 13 | 14 | // Reduction of public domain sources. 15 | 16 | void KeccakF1600_StateExtractBytes ( uint64_t *state, uint8_t *data Parameters ); 17 | 18 | void KeccakF1600_StateXORBytes ( uint64_t *state, const uint8_t *data Parameters ); 19 | 20 | void KeccakF1600_StatePermute( uint64_t *state ); 21 | 22 | #ifdef AVX2 23 | void KeccakF1600_StateExtractBytes_4x(__m256i *state, 24 | uint8_t *data0, 25 | uint8_t *data1, 26 | uint8_t *data2, 27 | uint8_t *data3 28 | Parameters ); 29 | 30 | void KeccakF1600_StateXORBytes_4x (__m256i *state, 31 | const uint8_t *data0, 32 | const uint8_t *data1, 33 | const uint8_t *data2, 34 | const uint8_t *data3 35 | Parameters ); 36 | #endif 37 | 38 | #endif /* _KECCAKF1600_H_ */ 39 | 40 | 41 | -------------------------------------------------------------------------------- /crypto/wrapper/pkg/windows_amd64/include/round5/matmul.h: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 2020, Koninklijke Philips N.V. 3 | */ 4 | 5 | #ifndef _MATMUL_H_ 6 | #define _MATMUL_H_ 7 | 8 | #include "r5_parameter_sets.h" 9 | 10 | #if PARAMS_K != 1 11 | 12 | //#if !defined(CM_CT) || !defined(CM_CACHE) 13 | //void create_secret_matrix_s_t(tern_secret_s secret_vector, const uint8_t *seed); 14 | //void create_secret_matrix_r_t(tern_secret_r secret_vector, const uint8_t *seed); 15 | //#endif 16 | 17 | #if PARAMS_TAU == 0 18 | void matmul_as_q(modq_t d[PARAMS_D][PARAMS_N_BAR], modq_t a[PARAMS_D][PARAMS_D], tern_secret_s secret_vector); 19 | void matmul_rta_q(modq_t d[PARAMS_M_BAR][PARAMS_D], modq_t a[PARAMS_D][PARAMS_D], tern_secret_r secret_vector); 20 | #elif PARAMS_TAU == 1 21 | void matmul_as_q(modq_t d[PARAMS_D][PARAMS_N_BAR], modq_t a[2 * PARAMS_D * PARAMS_D], uint32_t a_permutation[PARAMS_D], tern_secret_s secret_vector); 22 | void matmul_rta_q(modq_t d[PARAMS_M_BAR][PARAMS_D], modq_t a[2 * PARAMS_D * PARAMS_D], uint32_t a_permutation[PARAMS_D], tern_secret_r secret_vector); 23 | #else 24 | void matmul_as_q(modq_t d[PARAMS_D][PARAMS_N_BAR], modq_t a[PARAMS_TAU2_LEN + PARAMS_D], uint16_t a_permutation[PARAMS_D], tern_secret_s secret_vector); 25 | void matmul_rta_q(modq_t d[PARAMS_M_BAR][PARAMS_D], modq_t a[PARAMS_TAU2_LEN + PARAMS_D], uint16_t a_permutation[PARAMS_D], tern_secret_r secret_vector); 26 | #endif 27 | 28 | void matmul_stu_p(modp_t d[PARAMS_MU], modp_t u_t[PARAMS_M_BAR][PARAMS_D], tern_secret_s secret_vector); 29 | 30 | void matmul_btr_p(modp_t d[PARAMS_MU], modp_t b[PARAMS_D][PARAMS_N_BAR], tern_secret_r secret_vector); 31 | 32 | #endif /* PARAMS_K != 1 */ 33 | 34 | #endif /* _MATMUL_H_ */ 35 | -------------------------------------------------------------------------------- /crypto/wrapper/pkg/windows_amd64/include/round5/pack.h: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 2020, Koninklijke Philips N.V. 3 | */ 4 | 5 | #include 6 | #include "r5_parameter_sets.h" 7 | 8 | void pack_qp(uint8_t *pv, const modq_t *vq, const modq_t rounding_constant, size_t num_coeff, size_t size); 9 | void unpack_p(modp_t *vp, const uint8_t *pv, size_t num_coeff); 10 | 11 | 12 | -------------------------------------------------------------------------------- /crypto/wrapper/pkg/windows_amd64/include/round5/r5_cca_kem.h: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 2018, PQShield and Koninklijke Philips N.V. 3 | * Markku-Juhani O. Saarinen, Koninklijke Philips N.V. 4 | */ 5 | 6 | #ifndef R5_CCA_KEM_H 7 | #define R5_CCA_KEM_H 8 | 9 | #ifdef __cplusplus 10 | extern "C" { 11 | #endif 12 | 13 | /** 14 | * Generates a CCA KEM key pair. Uses the parameters as specified. 15 | * 16 | * @param[out] pk public key 17 | * @param[out] sk secret key 18 | * @return __0__ in case of success 19 | */ 20 | int r5_cca_kem_keygen(unsigned char *pk, unsigned char *sk); 21 | 22 | /** 23 | * CCA KEM encapsulate. Uses the parameters as specified. 24 | * 25 | * @param[out] ct key encapsulation message (important: the size of `ct` is `ct_size` + `kappa_bytes`!) 26 | * @param[out] k shared secret 27 | * @param[in] pk public key with which the message is encapsulated 28 | * @return __0__ in case of success 29 | */ 30 | int r5_cca_kem_encapsulate(unsigned char *ct, unsigned char *k, const unsigned char *pk); 31 | 32 | /** 33 | * CCA KEM de-capsulate. Uses the parameters as specified. 34 | * 35 | * @param[out] k shared secret 36 | * @param[in] ct key encapsulation message (important: the size of `ct` is `ct_size` + `kappa_bytes`!) 37 | * @param[in] sk secret key with which the message is to be de-capsulated (important: the size of `sk` is `sk_size` + `kappa_bytes` + `pk_size`!) 38 | * @return __0__ in case of success 39 | */ 40 | int r5_cca_kem_decapsulate(unsigned char *k, const unsigned char *ct, const unsigned char *sk); 41 | 42 | #ifdef __cplusplus 43 | } 44 | #endif 45 | 46 | #endif /* R5_CCA_KEM_H */ 47 | -------------------------------------------------------------------------------- /crypto/wrapper/pkg/windows_amd64/include/round5/r5_cca_pke.h: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 2018, Koninklijke Philips N.V. 3 | */ 4 | 5 | /** 6 | * @file 7 | * Declaration of the encrypt and decrypt functions based on the CCA KEM 8 | * algorithm. 9 | */ 10 | 11 | #ifndef _R5_CCA_PKE_H_ 12 | #define _R5_CCA_PKE_H_ 13 | 14 | #ifdef __cplusplus 15 | extern "C" { 16 | #endif 17 | 18 | /** 19 | * Generates an ENCRYPT key pair. Uses the parameters as specified. 20 | * 21 | * @param[out] pk public key 22 | * @param[out] sk secret key (important: the size of `sk` is `sk_size` + `kappa_bytes` + `pk_size`!) 23 | * @return __0__ in case of success 24 | */ 25 | int r5_cca_pke_keygen(unsigned char *pk, unsigned char *sk); 26 | 27 | /** 28 | * Encrypts a message. Uses the parameters as specified. 29 | * 30 | * @param[out] ct the encrypted message 31 | * @param[out] ct_len the length of the encrypted message (`mlen` + `ct_size` + `kappa_bytes` + 16) 32 | * @param[in] m the message to encrypt 33 | * @param[in] m_len the length of the message to encrypt 34 | * @param[in] pk the public key to use for the encryption 35 | * @return __0__ in case of success 36 | */ 37 | int r5_cca_pke_encrypt(unsigned char *ct, unsigned long long *ct_len, const unsigned char *m, const unsigned long long m_len, const unsigned char *pk); 38 | 39 | /** 40 | * Decrypts a message. Uses the parameters as specified. 41 | * 42 | * @param[out] m the decrypted message 43 | * @param[out] m_len the length of the decrypted message (`ct_len` - `ct_size` - `kappa_bytes` - 16) 44 | * @param[in] ct the message to decrypt 45 | * @param[in] ct_len the length of the message to decrypt 46 | * @param[in] sk the secret key to use for the decryption 47 | * @return __0__ in case of success 48 | */ 49 | int r5_cca_pke_decrypt(unsigned char *m, unsigned long long *m_len, const unsigned char *ct, const unsigned long long ct_len, const unsigned char *sk); 50 | 51 | #ifdef __cplusplus 52 | } 53 | #endif 54 | 55 | #endif /* _R5_CCA_PKE_H_ */ 56 | -------------------------------------------------------------------------------- /crypto/wrapper/pkg/windows_amd64/include/round5/r5_cpa_kem.h: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 2018, Koninklijke Philips N.V. 3 | */ 4 | 5 | /** 6 | * @file 7 | * Declaration of the CPA KEM functions. 8 | */ 9 | 10 | #ifndef R5_CPA_KEM_H 11 | #define R5_CPA_KEM_H 12 | 13 | #ifdef __cplusplus 14 | extern "C" { 15 | #endif 16 | 17 | /** 18 | * Generates a CPA KEM key pair. Uses the parameters as specified. 19 | * 20 | * @param[out] pk public key 21 | * @param[out] sk secret key 22 | * @return __0__ in case of success 23 | */ 24 | int r5_cpa_kem_keygen(unsigned char *pk, unsigned char *sk); 25 | 26 | /** 27 | * CPA KEM encapsulate. Uses the parameters as specified. 28 | * 29 | * @param[out] ct key encapsulation message 30 | * @param[out] k shared secret 31 | * @return __0__ in case of success 32 | */ 33 | int r5_cpa_kem_encapsulate(unsigned char *ct, unsigned char *k, const unsigned char *pk); 34 | 35 | /** 36 | * CPA KEM de-capsulate. Uses the parameters as specified. 37 | * 38 | * @param[out] k shared secret 39 | * @param[in] ct key encapsulation message 40 | * @param[in] sk secret key with which the message is to be de-capsulated 41 | * @return __0__ in case of success 42 | */ 43 | int r5_cpa_kem_decapsulate(unsigned char *k, const unsigned char *ct, const unsigned char *sk); 44 | 45 | #ifdef __cplusplus 46 | } 47 | #endif 48 | 49 | #endif /* R5_CPA_KEM_H */ 50 | -------------------------------------------------------------------------------- /crypto/wrapper/pkg/windows_amd64/include/round5/r5_cpa_pke.h: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 2018, PQShield and Koninklijke Philips N.V. 3 | * Markku-Juhani O. Saarinen, Koninklijke Philips N.V. 4 | */ 5 | 6 | #ifndef _R5_CPA_PKE_H_ 7 | #define _R5_CPA_PKE_H_ 8 | 9 | #include 10 | 11 | int r5_cpa_pke_keygen(uint8_t *pk, uint8_t *sk); 12 | 13 | int r5_cpa_pke_encrypt(uint8_t *ct, const uint8_t *pk, const uint8_t *m, const uint8_t *rho); 14 | 15 | int r5_cpa_pke_decrypt(uint8_t *m, const uint8_t *sk, const uint8_t *ct); 16 | 17 | #endif /* _R5_CPA_PKE_H_ */ 18 | -------------------------------------------------------------------------------- /crypto/wrapper/pkg/windows_amd64/include/round5/r5_dem.h: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 2018, Koninklijke Philips N.V. 3 | */ 4 | 5 | /** 6 | * @file 7 | * Declaration of the DEM functions used by the Round5 CCA KEM-based encrypt algorithm. 8 | */ 9 | 10 | #ifndef PST_DEM_H 11 | #define PST_DEM_H 12 | 13 | #include 14 | 15 | #ifdef __cplusplus 16 | extern "C" { 17 | #endif 18 | 19 | /** 20 | * Applies a DEM to the given message using the specified key. 21 | * 22 | * @param[out] c2 the encapsulated message 23 | * @param[out] c2_len the length of the encapsulated message (`m_len` + 16 bytes) 24 | * @param[in] key the key to use for the encapsulation 25 | * @param[in] m the message to encapsulate 26 | * @param[in] m_len the length of the message 27 | * @return __0__ in case of success 28 | */ 29 | int round5_dem(unsigned char *c2, unsigned long long *c2_len, const unsigned char *key, const unsigned char *m, const unsigned long long m_len); 30 | 31 | /** 32 | * Inverses the application of a DEM to a message. 33 | * 34 | * @param[out] m the original message 35 | * @param[out] m_len the length of the decapsulated message (`c2_len` - 16) 36 | * @param[in] key the key to use for the encapsulation 37 | * @param[in] c2 the encapsulated message 38 | * @param[in] c2_len the length of the encapsulated message 39 | * @return __0__ in case of success 40 | */ 41 | int round5_dem_inverse(unsigned char *m, unsigned long long *m_len, const unsigned char *key, const unsigned char *c2, const unsigned long long c2_len); 42 | 43 | #ifdef __cplusplus 44 | } 45 | #endif 46 | 47 | #endif /* PST_DEM_H */ 48 | -------------------------------------------------------------------------------- /crypto/wrapper/pkg/windows_amd64/include/round5/r5_hash.h: -------------------------------------------------------------------------------- 1 | #ifndef _R5_HASH_H_ 2 | #define _R5_HASH_H_ 3 | 4 | /* 5 | * Copyright (c) 2020, Koninklijke Philips N.V. 6 | */ 7 | 8 | /** 9 | * @file 10 | * Definition of the hash function as used within Round5. 11 | */ 12 | 13 | #include "f202sp800185.h" 14 | 15 | #ifdef __cplusplus 16 | extern "C" { 17 | #endif 18 | 19 | extern void HCPAKEM 20 | ( uint8_t *output, uint32_t outputLength, 21 | const uint8_t *firstInput, uint16_t firstInputLength, 22 | const uint8_t *secondInput, uint32_t secondInputLength 23 | Parameters ); 24 | 25 | extern void HCCAKEM 26 | ( uint8_t *output, uint32_t outputLength, 27 | const uint8_t *firstInput, uint16_t firstInputLength, 28 | const uint8_t *secondInput, uint32_t secondInputLength 29 | Parameters ); 30 | 31 | extern void GCCAKEM 32 | ( uint8_t *output, uint32_t outputLength, 33 | const uint8_t *firstInput, uint16_t firstInputLength, 34 | const uint8_t *secondInput, uint32_t secondInputLength 35 | Parameters ); 36 | 37 | extern void HashR5DEM 38 | ( uint8_t *output, uint32_t outputLength, 39 | const uint8_t *firstInput, uint16_t firstInputLength 40 | Parameters ); 41 | 42 | #ifdef __cplusplus 43 | } 44 | #endif 45 | 46 | #endif /* _R5_HASH_H_ */ 47 | -------------------------------------------------------------------------------- /crypto/wrapper/pkg/windows_amd64/include/round5/r5_secretkeygen.h: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 2020, PQShield and Koninklijke Philips N.V. 3 | * Markku-Juhani O. Saarinen, Koninklijke Philips N.V. 4 | */ 5 | 6 | #ifndef secretkeygen_h 7 | #define secretkeygen_h 8 | 9 | #include "r5_parameter_sets.h" 10 | 11 | void create_secret_vector_s(tern_secret secret_vector, const uint8_t *seed); 12 | void create_secret_vector_r(tern_secret secret_vector, const uint8_t *seed); 13 | void create_secret_matrix_s_t(tern_secret_s secret_vector, const uint8_t *seed); 14 | void create_secret_matrix_r_t(tern_secret_r secret_vector, const uint8_t *seed); 15 | 16 | #endif /* secretkeygen_h */ 17 | 18 | -------------------------------------------------------------------------------- /crypto/wrapper/pkg/windows_amd64/include/round5/ringmul.h: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 2018, PQShield and Koninklijke Philips N.V. 3 | * Markku-Juhani O. Saarinen, Koninklijke Philips N.V. 4 | */ 5 | 6 | #ifndef _RINGMUL_H_ 7 | #define _RINGMUL_H_ 8 | 9 | #include "r5_parameter_sets.h" 10 | 11 | #if PARAMS_K == 1 12 | 13 | // multiplication mod q, result length n 14 | void ringmul_q(modq_t d[PARAMS_N], modq_t a[PARAMS_N], tern_secret idx); 15 | 16 | // multiplication mod p, result length mu 17 | void ringmul_p(modp_t d[PARAMS_MU], modp_t a[PARAMS_N], tern_secret idx); 18 | 19 | #endif 20 | 21 | #endif /* _RINGMUL_H_ */ 22 | -------------------------------------------------------------------------------- /crypto/wrapper/pkg/windows_amd64/include/round5/rng.h: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 2018, Koninklijke Philips N.V. 3 | */ 4 | 5 | /** 6 | * @file 7 | * Declaration of the random bytes functions. 8 | */ 9 | 10 | #ifndef RNG_H 11 | #define RNG_H 12 | 13 | #ifdef __cplusplus 14 | extern "C" { 15 | #endif 16 | 17 | // /** 18 | // * Initializes the random number generator used for generating the random 19 | // * bytes. 20 | // * 21 | // * @param[in] entropy_input the bytes to use as input entropy (48 bytes) 22 | // * @param[in] personalization_string an optional personalization string (48 bytes) 23 | // * @param[in] security_strength parameter to specify the security strength of the random bytes 24 | // */ 25 | void randombytes_init(unsigned char *entropy_input, unsigned char *personalization_string, int security_strength); 26 | 27 | /** 28 | * Generates a sequence of random bytes. 29 | * 30 | * @param[out] x destination of the random bytes 31 | * @param[in] xlen the number of random bytes 32 | * @return _0_ in case of success, non-zero otherwise 33 | */ 34 | int randombytes(unsigned char *x, unsigned long long xlen); 35 | 36 | #ifdef __cplusplus 37 | } 38 | #endif 39 | 40 | #endif /* RNG_H */ 41 | -------------------------------------------------------------------------------- /crypto/wrapper/pkg/windows_amd64/include/round5/xef.h: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 2018, PQShield 3 | * Markku-Juhani O. Saarinen 4 | */ 5 | 6 | // Generic prototypes for error correction code 7 | 8 | #ifndef _XEF_H_ 9 | #define _XEF_H_ 10 | 11 | #include 12 | #include 13 | 14 | // Parametrized versions. f = 0..5, number of errors fixed 15 | 16 | // Computes the parity code, XORs it at the end of payload 17 | // len = payload (bytes). Returns (payload | xef) length in *bits*. 18 | size_t xef_compute(void *block, size_t len, unsigned f); 19 | 20 | // Fixes errors based on parity code. Call xef_compute() first to get delta. 21 | // len = payload (bytes). Returns (payload | xef) length in *bits*. 22 | size_t xef_fixerr(void *block, size_t len, unsigned f); 23 | 24 | 25 | // specific code from optimized implementations 26 | 27 | void xe2_53_compute(void *block); // xe2_c16.c 28 | void xe2_53_fixerr(void *block); 29 | 30 | void xe4_163_compute(void *block); // xe4_c64.c 31 | void xe4_163_fixerr(void *block); 32 | 33 | void xe5_190_compute(void *block); // xe5_c64.c 34 | void xe5_190_fixerr(void *block); 35 | void xe5_218_compute(void *block); 36 | void xe5_218_fixerr(void *block); 37 | void xe5_234_compute(void *block); 38 | void xe5_234_fixerr(void *block); 39 | 40 | #endif /* _XEF_H_ */ 41 | -------------------------------------------------------------------------------- /crypto/wrapper/pkg/windows_amd64/include/virgil/crypto/phe/UOKMSModels.pb.h: -------------------------------------------------------------------------------- 1 | /* Automatically generated nanopb header */ 2 | /* Generated by nanopb-0.3.9.4 at Wed May 13 14:57:44 2020. */ 3 | 4 | #ifndef PB_UOKMSMODELS_PB_H_INCLUDED 5 | #define PB_UOKMSMODELS_PB_H_INCLUDED 6 | #include 7 | 8 | /* @@protoc_insertion_point(includes) */ 9 | #if PB_PROTO_HEADER_VERSION != 30 10 | #error Regenerate this file with the current version of nanopb generator. 11 | #endif 12 | 13 | #ifdef __cplusplus 14 | extern "C" { 15 | #endif 16 | 17 | /* Struct definitions */ 18 | typedef struct _UOKMSProofOfSuccess { 19 | pb_byte_t term1[65]; 20 | pb_byte_t term2[65]; 21 | pb_byte_t blind_x[32]; 22 | /* @@protoc_insertion_point(struct:UOKMSProofOfSuccess) */ 23 | } UOKMSProofOfSuccess; 24 | 25 | typedef struct _DecryptResponse { 26 | pb_byte_t v[65]; 27 | UOKMSProofOfSuccess proof; 28 | /* @@protoc_insertion_point(struct:DecryptResponse) */ 29 | } DecryptResponse; 30 | 31 | /* Default values for struct fields */ 32 | 33 | /* Initializer values for message structs */ 34 | #define UOKMSProofOfSuccess_init_default {{0}, {0}, {0}} 35 | #define DecryptResponse_init_default {{0}, UOKMSProofOfSuccess_init_default} 36 | #define UOKMSProofOfSuccess_init_zero {{0}, {0}, {0}} 37 | #define DecryptResponse_init_zero {{0}, UOKMSProofOfSuccess_init_zero} 38 | 39 | /* Field tags (for use in manual encoding/decoding) */ 40 | #define UOKMSProofOfSuccess_term1_tag 1 41 | #define UOKMSProofOfSuccess_term2_tag 2 42 | #define UOKMSProofOfSuccess_blind_x_tag 3 43 | #define DecryptResponse_v_tag 1 44 | #define DecryptResponse_proof_tag 2 45 | 46 | /* Struct field encoding specification for nanopb */ 47 | extern const pb_field_t UOKMSProofOfSuccess_fields[4]; 48 | extern const pb_field_t DecryptResponse_fields[3]; 49 | 50 | /* Maximum encoded size of messages (where known) */ 51 | #define UOKMSProofOfSuccess_size 168 52 | #define DecryptResponse_size 238 53 | 54 | /* Message IDs (where set with "msgid" option) */ 55 | #ifdef PB_MSGID 56 | 57 | #define UOKMSMODELS_MESSAGES \ 58 | 59 | 60 | #endif 61 | 62 | #ifdef __cplusplus 63 | } /* extern "C" */ 64 | #endif 65 | /* @@protoc_insertion_point(eof) */ 66 | 67 | #endif 68 | -------------------------------------------------------------------------------- /crypto/wrapper/pkg/windows_amd64/lib/libed25519.a: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/VirgilSecurity/virgil-sdk-go/296d175bd33a209f8b4faa42042173dd4dd63648/crypto/wrapper/pkg/windows_amd64/lib/libed25519.a -------------------------------------------------------------------------------- /crypto/wrapper/pkg/windows_amd64/lib/libfalcon.a: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/VirgilSecurity/virgil-sdk-go/296d175bd33a209f8b4faa42042173dd4dd63648/crypto/wrapper/pkg/windows_amd64/lib/libfalcon.a -------------------------------------------------------------------------------- /crypto/wrapper/pkg/windows_amd64/lib/libmbedcrypto.a: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/VirgilSecurity/virgil-sdk-go/296d175bd33a209f8b4faa42042173dd4dd63648/crypto/wrapper/pkg/windows_amd64/lib/libmbedcrypto.a -------------------------------------------------------------------------------- /crypto/wrapper/pkg/windows_amd64/lib/libprotobuf-nanopb.a: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/VirgilSecurity/virgil-sdk-go/296d175bd33a209f8b4faa42042173dd4dd63648/crypto/wrapper/pkg/windows_amd64/lib/libprotobuf-nanopb.a -------------------------------------------------------------------------------- /crypto/wrapper/pkg/windows_amd64/lib/libround5.a: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/VirgilSecurity/virgil-sdk-go/296d175bd33a209f8b4faa42042173dd4dd63648/crypto/wrapper/pkg/windows_amd64/lib/libround5.a -------------------------------------------------------------------------------- /crypto/wrapper/pkg/windows_amd64/lib/libvsc_common.a: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/VirgilSecurity/virgil-sdk-go/296d175bd33a209f8b4faa42042173dd4dd63648/crypto/wrapper/pkg/windows_amd64/lib/libvsc_common.a -------------------------------------------------------------------------------- /crypto/wrapper/pkg/windows_amd64/lib/libvsc_foundation.a: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/VirgilSecurity/virgil-sdk-go/296d175bd33a209f8b4faa42042173dd4dd63648/crypto/wrapper/pkg/windows_amd64/lib/libvsc_foundation.a -------------------------------------------------------------------------------- /crypto/wrapper/pkg/windows_amd64/lib/libvsc_foundation_pb.a: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/VirgilSecurity/virgil-sdk-go/296d175bd33a209f8b4faa42042173dd4dd63648/crypto/wrapper/pkg/windows_amd64/lib/libvsc_foundation_pb.a -------------------------------------------------------------------------------- /crypto/wrapper/pkg/windows_amd64/lib/libvsc_phe.a: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/VirgilSecurity/virgil-sdk-go/296d175bd33a209f8b4faa42042173dd4dd63648/crypto/wrapper/pkg/windows_amd64/lib/libvsc_phe.a -------------------------------------------------------------------------------- /crypto/wrapper/pkg/windows_amd64/lib/libvsc_phe_pb.a: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/VirgilSecurity/virgil-sdk-go/296d175bd33a209f8b4faa42042173dd4dd63648/crypto/wrapper/pkg/windows_amd64/lib/libvsc_phe_pb.a -------------------------------------------------------------------------------- /doc.go: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (C) 2015-2018 Virgil Security Inc. 3 | * 4 | * Lead Maintainer: Virgil Security Inc. 5 | * 6 | * All rights reserved. 7 | * 8 | * Redistribution and use in source and binary forms, with or without 9 | * modification, are permitted provided that the following conditions 10 | * are met: 11 | * 12 | * (1) Redistributions of source code must retain the above copyright 13 | * notice, this list of conditions and the following disclaimer. 14 | * 15 | * (2) Redistributions in binary form must reproduce the above copyright 16 | * notice, this list of conditions and the following disclaimer in 17 | * the documentation and/or other materials provided with the 18 | * distribution. 19 | * 20 | * (3) Neither the name of the copyright holder nor the names of its 21 | * contributors may be used to endorse or promote products derived 22 | * from this software without specific prior written permission. 23 | * 24 | * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ''AS IS'' AND ANY EXPRESS OR 25 | * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED 26 | * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE 27 | * DISCLAIMED. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, 28 | * INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES 29 | * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR 30 | * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) 31 | * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, 32 | * STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING 33 | * IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE 34 | * POSSIBILITY OF SUCH DAMAGE. 35 | * 36 | */ 37 | 38 | package virgil 39 | -------------------------------------------------------------------------------- /errors/api.go: -------------------------------------------------------------------------------- 1 | package errors 2 | 3 | import ( 4 | "errors" 5 | "fmt" 6 | ) 7 | 8 | var ( 9 | // ErrEntityNotFound return when service return 404 HTTP status code and body is empty 10 | ErrEntityNotFound = &VirgilAPIError{ 11 | Code: 10001, 12 | Message: "entity was not found", 13 | } 14 | 15 | // ErrInternalServerError return when service return 5xx HTTP status code and body is empty 16 | ErrInternalServerError = &VirgilAPIError{ 17 | Code: 10000, 18 | Message: "internal server error", 19 | } 20 | ) 21 | 22 | // VirgilAPIError is service's errors 23 | type VirgilAPIError struct { 24 | Code int `json:"code"` 25 | Message string `json:"message"` 26 | } 27 | 28 | func (err *VirgilAPIError) Error() string { 29 | return fmt.Sprintf("Virgil API error {code: %v message: %v}", err.Code, err.Message) 30 | } 31 | 32 | func (err *VirgilAPIError) Is(e error) bool { 33 | var ve *VirgilAPIError 34 | if !errors.As(e, &ve) { 35 | return false 36 | } 37 | return ve.Code == err.Code 38 | } 39 | -------------------------------------------------------------------------------- /go.mod: -------------------------------------------------------------------------------- 1 | module github.com/VirgilSecurity/virgil-sdk-go/v6 2 | 3 | go 1.12 4 | 5 | require ( 6 | github.com/cenkalti/backoff/v4 v4.0.2 7 | github.com/stretchr/testify v1.4.0 8 | golang.org/x/crypto v0.0.0-20200429183012-4b2356b1ed79 9 | golang.org/x/xerrors v0.0.0-20191204190536-9bdfabe68543 10 | ) 11 | -------------------------------------------------------------------------------- /go.sum: -------------------------------------------------------------------------------- 1 | github.com/cenkalti/backoff/v4 v4.0.2 h1:JIufpQLbh4DkbQoii76ItQIUFzevQSqOLZca4eamEDs= 2 | github.com/cenkalti/backoff/v4 v4.0.2/go.mod h1:eEew/i+1Q6OrCDZh3WiXYv3+nJwBASZ8Bog/87DQnVg= 3 | github.com/davecgh/go-spew v1.1.0 h1:ZDRjVQ15GmhC3fiQ8ni8+OwkZQO4DARzQgrnXU1Liz8= 4 | github.com/davecgh/go-spew v1.1.0/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38= 5 | github.com/pmezard/go-difflib v1.0.0 h1:4DBwDE0NGyQoBHbLQYPwSUPoCMWR5BEzIk/f1lZbAQM= 6 | github.com/pmezard/go-difflib v1.0.0/go.mod h1:iKH77koFhYxTK1pcRnkKkqfTogsbg7gZNVY4sRDYZ/4= 7 | github.com/stretchr/objx v0.1.0/go.mod h1:HFkY916IF+rwdDfMAkV7OtwuqBVzrE8GR6GFx+wExME= 8 | github.com/stretchr/testify v1.4.0 h1:2E4SXV/wtOkTonXsotYi4li6zVWxYlZuYNCXe9XRJyk= 9 | github.com/stretchr/testify v1.4.0/go.mod h1:j7eGeouHqKxXV5pUuKE4zz7dFj8WfuZ+81PSLYec5m4= 10 | golang.org/x/crypto v0.0.0-20190308221718-c2843e01d9a2/go.mod h1:djNgcEr1/C05ACkg1iLfiJU5Ep61QUkGW8qpdssI0+w= 11 | golang.org/x/crypto v0.0.0-20200429183012-4b2356b1ed79 h1:IaQbIIB2X/Mp/DKctl6ROxz1KyMlKp4uyvL6+kQ7C88= 12 | golang.org/x/crypto v0.0.0-20200429183012-4b2356b1ed79/go.mod h1:LzIPMQfyMNhhGPhUkYOs5KpL4U8rLKemX1yGLhDgUto= 13 | golang.org/x/net v0.0.0-20190404232315-eb5bcb51f2a3/go.mod h1:t9HGtf8HONx5eT2rtn7q6eTqICYqUVnKs3thJo3Qplg= 14 | golang.org/x/sys v0.0.0-20190215142949-d0b11bdaac8a/go.mod h1:STP8DvDyc/dI5b8T5hshtkjS+E42TnysNCUPdjciGhY= 15 | golang.org/x/sys v0.0.0-20190412213103-97732733099d/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= 16 | golang.org/x/text v0.3.0/go.mod h1:NqM8EUOU14njkJ3fqMW+pc6Ldnwhi/IjpwHt7yyuwOQ= 17 | golang.org/x/xerrors v0.0.0-20191204190536-9bdfabe68543 h1:E7g+9GITq07hpfrRu66IVDexMakfv52eLZ2CXBWiKr4= 18 | golang.org/x/xerrors v0.0.0-20191204190536-9bdfabe68543/go.mod h1:I/5z698sn9Ka8TeJc9MKroUUfqBBauWjQqLJ2OPfmY0= 19 | gopkg.in/check.v1 v0.0.0-20161208181325-20d25e280405 h1:yhCVgyC4o1eVCa2tZl7eS0r+SDo693bJlVdllGtEeKM= 20 | gopkg.in/check.v1 v0.0.0-20161208181325-20d25e280405/go.mod h1:Co6ibVJAznAaIkqp8huTwlJQCZ016jof/cbN4VW5Yz0= 21 | gopkg.in/yaml.v2 v2.2.2 h1:ZCJp+EgiOT7lHqUV2J862kp8Qj64Jo6az82+3Td9dZw= 22 | gopkg.in/yaml.v2 v2.2.2/go.mod h1:hI93XBmqTisBFMUTm0b8Fm+jr3Dg1NNxqwp+5A1VGuI= 23 | -------------------------------------------------------------------------------- /sdk/sdk_test.go: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (C) 2015-2018 Virgil Security Inc. 3 | * 4 | * Lead Maintainer: Virgil Security Inc. 5 | * 6 | * All rights reserved. 7 | * 8 | * Redistribution and use in source and binary forms, with or without 9 | * modification, are permitted provided that the following conditions 10 | * are met: 11 | * 12 | * (1) Redistributions of source code must retain the above copyright 13 | * notice, this list of conditions and the following disclaimer. 14 | * 15 | * (2) Redistributions in binary form must reproduce the above copyright 16 | * notice, this list of conditions and the following disclaimer in 17 | * the documentation and/or other materials provided with the 18 | * distribution. 19 | * 20 | * (3) Neither the name of the copyright holder nor the names of its 21 | * contributors may be used to endorse or promote products derived 22 | * from this software without specific prior written permission. 23 | * 24 | * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ''AS IS'' AND ANY EXPRESS OR 25 | * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED 26 | * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE 27 | * DISCLAIMED. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, 28 | * INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES 29 | * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR 30 | * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) 31 | * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, 32 | * STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING 33 | * IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE 34 | * POSSIBILITY OF SUCH DAMAGE. 35 | * 36 | */ 37 | 38 | package sdk 39 | 40 | import "github.com/VirgilSecurity/virgil-sdk-go/v6/crypto" 41 | 42 | var ( 43 | cryptoNative = &crypto.Crypto{} 44 | ) 45 | -------------------------------------------------------------------------------- /session/accesstoken.go: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (C) 2015-2018 Virgil Security Inc. 3 | * 4 | * Lead Maintainer: Virgil Security Inc. 5 | * 6 | * All rights reserved. 7 | * 8 | * Redistribution and use in source and binary forms, with or without 9 | * modification, are permitted provided that the following conditions 10 | * are met: 11 | * 12 | * (1) Redistributions of source code must retain the above copyright 13 | * notice, this list of conditions and the following disclaimer. 14 | * 15 | * (2) Redistributions in binary form must reproduce the above copyright 16 | * notice, this list of conditions and the following disclaimer in 17 | * the documentation and/or other materials provided with the 18 | * distribution. 19 | * 20 | * (3) Neither the name of the copyright holder nor the names of its 21 | * contributors may be used to endorse or promote products derived 22 | * from this software without specific prior written permission. 23 | * 24 | * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ''AS IS'' AND ANY EXPRESS OR 25 | * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED 26 | * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE 27 | * DISCLAIMED. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, 28 | * INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES 29 | * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR 30 | * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) 31 | * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, 32 | * STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING 33 | * IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE 34 | * POSSIBILITY OF SUCH DAMAGE. 35 | * 36 | */ 37 | 38 | package session 39 | 40 | type AccessToken interface { 41 | String() string 42 | Identity() (string, error) 43 | } 44 | -------------------------------------------------------------------------------- /session/accesstokenprovider.go: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (C) 2015-2018 Virgil Security Inc. 3 | * 4 | * Lead Maintainer: Virgil Security Inc. 5 | * 6 | * All rights reserved. 7 | * 8 | * Redistribution and use in source and binary forms, with or without 9 | * modification, are permitted provided that the following conditions 10 | * are met: 11 | * 12 | * (1) Redistributions of source code must retain the above copyright 13 | * notice, this list of conditions and the following disclaimer. 14 | * 15 | * (2) Redistributions in binary form must reproduce the above copyright 16 | * notice, this list of conditions and the following disclaimer in 17 | * the documentation and/or other materials provided with the 18 | * distribution. 19 | * 20 | * (3) Neither the name of the copyright holder nor the names of its 21 | * contributors may be used to endorse or promote products derived 22 | * from this software without specific prior written permission. 23 | * 24 | * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ''AS IS'' AND ANY EXPRESS OR 25 | * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED 26 | * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE 27 | * DISCLAIMED. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, 28 | * INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES 29 | * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR 30 | * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) 31 | * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, 32 | * STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING 33 | * IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE 34 | * POSSIBILITY OF SUCH DAMAGE. 35 | * 36 | */ 37 | 38 | package session 39 | 40 | type AccessTokenProvider interface { 41 | GetToken(context *TokenContext) (AccessToken, error) 42 | } 43 | 44 | type ConstAccessTokenProvider struct { 45 | AccessToken AccessToken 46 | } 47 | 48 | func (a *ConstAccessTokenProvider) GetToken(context *TokenContext) (AccessToken, error) { 49 | return a.AccessToken, nil 50 | } 51 | -------------------------------------------------------------------------------- /session/errors.go: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (C) 2015-2018 Virgil Security Inc. 3 | * 4 | * Lead Maintainer: Virgil Security Inc. 5 | * 6 | * All rights reserved. 7 | * 8 | * Redistribution and use in source and binary forms, with or without 9 | * modification, are permitted provided that the following conditions 10 | * are met: 11 | * 12 | * (1) Redistributions of source code must retain the above copyright 13 | * notice, this list of conditions and the following disclaimer. 14 | * 15 | * (2) Redistributions in binary form must reproduce the above copyright 16 | * notice, this list of conditions and the following disclaimer in 17 | * the documentation and/or other materials provided with the 18 | * distribution. 19 | * 20 | * (3) Neither the name of the copyright holder nor the names of its 21 | * contributors may be used to endorse or promote products derived 22 | * from this software without specific prior written permission. 23 | * 24 | * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ''AS IS'' AND ANY EXPRESS OR 25 | * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED 26 | * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE 27 | * DISCLAIMED. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, 28 | * INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES 29 | * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR 30 | * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) 31 | * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, 32 | * STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING 33 | * IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE 34 | * POSSIBILITY OF SUCH DAMAGE. 35 | * 36 | */ 37 | 38 | package session 39 | 40 | import "errors" 41 | 42 | var ( 43 | ErrIdentityIsMandatory = errors.New("identity is mandatory") 44 | ErrContextIsMandatory = errors.New("token context is mandatory") 45 | ErrJWTInvalid = errors.New("jwt invalid") 46 | ErrJWTTokenIsMandatory = errors.New("jwt token is mandatory") 47 | ErrJWTExpired = errors.New("jwt token is expired") 48 | ErrJWTParseFailed = errors.New("jwt parse failed") 49 | ErrJWTIncorrect = errors.New("jwt body does not contain virgil prefix") 50 | ) 51 | -------------------------------------------------------------------------------- /session/tokecontext.go: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (C) 2015-2018 Virgil Security Inc. 3 | * 4 | * Lead Maintainer: Virgil Security Inc. 5 | * 6 | * All rights reserved. 7 | * 8 | * Redistribution and use in source and binary forms, with or without 9 | * modification, are permitted provided that the following conditions 10 | * are met: 11 | * 12 | * (1) Redistributions of source code must retain the above copyright 13 | * notice, this list of conditions and the following disclaimer. 14 | * 15 | * (2) Redistributions in binary form must reproduce the above copyright 16 | * notice, this list of conditions and the following disclaimer in 17 | * the documentation and/or other materials provided with the 18 | * distribution. 19 | * 20 | * (3) Neither the name of the copyright holder nor the names of its 21 | * contributors may be used to endorse or promote products derived 22 | * from this software without specific prior written permission. 23 | * 24 | * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ''AS IS'' AND ANY EXPRESS OR 25 | * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED 26 | * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE 27 | * DISCLAIMED. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, 28 | * INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES 29 | * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR 30 | * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) 31 | * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, 32 | * STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING 33 | * IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE 34 | * POSSIBILITY OF SUCH DAMAGE. 35 | * 36 | */ 37 | 38 | package session 39 | 40 | type TokenContext struct { 41 | Identity string 42 | Operation string 43 | Service string 44 | ForceReload bool 45 | } 46 | -------------------------------------------------------------------------------- /storage/storage.go: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (C) 2015-2018 Virgil Security Inc. 3 | * 4 | * Lead Maintainer: Virgil Security Inc. 5 | * 6 | * All rights reserved. 7 | * 8 | * Redistribution and use in source and binary forms, with or without 9 | * modification, are permitted provided that the following conditions 10 | * are met: 11 | * 12 | * (1) Redistributions of source code must retain the above copyright 13 | * notice, this list of conditions and the following disclaimer. 14 | * 15 | * (2) Redistributions in binary form must reproduce the above copyright 16 | * notice, this list of conditions and the following disclaimer in 17 | * the documentation and/or other materials provided with the 18 | * distribution. 19 | * 20 | * (3) Neither the name of the copyright holder nor the names of its 21 | * contributors may be used to endorse or promote products derived 22 | * from this software without specific prior written permission. 23 | * 24 | * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ''AS IS'' AND ANY EXPRESS OR 25 | * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED 26 | * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE 27 | * DISCLAIMED. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, 28 | * INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES 29 | * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR 30 | * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) 31 | * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, 32 | * STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING 33 | * IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE 34 | * POSSIBILITY OF SUCH DAMAGE. 35 | * 36 | */ 37 | 38 | package storage 39 | 40 | import "errors" 41 | 42 | var ( 43 | ErrorKeyAlreadyExists = errors.New("key already exists") 44 | ErrorKeyNotFound = errors.New("key not found") 45 | ) 46 | 47 | type Storage interface { 48 | Store(key string, val []byte) error 49 | Load(key string) ([]byte, error) 50 | Exists(key string) bool 51 | Delete(key string) error 52 | } 53 | -------------------------------------------------------------------------------- /version.go: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (C) 2015-2019 Virgil Security Inc. 3 | * 4 | * Lead Maintainer: Virgil Security Inc. 5 | * 6 | * All rights reserved. 7 | * 8 | * Redistribution and use in source and binary forms, with or without 9 | * modification, are permitted provided that the following conditions 10 | * are met: 11 | * 12 | * (1) Redistributions of source code must retain the above copyright 13 | * notice, this list of conditions and the following disclaimer. 14 | * 15 | * (2) Redistributions in binary form must reproduce the above copyright 16 | * notice, this list of conditions and the following disclaimer in 17 | * the documentation and/or other materials provided with the 18 | * distribution. 19 | * 20 | * (3) Neither the name of the copyright holder nor the names of its 21 | * contributors may be used to endorse or promote products derived 22 | * from this software without specific prior written permission. 23 | * 24 | * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ''AS IS'' AND ANY EXPRESS OR 25 | * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED 26 | * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE 27 | * DISCLAIMED. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, 28 | * INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES 29 | * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR 30 | * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) 31 | * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, 32 | * STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING 33 | * IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE 34 | * POSSIBILITY OF SUCH DAMAGE. 35 | * 36 | */ 37 | 38 | package virgil 39 | 40 | // Version current go sdk version 41 | const Version = "v6.0.14" 42 | --------------------------------------------------------------------------------