~/bend-docscommunity

rsa.bend checks

raw source on the hub · import element-crypto@0.1.0.0/rsa.bend as Rsa

3 imports
import Base
import element-math@0.1.0.0/big.bend as Big
import ./hash.bend as Hash

Definitions

def drop_zeros source · line 10 · raw

@bs:List<&2, U32> -> List<&2, U32>

def all_zero source · line 17 · raw

@bs:List<&2, U32> -> Bool

def same source · line 20 · raw

@+a:List<&2, U32> -> @+b:List<&2, U32> -> Bool

def len source · line 23 · raw

@+bs:List<&2, U32> -> Nat

def fill source · line 26 · raw

@n:Nat -> @+v:U32 -> List<&2, U32>

def open_with source · line 34 · raw

@ok:Bool -> @+n:List<&2, U32> -> @+e:List<&2, U32> -> @+s:List<&2, U32> -> List<&2, U32>

s^e mod n as |n| bytes, or Nil when s has the wrong length or is not below n.

def open source · line 41 · raw

@+n0:List<&2, U32> -> @+e:List<&2, U32> -> @+s:List<&2, U32> -> List<&2, U32>

def expected source · line 48 · raw

@+h:0x29d6f1ff259add9ea6c8f213fda12377/hash.Hash -> @+k:Nat -> @+msg:List<&2, U32> -> List<&2, U32>

EM = 00 01 FF..FF 00 DigestInfo H, at least 8 bytes of FF.

def pkcs1_verify source · line 52 · raw

@+h:0x29d6f1ff259add9ea6c8f213fda12377/hash.Hash -> @+n:List<&2, U32> -> @+e:List<&2, U32> -> @+sig:List<&2, U32> -> @+msg:List<&2, U32> -> Bool

def be32 source · line 59 · raw

@+x:U32 -> List<&2, U32>

def mgf_go source · line 62 · raw

@c:Nat -> @+h:0x29d6f1ff259add9ea6c8f213fda12377/hash.Hash -> @+seed:List<&2, U32> -> @+i:U32 -> List<&2, U32>

def mgf1 source · line 70 · raw

@+h:0x29d6f1ff259add9ea6c8f213fda12377/hash.Hash -> @+seed:List<&2, U32> -> @+n:Nat -> List<&2, U32>

MGF1 (B.2.1): the first n bytes of Hash(seed || counter) for counter 0, 1, ...

def xor_with source · line 73 · raw

@a:List<&2, U32> -> @b:List<&2, U32> -> List<&2, U32>

def top_bits source · line 80 · raw

@c:Nat -> @+b:U32 -> Nat

def bit_length source · line 88 · raw

@+n:List<&2, U32> -> Nat

Bits in n, from its big-endian bytes with leading zeros dropped.

def first source · line 91 · raw

@+bs:List<&2, U32> -> U32

def last source · line 94 · raw

@+bs:List<&2, U32> -> U32

def head_masked source · line 97 · raw

@bs:List<&2, U32> -> @+keep:U32 -> List<&2, U32>

def pss_check source · line 105 · raw

@+h:0x29d6f1ff259add9ea6c8f213fda12377/hash.Hash -> @+em:List<&2, U32> -> @+em_len:Nat -> @+zbits:Nat -> @+msg:List<&2, U32> -> Bool

EM is emLen bytes; the leftmost 8 emLen - emBits bits must be zero.

def pss_verify source · line 118 · raw

@+h:0x29d6f1ff259add9ea6c8f213fda12377/hash.Hash -> @+n0:List<&2, U32> -> @+e:List<&2, U32> -> @+sig:List<&2, U32> -> @+msg:List<&2, U32> -> Bool