add sha256 syscall (#12569)
This commit is contained in:
26
programs/bpf/rust/sha256/Cargo.toml
Normal file
26
programs/bpf/rust/sha256/Cargo.toml
Normal file
@ -0,0 +1,26 @@
|
||||
|
||||
# Note: This crate must be built using do.sh
|
||||
|
||||
[package]
|
||||
name = "solana-bpf-rust-sha256"
|
||||
version = "1.4.0"
|
||||
description = "Solana BPF test program written in Rust"
|
||||
authors = ["Solana Maintainers <maintainers@solana.foundation>"]
|
||||
repository = "https://github.com/solana-labs/solana"
|
||||
license = "Apache-2.0"
|
||||
homepage = "https://solana.com/"
|
||||
edition = "2018"
|
||||
|
||||
[dependencies]
|
||||
solana-sdk = { path = "../../../../sdk/", version = "1.4.0", default-features = false }
|
||||
|
||||
[features]
|
||||
program = ["solana-sdk/program"]
|
||||
default = ["program", "solana-sdk/default"]
|
||||
|
||||
[lib]
|
||||
name = "solana_bpf_rust_sha256"
|
||||
crate-type = ["cdylib"]
|
||||
|
||||
[package.metadata.docs.rs]
|
||||
targets = ["x86_64-unknown-linux-gnu"]
|
2
programs/bpf/rust/sha256/Xargo.toml
Normal file
2
programs/bpf/rust/sha256/Xargo.toml
Normal file
@ -0,0 +1,2 @@
|
||||
[target.bpfel-unknown-unknown.dependencies.std]
|
||||
features = []
|
19
programs/bpf/rust/sha256/src/lib.rs
Normal file
19
programs/bpf/rust/sha256/src/lib.rs
Normal file
@ -0,0 +1,19 @@
|
||||
//! @brief SHA256 Syscall test
|
||||
|
||||
extern crate solana_sdk;
|
||||
use solana_sdk::{
|
||||
hash::{hashv, Hasher},
|
||||
info,
|
||||
};
|
||||
|
||||
#[no_mangle]
|
||||
pub extern "C" fn entrypoint(_input: *mut u8) -> u64 {
|
||||
info!("sha256");
|
||||
|
||||
let vals = &["Gaggablaghblagh!".as_ref(), "flurbos".as_ref()];
|
||||
let mut hasher = Hasher::default();
|
||||
hasher.hashv(vals);
|
||||
assert_eq!(hashv(vals), hasher.result());
|
||||
|
||||
0
|
||||
}
|
Reference in New Issue
Block a user