Enum lucky_commit::Sha1

source ·
pub enum Sha1 {}
Expand description

The hash type used for Sha1 git repositories (the default at the time of writing) This type is uninhabited, and is only intended to be used as a type parameter.

Trait Implementations§

source§

impl Clone for Sha1

source§

fn clone(&self) -> Sha1

Returns a copy of the value. Read more
1.0.0 · source§

fn clone_from(&mut self, source: &Self)

Performs copy-assignment from source. Read more
source§

impl Debug for Sha1

source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more
source§

impl GitHashFn for Sha1

§

type State = [u32; 5]

The type of the output and intermediate state of this hash function. For sha1 and sha256, this is [u32; N] for some N. Ideally this trait would just have an associated const for the length of the state vector, and then State would be defined as [u32; N], but this isn’t possible due to https://github.com/rust-lang/rust/issues/60551.
source§

const INITIAL_STATE: Self::State = _

The initial value of the state vector for the given algorithm
§

type Block = GenericArray<u8, <Sha1Core as BlockSizeUser>::BlockSize>

The datatype representing a block for this algorithm. This must be layout-equivalent to [u8; 64], although the nominal type that gets used might be different on a per-library basis due to const generic limitations.
source§

fn compress(state: &mut Self::State, blocks: &[Self::Block])

Processes a set of blocks using the given algorithm
source§

const KERNEL: &'static str = "// Note: A lot of code is duplicated between this file and sha256_matcher.cl.\nuint16 arrange_padding_block(ulong padding_specifier, uint4 padding_block_ending);\nvoid sha1_compress(__private uint* h, uint16 w);\n\n__constant uint PADDING_CHUNKS[16] = {\n 0x20202020, 0x20202009, 0x20200920, 0x20200909,\n 0x20092020, 0x20092009, 0x20090920, 0x20090909,\n 0x09202020, 0x09202009, 0x09200920, 0x09200909,\n 0x09092020, 0x09092009, 0x09090920, 0x09090909,\n};\n\n__kernel void scatter_padding_and_find_match(\n __global uint* hash_spec_data,\n __global uint* hash_spec_mask,\n __global uint* h,\n ulong base_padding_specifier,\n __global uint16* dynamic_blocks,\n ulong num_dynamic_blocks,\n __global uint* successful_match_receiver\n) {\n uint finalized_hash[5] = {h[0], h[1], h[2], h[3], h[4]};\n sha1_compress(\n finalized_hash,\n arrange_padding_block(\n base_padding_specifier + get_global_id(0),\n dynamic_blocks[0].sCDEF\n )\n );\n for (size_t i = 1; i < num_dynamic_blocks; i++) {\n sha1_compress(finalized_hash, dynamic_blocks[i]);\n }\n\n if (\n (finalized_hash[0] & hash_spec_mask[0]) == hash_spec_data[0] &&\n (finalized_hash[1] & hash_spec_mask[1]) == hash_spec_data[1] &&\n (finalized_hash[2] & hash_spec_mask[2]) == hash_spec_data[2] &&\n (finalized_hash[3] & hash_spec_mask[3]) == hash_spec_data[3] &&\n (finalized_hash[4] & hash_spec_mask[4]) == hash_spec_data[4]\n ) {\n atomic_cmpxchg(successful_match_receiver, UINT_MAX, get_global_id(0));\n }\n}\n\nuint16 arrange_padding_block(ulong padding_specifier, uint4 padding_block_ending) {\n return (uint16)(\n PADDING_CHUNKS[(padding_specifier >> 4) & 0xf],\n PADDING_CHUNKS[(padding_specifier >> 0) & 0xf],\n PADDING_CHUNKS[(padding_specifier >> 12) & 0xf],\n PADDING_CHUNKS[(padding_specifier >> 8) & 0xf],\n PADDING_CHUNKS[(padding_specifier >> 20) & 0xf],\n PADDING_CHUNKS[(padding_specifier >> 16) & 0xf],\n PADDING_CHUNKS[(padding_specifier >> 28) & 0xf],\n PADDING_CHUNKS[(padding_specifier >> 24) & 0xf],\n PADDING_CHUNKS[(padding_specifier >> 36) & 0xf],\n PADDING_CHUNKS[(padding_specifier >> 32) & 0xf],\n PADDING_CHUNKS[(padding_specifier >> 44) & 0xf],\n PADDING_CHUNKS[(padding_specifier >> 40) & 0xf],\n padding_block_ending.s0,\n padding_block_ending.s1,\n padding_block_ending.s2,\n padding_block_ending.s3\n );\n}\n\n/*\nThe sha1 implementation below is mostly adapted from hashcat (https://hashcat.net/hashcat).\n\nThe MIT License (MIT)\n\nCopyright (c) 2015-2020 Jens Steube\n\nPermission is hereby granted, free of charge, to any person obtaining a copy\nof this software and associated documentation files (the \"Software\"), to deal\nin the Software without restriction, including without limitation the rights\nto use, copy, modify, merge, publish, distribute, sublicense, and/or sell\ncopies of the Software, and to permit persons to whom the Software is\nfurnished to do so, subject to the following conditions:\n\nThe above copyright notice and this permission notice shall be included in all\ncopies or substantial portions of the Software.\n\nTHE SOFTWARE IS PROVIDED \"AS IS\", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR\nIMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,\nFITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE\nAUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER\nLIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,\nOUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE\nSOFTWARE.\n*/\n\n#define SHA1_F1(x,y,z) ((x) ^ (y) ^ (z))\n#define SHA1_F0o(x,y,z) (bitselect((z), (y), (x)))\n#define SHA1_F2o(x,y,z) (bitselect((x), (y), ((x) ^ (z))))\n\n#define SHA1_STEP_S(f,a,b,c,d,e,x) \\\n{ \\\n e += x + f(b, c, d) + K + rotate(a, 5u); \\\n b = rotate(b, 30u); \\\n}\n\nvoid sha1_compress(__private uint* h, uint16 w) {\n uint a = h[0];\n uint b = h[1];\n uint c = h[2];\n uint d = h[3];\n uint e = h[4];\n\n uint w0_t = w.s0;\n uint w1_t = w.s1;\n uint w2_t = w.s2;\n uint w3_t = w.s3;\n uint w4_t = w.s4;\n uint w5_t = w.s5;\n uint w6_t = w.s6;\n uint w7_t = w.s7;\n uint w8_t = w.s8;\n uint w9_t = w.s9;\n uint wa_t = w.sA;\n uint wb_t = w.sB;\n uint wc_t = w.sC;\n uint wd_t = w.sD;\n uint we_t = w.sE;\n uint wf_t = w.sF;\n\n #define K 0x5a827999\n\n SHA1_STEP_S(SHA1_F0o, a, b, c, d, e, w0_t);\n SHA1_STEP_S(SHA1_F0o, e, a, b, c, d, w1_t);\n SHA1_STEP_S(SHA1_F0o, d, e, a, b, c, w2_t);\n SHA1_STEP_S(SHA1_F0o, c, d, e, a, b, w3_t);\n SHA1_STEP_S(SHA1_F0o, b, c, d, e, a, w4_t);\n SHA1_STEP_S(SHA1_F0o, a, b, c, d, e, w5_t);\n SHA1_STEP_S(SHA1_F0o, e, a, b, c, d, w6_t);\n SHA1_STEP_S(SHA1_F0o, d, e, a, b, c, w7_t);\n SHA1_STEP_S(SHA1_F0o, c, d, e, a, b, w8_t);\n SHA1_STEP_S(SHA1_F0o, b, c, d, e, a, w9_t);\n SHA1_STEP_S(SHA1_F0o, a, b, c, d, e, wa_t);\n SHA1_STEP_S(SHA1_F0o, e, a, b, c, d, wb_t);\n SHA1_STEP_S(SHA1_F0o, d, e, a, b, c, wc_t);\n SHA1_STEP_S(SHA1_F0o, c, d, e, a, b, wd_t);\n SHA1_STEP_S(SHA1_F0o, b, c, d, e, a, we_t);\n SHA1_STEP_S(SHA1_F0o, a, b, c, d, e, wf_t);\n w0_t = rotate((wd_t ^ w8_t ^ w2_t ^ w0_t), 1u); SHA1_STEP_S(SHA1_F0o, e, a, b, c, d, w0_t);\n w1_t = rotate((we_t ^ w9_t ^ w3_t ^ w1_t), 1u); SHA1_STEP_S(SHA1_F0o, d, e, a, b, c, w1_t);\n w2_t = rotate((wf_t ^ wa_t ^ w4_t ^ w2_t), 1u); SHA1_STEP_S(SHA1_F0o, c, d, e, a, b, w2_t);\n w3_t = rotate((w0_t ^ wb_t ^ w5_t ^ w3_t), 1u); SHA1_STEP_S(SHA1_F0o, b, c, d, e, a, w3_t);\n\n #undef K\n #define K 0x6ed9eba1\n\n w4_t = rotate((w1_t ^ wc_t ^ w6_t ^ w4_t), 1u); SHA1_STEP_S(SHA1_F1, a, b, c, d, e, w4_t);\n w5_t = rotate((w2_t ^ wd_t ^ w7_t ^ w5_t), 1u); SHA1_STEP_S(SHA1_F1, e, a, b, c, d, w5_t);\n w6_t = rotate((w3_t ^ we_t ^ w8_t ^ w6_t), 1u); SHA1_STEP_S(SHA1_F1, d, e, a, b, c, w6_t);\n w7_t = rotate((w4_t ^ wf_t ^ w9_t ^ w7_t), 1u); SHA1_STEP_S(SHA1_F1, c, d, e, a, b, w7_t);\n w8_t = rotate((w5_t ^ w0_t ^ wa_t ^ w8_t), 1u); SHA1_STEP_S(SHA1_F1, b, c, d, e, a, w8_t);\n w9_t = rotate((w6_t ^ w1_t ^ wb_t ^ w9_t), 1u); SHA1_STEP_S(SHA1_F1, a, b, c, d, e, w9_t);\n wa_t = rotate((w7_t ^ w2_t ^ wc_t ^ wa_t), 1u); SHA1_STEP_S(SHA1_F1, e, a, b, c, d, wa_t);\n wb_t = rotate((w8_t ^ w3_t ^ wd_t ^ wb_t), 1u); SHA1_STEP_S(SHA1_F1, d, e, a, b, c, wb_t);\n wc_t = rotate((w9_t ^ w4_t ^ we_t ^ wc_t), 1u); SHA1_STEP_S(SHA1_F1, c, d, e, a, b, wc_t);\n wd_t = rotate((wa_t ^ w5_t ^ wf_t ^ wd_t), 1u); SHA1_STEP_S(SHA1_F1, b, c, d, e, a, wd_t);\n we_t = rotate((wb_t ^ w6_t ^ w0_t ^ we_t), 1u); SHA1_STEP_S(SHA1_F1, a, b, c, d, e, we_t);\n wf_t = rotate((wc_t ^ w7_t ^ w1_t ^ wf_t), 1u); SHA1_STEP_S(SHA1_F1, e, a, b, c, d, wf_t);\n w0_t = rotate((wd_t ^ w8_t ^ w2_t ^ w0_t), 1u); SHA1_STEP_S(SHA1_F1, d, e, a, b, c, w0_t);\n w1_t = rotate((we_t ^ w9_t ^ w3_t ^ w1_t), 1u); SHA1_STEP_S(SHA1_F1, c, d, e, a, b, w1_t);\n w2_t = rotate((wf_t ^ wa_t ^ w4_t ^ w2_t), 1u); SHA1_STEP_S(SHA1_F1, b, c, d, e, a, w2_t);\n w3_t = rotate((w0_t ^ wb_t ^ w5_t ^ w3_t), 1u); SHA1_STEP_S(SHA1_F1, a, b, c, d, e, w3_t);\n w4_t = rotate((w1_t ^ wc_t ^ w6_t ^ w4_t), 1u); SHA1_STEP_S(SHA1_F1, e, a, b, c, d, w4_t);\n w5_t = rotate((w2_t ^ wd_t ^ w7_t ^ w5_t), 1u); SHA1_STEP_S(SHA1_F1, d, e, a, b, c, w5_t);\n w6_t = rotate((w3_t ^ we_t ^ w8_t ^ w6_t), 1u); SHA1_STEP_S(SHA1_F1, c, d, e, a, b, w6_t);\n w7_t = rotate((w4_t ^ wf_t ^ w9_t ^ w7_t), 1u); SHA1_STEP_S(SHA1_F1, b, c, d, e, a, w7_t);\n\n #undef K\n #define K 0x8f1bbcdc\n\n w8_t = rotate((w5_t ^ w0_t ^ wa_t ^ w8_t), 1u); SHA1_STEP_S(SHA1_F2o, a, b, c, d, e, w8_t);\n w9_t = rotate((w6_t ^ w1_t ^ wb_t ^ w9_t), 1u); SHA1_STEP_S(SHA1_F2o, e, a, b, c, d, w9_t);\n wa_t = rotate((w7_t ^ w2_t ^ wc_t ^ wa_t), 1u); SHA1_STEP_S(SHA1_F2o, d, e, a, b, c, wa_t);\n wb_t = rotate((w8_t ^ w3_t ^ wd_t ^ wb_t), 1u); SHA1_STEP_S(SHA1_F2o, c, d, e, a, b, wb_t);\n wc_t = rotate((w9_t ^ w4_t ^ we_t ^ wc_t), 1u); SHA1_STEP_S(SHA1_F2o, b, c, d, e, a, wc_t);\n wd_t = rotate((wa_t ^ w5_t ^ wf_t ^ wd_t), 1u); SHA1_STEP_S(SHA1_F2o, a, b, c, d, e, wd_t);\n we_t = rotate((wb_t ^ w6_t ^ w0_t ^ we_t), 1u); SHA1_STEP_S(SHA1_F2o, e, a, b, c, d, we_t);\n wf_t = rotate((wc_t ^ w7_t ^ w1_t ^ wf_t), 1u); SHA1_STEP_S(SHA1_F2o, d, e, a, b, c, wf_t);\n w0_t = rotate((wd_t ^ w8_t ^ w2_t ^ w0_t), 1u); SHA1_STEP_S(SHA1_F2o, c, d, e, a, b, w0_t);\n w1_t = rotate((we_t ^ w9_t ^ w3_t ^ w1_t), 1u); SHA1_STEP_S(SHA1_F2o, b, c, d, e, a, w1_t);\n w2_t = rotate((wf_t ^ wa_t ^ w4_t ^ w2_t), 1u); SHA1_STEP_S(SHA1_F2o, a, b, c, d, e, w2_t);\n w3_t = rotate((w0_t ^ wb_t ^ w5_t ^ w3_t), 1u); SHA1_STEP_S(SHA1_F2o, e, a, b, c, d, w3_t);\n w4_t = rotate((w1_t ^ wc_t ^ w6_t ^ w4_t), 1u); SHA1_STEP_S(SHA1_F2o, d, e, a, b, c, w4_t);\n w5_t = rotate((w2_t ^ wd_t ^ w7_t ^ w5_t), 1u); SHA1_STEP_S(SHA1_F2o, c, d, e, a, b, w5_t);\n w6_t = rotate((w3_t ^ we_t ^ w8_t ^ w6_t), 1u); SHA1_STEP_S(SHA1_F2o, b, c, d, e, a, w6_t);\n w7_t = rotate((w4_t ^ wf_t ^ w9_t ^ w7_t), 1u); SHA1_STEP_S(SHA1_F2o, a, b, c, d, e, w7_t);\n w8_t = rotate((w5_t ^ w0_t ^ wa_t ^ w8_t), 1u); SHA1_STEP_S(SHA1_F2o, e, a, b, c, d, w8_t);\n w9_t = rotate((w6_t ^ w1_t ^ wb_t ^ w9_t), 1u); SHA1_STEP_S(SHA1_F2o, d, e, a, b, c, w9_t);\n wa_t = rotate((w7_t ^ w2_t ^ wc_t ^ wa_t), 1u); SHA1_STEP_S(SHA1_F2o, c, d, e, a, b, wa_t);\n wb_t = rotate((w8_t ^ w3_t ^ wd_t ^ wb_t), 1u); SHA1_STEP_S(SHA1_F2o, b, c, d, e, a, wb_t);\n\n #undef K\n #define K 0xca62c1d6\n\n wc_t = rotate((w9_t ^ w4_t ^ we_t ^ wc_t), 1u); SHA1_STEP_S(SHA1_F1, a, b, c, d, e, wc_t);\n wd_t = rotate((wa_t ^ w5_t ^ wf_t ^ wd_t), 1u); SHA1_STEP_S(SHA1_F1, e, a, b, c, d, wd_t);\n we_t = rotate((wb_t ^ w6_t ^ w0_t ^ we_t), 1u); SHA1_STEP_S(SHA1_F1, d, e, a, b, c, we_t);\n wf_t = rotate((wc_t ^ w7_t ^ w1_t ^ wf_t), 1u); SHA1_STEP_S(SHA1_F1, c, d, e, a, b, wf_t);\n w0_t = rotate((wd_t ^ w8_t ^ w2_t ^ w0_t), 1u); SHA1_STEP_S(SHA1_F1, b, c, d, e, a, w0_t);\n w1_t = rotate((we_t ^ w9_t ^ w3_t ^ w1_t), 1u); SHA1_STEP_S(SHA1_F1, a, b, c, d, e, w1_t);\n w2_t = rotate((wf_t ^ wa_t ^ w4_t ^ w2_t), 1u); SHA1_STEP_S(SHA1_F1, e, a, b, c, d, w2_t);\n w3_t = rotate((w0_t ^ wb_t ^ w5_t ^ w3_t), 1u); SHA1_STEP_S(SHA1_F1, d, e, a, b, c, w3_t);\n w4_t = rotate((w1_t ^ wc_t ^ w6_t ^ w4_t), 1u); SHA1_STEP_S(SHA1_F1, c, d, e, a, b, w4_t);\n w5_t = rotate((w2_t ^ wd_t ^ w7_t ^ w5_t), 1u); SHA1_STEP_S(SHA1_F1, b, c, d, e, a, w5_t);\n w6_t = rotate((w3_t ^ we_t ^ w8_t ^ w6_t), 1u); SHA1_STEP_S(SHA1_F1, a, b, c, d, e, w6_t);\n w7_t = rotate((w4_t ^ wf_t ^ w9_t ^ w7_t), 1u); SHA1_STEP_S(SHA1_F1, e, a, b, c, d, w7_t);\n w8_t = rotate((w5_t ^ w0_t ^ wa_t ^ w8_t), 1u); SHA1_STEP_S(SHA1_F1, d, e, a, b, c, w8_t);\n w9_t = rotate((w6_t ^ w1_t ^ wb_t ^ w9_t), 1u); SHA1_STEP_S(SHA1_F1, c, d, e, a, b, w9_t);\n wa_t = rotate((w7_t ^ w2_t ^ wc_t ^ wa_t), 1u); SHA1_STEP_S(SHA1_F1, b, c, d, e, a, wa_t);\n wb_t = rotate((w8_t ^ w3_t ^ wd_t ^ wb_t), 1u); SHA1_STEP_S(SHA1_F1, a, b, c, d, e, wb_t);\n wc_t = rotate((w9_t ^ w4_t ^ we_t ^ wc_t), 1u); SHA1_STEP_S(SHA1_F1, e, a, b, c, d, wc_t);\n wd_t = rotate((wa_t ^ w5_t ^ wf_t ^ wd_t), 1u); SHA1_STEP_S(SHA1_F1, d, e, a, b, c, wd_t);\n we_t = rotate((wb_t ^ w6_t ^ w0_t ^ we_t), 1u); SHA1_STEP_S(SHA1_F1, c, d, e, a, b, we_t);\n wf_t = rotate((wc_t ^ w7_t ^ w1_t ^ wf_t), 1u); SHA1_STEP_S(SHA1_F1, b, c, d, e, a, wf_t);\n\n #undef K\n\n h[0] += a;\n h[1] += b;\n h[2] += c;\n h[3] += d;\n h[4] += e;\n}\n"

Source code of an OpenCL shader kernel finding hash matches for the given algorithm. The kernel should have a function scatter_padding_and_find_match, which accepts the following parameters: Read more
source§

impl PartialEq for Sha1

source§

fn eq(&self, other: &Sha1) -> bool

This method tests for self and other values to be equal, and is used by ==.
1.0.0 · source§

fn ne(&self, other: &Rhs) -> bool

This method tests for !=. The default implementation is almost always sufficient, and should not be overridden without very good reason.
source§

impl Eq for Sha1

source§

impl StructuralPartialEq for Sha1

Auto Trait Implementations§

§

impl Freeze for Sha1

§

impl RefUnwindSafe for Sha1

§

impl Send for Sha1

§

impl Sync for Sha1

§

impl Unpin for Sha1

§

impl UnwindSafe for Sha1

Blanket Implementations§

source§

impl<T> Any for T
where T: 'static + ?Sized,

source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
source§

impl<T> Borrow<T> for T
where T: ?Sized,

source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
source§

impl<T> From<T> for T

source§

fn from(t: T) -> T

Returns the argument unchanged.

source§

impl<T, U> Into<U> for T
where U: From<T>,

source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

source§

impl<T> Pointable for T

source§

const ALIGN: usize = _

The alignment of pointer.
§

type Init = T

The type for initializers.
source§

unsafe fn init(init: <T as Pointable>::Init) -> usize

Initializes a with the given initializer. Read more
source§

unsafe fn deref<'a>(ptr: usize) -> &'a T

Dereferences the given pointer. Read more
source§

unsafe fn deref_mut<'a>(ptr: usize) -> &'a mut T

Mutably dereferences the given pointer. Read more
source§

unsafe fn drop(ptr: usize)

Drops the object pointed to by the given pointer. Read more
source§

impl<T> Same for T

§

type Output = T

Should always be Self
source§

impl<T> ToOwned for T
where T: Clone,

§

type Owned = T

The resulting type after obtaining ownership.
source§

fn to_owned(&self) -> T

Creates owned data from borrowed data, usually by cloning. Read more
source§

fn clone_into(&self, target: &mut T)

Uses borrowed data to replace owned data, usually by cloning. Read more
source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

§

type Error = Infallible

The type returned in the event of a conversion error.
source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.