assh/assh_bignum.h header reference

Description [link] 

The big number computations in libassh are expressed using a dedicated bytecode. A big number module is in charge of executing this bytecode.

Header inclusion [link] 

Members [link] 

Types [link] 

Functions [link] 

  • size_t assh_bignum_bits(const struct assh_bignum_s *bn)
  • assh_status_t assh_bignum_bytecode(struct assh_context_s *c, uint8_t cond, const assh_bignum_op_t *ops, const char *format, ...)
  • assh_status_t assh_bignum_bytecode_valist(struct assh_context_s *c, uint8_t cond, const assh_bignum_op_t *ops, const char *format, va_list ap)
  • assh_status_t assh_bignum_convert(struct assh_context_s *c, enum assh_bignum_fmt_e src_fmt, enum assh_bignum_fmt_e dst_fmt, const void *src, void *dst, uint8_t **next, assh_bool_t dst_secret)
  • void assh_bignum_init(struct assh_context_s *c, struct assh_bignum_s *bn, size_t bits)
  • assh_bool_t assh_bignum_isempty(const struct assh_bignum_s *bn)
  • void assh_bignum_release(struct assh_context_s *ctx, struct assh_bignum_s *bn)
  • size_t assh_bignum_size_of_bits(enum assh_bignum_fmt_e dst_fmt, size_t bits)
  • assh_status_t assh_bignum_size_of_data(enum assh_bignum_fmt_e fmt, const void *data, size_t *size, size_t *val_size, size_t *bits)
  • size_t assh_bignum_size_of_num(enum assh_bignum_fmt_e dst_fmt, const struct assh_bignum_s *bn)

Macros [link] 

Bytecode instructions [link] 

Members detail [link] 

enum assh_bignum_bool_op [link] 

This enum is declared in assh/assh_bignum.h source file, line 651.

specify boolean operations for use with ASSH_BOP_BOOL

IdentifierValueDescription
ASSH_BOP_BOOL_AND0
ASSH_BOP_BOOL_OR1
ASSH_BOP_BOOL_XOR2
ASSH_BOP_BOOL_ANDN3
ASSH_BOP_BOOL_NAND4
ASSH_BOP_BOOL_NOR5
ASSH_BOP_BOOL_NXOR6
ASSH_BOP_BOOL_NANDN7

#define ASSH_BOP_ADD(dst, src1, src2) [link] 

This macro is for internal use only.

This macro is declared in assh/assh_bignum.h source file, line 411.

This instruction computes dst = (src1 + src2) in constant time. The bit size of the destination number must be max(bits(src1), bits(src2)) or larger.

This macro expands to:

#define ASSH_BOP_ADDM(dst, src1, src2, mod) [link] 

This macro is for internal use only.

This macro is declared in assh/assh_bignum.h source file, line 398.

This instruction computes dst = (src1 + src2) % mod in constant time. The bit size of the destination number must be max(bits(src1), bits(src2)) or larger. The mod must be a montgomery context.

This macro expands to:

ASSH_BOP_FMT4(ASSH_BIGNUM_OP_ADD, dst, src1, src2, mod)

#define ASSH_BOP_BOOL(conddst, condsrc1, condsrc2, boolop) [link] 

This macro is for internal use only.

This macro is declared in assh/assh_bignum.h source file, line 664.

This instructions performs the specified boolean operation on condition flags.

This macro expands to:

ASSH_BOP_FMT4(ASSH_BIGNUM_OP_BOOL, conddst, condsrc1, condsrc2, boolop)

See also enum assh_bignum_bool_op.

#define ASSH_BOP_CFAIL(inv, condid) [link] 

This macro is for internal use only.

This macro is declared in assh/assh_bignum.h source file, line 555.

This instruction abort bytecode execution with an error if the condition flag is different from inv.

This macro expands to:

#define ASSH_BOP_CJMP(pcdiff, inv, condid) [link] 

This macro is for internal use only.

This macro is declared in assh/assh_bignum.h source file, line 549.

This instruction jump to a different bytecode location if the condition flag is different from inv.

This macro expands to:

ASSH_BOP_FMT4(ASSH_BIGNUM_OP_JMP, condid, 0, 128 + pcdiff, inv)

#define ASSH_BOP_CMOVE(dst, src, inv, condid) [link] 

This macro is for internal use only.

This macro is declared in assh/assh_bignum.h source file, line 596.

This instruction performs a conditional move in constant time depending on the condition flag.

This macro expands to:

ASSH_BOP_FMT4(ASSH_BIGNUM_OP_CMOVE, condid, dst, src, inv)

#define ASSH_BOP_CMPEQ(src1, src2, condid) [link] 

This macro is for internal use only.

This macro is declared in assh/assh_bignum.h source file, line 514.

This instruction performs a comparison in constant time and updates the condition flag. It can be used with values of different bit length. It is possible to test if an struct assh_bignum_s object is empty by comparing against ASSH_BOP_NOREG.

This macro expands to:

ASSH_BOP_FMT4(ASSH_BIGNUM_OP_CMP, condid, src1, src2, 0)

#define ASSH_BOP_CMPGT(src1, src2, condid) [link] 

This macro is for internal use only.

This macro is declared in assh/assh_bignum.h source file, line 524.

This instruction is similar to ASSH_BOP_CMPEQ.

This macro expands to:

ASSH_BOP_FMT4(ASSH_BIGNUM_OP_CMP, condid, src2, src1, 1)

#define ASSH_BOP_CMPGTEQ(src1, src2, condid) [link] 

This macro is for internal use only.

This macro is declared in assh/assh_bignum.h source file, line 534.

This instruction is similar to ASSH_BOP_CMPEQ.

This macro expands to:

ASSH_BOP_FMT4(ASSH_BIGNUM_OP_CMP, condid, src2, src1, 2)

#define ASSH_BOP_CMPLT(src1, src2, condid) [link] 

This macro is for internal use only.

This macro is declared in assh/assh_bignum.h source file, line 519.

This instruction is similar to ASSH_BOP_CMPEQ.

This macro expands to:

ASSH_BOP_FMT4(ASSH_BIGNUM_OP_CMP, condid, src1, src2, 1)

#define ASSH_BOP_CMPLTEQ(src1, src2, condid) [link] 

This macro is for internal use only.

This macro is declared in assh/assh_bignum.h source file, line 529.

This instruction is similar to ASSH_BOP_CMPEQ.

This macro expands to:

ASSH_BOP_FMT4(ASSH_BIGNUM_OP_CMP, condid, src1, src2, 2)

#define ASSH_BOP_CSWAP(src1, src2, inv, condid) [link] 

This macro is for internal use only.

This macro is declared in assh/assh_bignum.h source file, line 590.

This instruction performs a conditional swap in constant time between two values depending on the condition flag.

This macro expands to:

ASSH_BOP_FMT4(ASSH_BIGNUM_OP_CSWAP, condid, src1, src2, inv)

#define ASSH_BOP_DIV(dst, src1, src2) [link] 

This macro is for internal use only.

This macro is declared in assh/assh_bignum.h source file, line 459.

This instruction computes dst2 = src1 / src2.

This macro expands to:

See also ASSH_BOP_DIVMOD.

#define ASSH_BOP_DIVMOD(dstq, dstr, src1, src2) [link] 

This macro is for internal use only.

This macro is declared in assh/assh_bignum.h source file, line 446.

This instruction computes dst2 = src1 % src2 and dst1 = src1 / src2.

When a secret number is involved, the constant time algorithm used only yields a correct result if the most significant bit of src2 is set.

This macro expands to:

ASSH_BOP_FMT4(ASSH_BIGNUM_OP_DIV, dstq, dstr, src1, src2)

See also ASSH_BOP_MOD and ASSH_BOP_DIV.

#define ASSH_BOP_END() [link] 

This macro is for internal use only.

This macro is declared in assh/assh_bignum.h source file, line 315.

This instruction terminates execution of the bytecode. It must be used only once as the last instruction of the program.

This macro expands to:

#define ASSH_BOP_EXPM(dst, src1, src2, mod) [link] 

This macro is for internal use only.

This macro is declared in assh/assh_bignum.h source file, line 473.

This instruction computes dst = (src1 ^ src2) % mod. The mod operand must be a montgomery context. The src1 and dst operands are montgomery numbers and their bit size must match the size of the montgomery context.

This macro expands to:

ASSH_BOP_FMT4(ASSH_BIGNUM_OP_EXPM, dst, src1, src2, mod)

See also ASSH_BOP_EXPM.

#define ASSH_BOP_FMT1(op, d) [link] 

This macro is for internal use only.

This macro is declared in assh/assh_bignum.h source file, line 72.

This macro generates bytecode instruction format 1

This macro expands to:

(((op) << 26) | (d))

#define ASSH_BOP_FMT2(op, c, d) [link] 

This macro is for internal use only.

This macro is declared in assh/assh_bignum.h source file, line 70.

This macro generates bytecode instruction format 2

This macro expands to:

(((op) << 26) | ((c) << 6) | (d))

#define ASSH_BOP_FMT3(op, b, c, d) [link] 

This macro is for internal use only.

This macro is declared in assh/assh_bignum.h source file, line 68.

This macro generates bytecode instruction format 3

This macro expands to:

(((op) << 26) | ((b) << 14) | ((c) << 6) | (d))

#define ASSH_BOP_FMT4(op, a, b, c, d) [link] 

This macro is for internal use only.

This macro is declared in assh/assh_bignum.h source file, line 66.

This macro generates bytecode instruction format 4

This macro expands to:

(((op) << 26) | ((a) << 20) | ((b) << 14) | ((c) << 6) | (d))

#define ASSH_BOP_GCD(dst, src1, src2) [link] 

This macro is for internal use only.

This macro is declared in assh/assh_bignum.h source file, line 464.

This instruction computes dst = gcd(src1, src2).

This macro expands to:

#define ASSH_BOP_INV(dst, src1, src2) [link] 

This macro is for internal use only.

This macro is declared in assh/assh_bignum.h source file, line 481.

This instruction computes dst = invmod(src1, src2). If src2 is a montgomery context, the modulus must be prime as the operation is performed in constant time using the Fermat little theorem.

This macro expands to:

#define ASSH_BOP_ISPRIME(src, rounds, condid) [link] 

This macro is for internal use only.

This macro is declared in assh/assh_bignum.h source file, line 640.

This instruction updates the condition flag. It is set if the number is a prime greater than 2. Seven miller rabin rounds are enough for values picked at random. The number of rounds for values of unknown origin is greater and depends on the required probability.

This macro expands to:

ASSH_BOP_FMT3(ASSH_BIGNUM_OP_ISPRIME, condid, rounds, src)

#define ASSH_BOP_ISTRIVIAL(src, condid) [link] 

This macro is for internal use only.

This macro is declared in assh/assh_bignum.h source file, line 645.

This instruction updates the condition flag. It is set if the number has a small prime factor.

This macro expands to:

#define ASSH_BOP_JMP(pcdiff) [link] 

This macro is for internal use only.

This macro is declared in assh/assh_bignum.h source file, line 539.

This instruction jump to a different bytecode location.

This macro expands to:

ASSH_BOP_FMT4(ASSH_BIGNUM_OP_JMP, 0, 1, 128 + pcdiff, 0)

#define ASSH_BOP_LADINIT(src) [link] 

This macro is for internal use only.

This macro is declared in assh/assh_bignum.h source file, line 602.

This instruction initialize the ladder bit index to bits(src)-1.

This macro expands to:

#define ASSH_BOP_LADNEXT(condid) [link] 

This macro is for internal use only.

This macro is declared in assh/assh_bignum.h source file, line 614.

This instruction decrements the current ladder bit index and set the condition flag if the new index value is 0.

This macro expands to:

#define ASSH_BOP_LADTEST(src, condid) [link] 

This macro is for internal use only.

This macro is declared in assh/assh_bignum.h source file, line 608.

This instruction upadates the condition flag according to the bit in source number selected by the current ladder index.

This macro expands to:

#define ASSH_BOP_MOD(dst, src1, src2) [link] 

This macro is for internal use only.

This macro is declared in assh/assh_bignum.h source file, line 453.

This instruction computes dst2 = src1 % src2. The src2 operand can be either a big number or a montgomery context.

This macro expands to:

See also ASSH_BOP_DIVMOD.

#define ASSH_BOP_MOVE(dst, src) [link] 

This macro is for internal use only.

This macro is declared in assh/assh_bignum.h source file, line 321.

This instruction moves and converts values in various formats. It is equivalent to the assh_bignum_convert function.

This macro expands to:

#define ASSH_BOP_MOVEA(dst, src) [link] 

This macro is for internal use only.

This macro is declared in assh/assh_bignum.h source file, line 329.

This instruction is similar to ASSH_BOP_MOVE. Once the bignum has been written, the next argument is set to point after the output, so that multiple serialized bignums can be made contiguous.

This macro expands to:

#define ASSH_BOP_MOVES(dst, src) [link] 

This macro is for internal use only.

This macro is declared in assh/assh_bignum.h source file, line 335.

Same behavior as ASSH_BOP_MOVE, set the secret flag on destination.

This macro expands to:

#define ASSH_BOP_MTFROM(dst1, dst2, src, mt) [link] 

This macro is for internal use only.

This macro is declared in assh/assh_bignum.h source file, line 362.

This converts the source number from montgomery representation. The resulting number is reduced according to the modulus.

This macro expands to:

ASSH_BOP_FMT4(ASSH_BIGNUM_OP_MTFROM, dst2 - dst1 + 1, dst1, src, mt)

See also ASSH_BOP_MTTO.

#define ASSH_BOP_MTINIT(mt, mod) [link] 

This macro is for internal use only.

This macro is declared in assh/assh_bignum.h source file, line 344.

This initializes a temporary montgomery multiplication context from a modulus number.

If the modulus is a secret number, its most significant bit must be set.

This macro expands to:

#define ASSH_BOP_MTTO(dst1, dst2, src, mt) [link] 

This macro is for internal use only.

This macro is declared in assh/assh_bignum.h source file, line 355.

This converts the source number to montgomery representation.

The resulting value can be further processed by the ASSH_BOP_ADDM, ASSH_BOP_SUBM, ASSH_BOP_MULM, ASSH_BOP_EXPM, ASSH_BOP_INV, ASSH_BOP_MOD and ASSH_BOP_MTFROM instructions. The mt operand is a montgomery context initialized from the modulus using the ASSH_BOP_MTINIT instruction.

This macro expands to:

ASSH_BOP_FMT4(ASSH_BIGNUM_OP_MTTO, dst2 - dst1 + 1, dst1, src, mt)

#define ASSH_BOP_MTUINT(dst, value, mt) [link] 

This macro is for internal use only.

This macro is declared in assh/assh_bignum.h source file, line 584.

This instruction initializes a big number from a 12 bits unsigned integer constant. The result is converted to montgomery form.

This macro expands to:

#define ASSH_BOP_MUL(dst, src1, src2) [link] 

This macro is for internal use only.

This macro is declared in assh/assh_bignum.h source file, line 434.

This instruction computes dst = (src1 * src2) in constant time. The bit size of the destination number must be bits(src1) + bits(src2) or larger.

This macro expands to:

#define ASSH_BOP_MULM(dst, src1, src2, mod) [link] 

This macro is for internal use only.

This macro is declared in assh/assh_bignum.h source file, line 427.

This instruction computes dst = (src1 * src2) % mod. The bit size of the destination number must be bits(mod) or larger. The mod operand can be either a big number or a montgomery context. In the later case the bit size of all operands must match the size of the montgomery context and the operation is computed in constant time.

This macro expands to:

ASSH_BOP_FMT4(ASSH_BIGNUM_OP_MUL, dst, src1, src2, mod)

#define ASSH_BOP_NEXTPRIME(dst, step) [link] 

This macro is for internal use only.

This macro is declared in assh/assh_bignum.h source file, line 632.

This instruction finds the next prime number starting from the specified value. If step is not ASSH_BOP_NOREG, it must hold a value used as increment. In the other case, the step value is 1. When an increment is specified, it must be prime and the value of dst must not be a multiple of step.

This macro expands to:

#define ASSH_BOP_NOP() [link] 

This macro is for internal use only.

This macro is declared in assh/assh_bignum.h source file, line 544.

This instruction does nothing.

This macro expands to:

#define ASSH_BOP_NOREG 63 [link] 

This macro is for internal use only.

This macro is declared in assh/assh_bignum.h source file, line 310.

Reserved big number bytecode register id.

#define ASSH_BOP_PRIME(dst, min, max, quality) [link] 

This macro is for internal use only.

This macro is declared in assh/assh_bignum.h source file, line 623.

This instruction generates a prime number in the range (min, max). If min is ASSH_BOP_NOREG, no lower bound is used. If max is ASSH_BOP_NOREG, the most significant bit of the destination will be set so that the bit size of the generated number is large.

This macro expands to:

ASSH_BOP_FMT4(ASSH_BIGNUM_OP_PRIME, dst, min, max, quality)

#define ASSH_BOP_PRINT(src, id) [link] 

This macro is for internal use only.

This macro is declared in assh/assh_bignum.h source file, line 677.

This instruction prints a big number argument for debugging purpose. The id argument is an ASCII integer constant.

This macro expands to:

#define ASSH_BOP_PRIVACY(src, secret, secur) [link] 

This macro is for internal use only.

This macro is declared in assh/assh_bignum.h source file, line 671.

The secret flag is forwarded to results of operations on big numbers. This instruction can be used to change the secret flag of a value.

This macro expands to:

#define ASSH_BOP_RAND(dst, min, max, quality) [link] 

This macro is for internal use only.

This macro is declared in assh/assh_bignum.h source file, line 505.

This instruction initializes a big number with random data. A new value is generated until it does fall in the specified range. The min and max bounds can be ASSH_BOP_NOREG. The quality operand is of type enum assh_prng_quality_e. The result is flagged secret depending on quality.

This macro expands to:

ASSH_BOP_FMT4(ASSH_BIGNUM_OP_RAND, dst, min, max, quality)

#define ASSH_BOP_SET(dst, val, src, condid) [link] 

This macro is for internal use only.

This macro is declared in assh/assh_bignum.h source file, line 572.

This instruction set a bit in dst from a condition flag. When the src operand is ASSH_BOP_NOREG, the tested bit position is val. In the other case, the tested bit position is size(src) - val). val must be in the range [0, 64].

This macro expands to:

ASSH_BOP_FMT4(ASSH_BIGNUM_OP_SET, condid, dst, val, src)

#define ASSH_BOP_SHL(dst, src, val, src2) [link] 

This macro is for internal use only.

This macro is declared in assh/assh_bignum.h source file, line 496.

This instruction is similar to ASSH_BOP_SHR but perform a left shift.

This macro expands to:

ASSH_BOP_FMT4(ASSH_BIGNUM_OP_SHL, dst, src, 128 + (val), src2)

#define ASSH_BOP_SHR(dst, src, val, src2) [link] 

This macro is for internal use only.

This macro is declared in assh/assh_bignum.h source file, line 490.

This instruction computes dst = shift_right(src1, val + size(src2)) in constant time. val must be in range [-128, +127] and src2 can be ASSH_BOP_NOREG. The source and destination operands must have the same bit length and the shift amount must be less than the length.

This macro expands to:

ASSH_BOP_FMT4(ASSH_BIGNUM_OP_SHR, dst, src, 128 + (val), src2)

#define ASSH_BOP_SHRINK(dst, src) [link] 

This macro is for internal use only.

This macro is declared in assh/assh_bignum.h source file, line 390.

This reduces the bit size of a temporary number or montgomery context. The source operand is evaluated by a call to the assh_bignum_size_of_data function.

This macro expands to:

#define ASSH_BOP_SIZE(dst, src) [link] 

This macro is for internal use only.

This macro is declared in assh/assh_bignum.h source file, line 369.

This instruction defines the bit size of a number or montgomery context. The source operand is evaluated by a call to the assh_bignum_size_of_data function.

This macro expands to:

#define ASSH_BOP_SIZEM(dst, src, cadd, cshift) [link] 

This macro is for internal use only.

This macro is declared in assh/assh_bignum.h source file, line 376.

This instruction has the same behavior as the ASSH_BOP_SIZE instruction with shift and offset of the source size value.

This macro expands to:

ASSH_BOP_FMT4(ASSH_BIGNUM_OP_SIZE, dst, src, cadd, cshift + 32)

#define ASSH_BOP_SIZER(dst1, dst2, src) [link] 

This macro is for internal use only.

This macro is declared in assh/assh_bignum.h source file, line 383.

This instruction has the same behavior as the ASSH_BOP_SIZE instruction applied to a range of destination registers.

This macro expands to:

ASSH_BOP_FMT4(ASSH_BIGNUM_OP_SIZER, dst1, src, dst2, 0)

#define ASSH_BOP_SUB(dst, src1, src2) [link] 

This macro is for internal use only.

This macro is declared in assh/assh_bignum.h source file, line 417.

This instruction computes dst = (src1 - src2) % mod. Same behavior as ASSH_BOP_ADD

This macro expands to:

#define ASSH_BOP_SUBM(dst, src1, src2, mod) [link] 

This macro is for internal use only.

This macro is declared in assh/assh_bignum.h source file, line 404.

This instruction computes dst = (src1 - src2) % mod. Same behavior as ASSH_BOP_ADDM.

This macro expands to:

ASSH_BOP_FMT4(ASSH_BIGNUM_OP_SUB, dst, src1, src2, mod)

#define ASSH_BOP_TEST(src1, val, src2, condid) [link] 

This macro is for internal use only.

This macro is declared in assh/assh_bignum.h source file, line 564.

This instruction tests a bit in src1 and updates the condition flag. When the src2 operand is ASSH_BOP_NOREG, the tested bit position is val. In the other case, the tested bit position is size(src2) - val). val must be in the range [0, 64].

This macro expands to:

ASSH_BOP_FMT4(ASSH_BIGNUM_OP_TEST, condid, src1, val, src2)

#define ASSH_BOP_UINT(dst, value) [link] 

This macro is for internal use only.

This macro is declared in assh/assh_bignum.h source file, line 578.

This instruction initializes a big number from a 20 bits unsigned integer constant.

This macro expands to:

size_t assh_bignum_bits(const struct assh_bignum_s *bn) [link] 

This function is for internal use only.

This function is declared in assh/assh_bignum.h source file, line 237.

This function returns the number of bits of a big number.

assh_status_t assh_bignum_bytecode(struct assh_context_s *c, uint8_t cond, const assh_bignum_op_t *ops, const char *format, ...) [link] 

This function is for internal use only.

This function is declared in assh/assh_bignum.h source file, line 172.

This function executes big number operations specified by the given bytecode. Operations are performed on arguments and temporarie values as specified by the format argument.

The format string indicates the types of arguments passed to the function and the number of temporary values. The format string is composed of characters defined in enum assh_bignum_fmt_e. An extra argument must be passed to the function for each non-temporary entry in the format string.

The ASSH_BOP_MOVE instruction can be used to convert between native big numbers (arguments or temporaries) and other types of arguments. Unless specified otherwise, all other instructions are designed to be used on native big numbers only.

Native big number arguments are passed as pointers to struct assh_bignum_s objects. The size of big numbers can only be changed by the ASSH_BOP_SIZE family of instructions. The destination big number used with other instructions must be large enough to store the result as the number will not be dynamically resized. Working on numbers with a predefined storage size helps with constant time execution.

If NULL is passed as argument following a mpint argument, the pointer will be set when the mpint is written. This allows storing contiguous numbers in mpint format whithout knowing the size of the encoded numbers.

Resources used by temporary numbers are automatically released when the function returns.

assh_status_t assh_bignum_bytecode_valist(struct assh_context_s *c, uint8_t cond, const assh_bignum_op_t *ops, const char *format, va_list ap) [link] 

This function is for internal use only.

This function is declared in assh/assh_bignum.h source file, line 137.

See also assh_bignum_bytecode.

assh_status_t assh_bignum_convert(struct assh_context_s *c, enum assh_bignum_fmt_e src_fmt, enum assh_bignum_fmt_e dst_fmt, const void *src, void *dst, uint8_t **next, assh_bool_t dst_secret) [link] 

This function is for internal use only.

This function is declared in assh/assh_bignum.h source file, line 199.

This function converts between a big number in ASSH_BIGNUM_NATIVE format and a number in an alternate format. The native big number argument points to an struct assh_bignum_s object.

When converting to a native big number from a number in ASSH_BIGNUM_STRING, ASSH_BIGNUM_ASN1 or ASSH_BIGNUM_MPINT format, the source number must have a properly initialized or checked size header. When converting from a source number in ASSH_BIGNUM_MSB_RAW or ASSH_BIGNUM_LSB_RAW format, the bit size of the destination number is used; leading bits in the most significant byte of the source are ignored.

In all other cases, the buffer size is expected to be appropriate for the bits size of the native big number involved in the conversion, as returned by the assh_bignum_size_of_bits and assh_bignum_size_of_num functions.

When converting between two native big numbers, the current bits size of the source might be larger than the size of the destination provided that the actual value fits in the destination.

enum assh_bignum_fmt_e [link] 

This enum is for internal use only.

This enum is declared in assh/assh_bignum.h source file, line 78.

This enum specifies various storage formats of big numbers.

IdentifierValueDescription
ASSH_BIGNUM_NATIVE'N'Native big number representation, stored as a struct assh_bignum_s object.
ASSH_BIGNUM_TEMP'T'Same representation as ASSH_BIGNUM_NATIVE, used as a temporary value during bytecode execution.
ASSH_BIGNUM_MPINT'M'SSH mpint representation.
ASSH_BIGNUM_ASN1'A'ASN1 integer representation.
ASSH_BIGNUM_STRING'S'RAW MSB data embedded in a SSH string
ASSH_BIGNUM_MSB_RAW'D'RAW MSB first data without header
ASSH_BIGNUM_LSB_RAW'd'RAW LSB first data without header
ASSH_BIGNUM_HEX'H'NUL terminated hexadecimal representation
ASSH_BIGNUM_INT'i'Intptr_t value interpreted as a number value.
ASSH_BIGNUM_SIZE's'Intptr_t value interpreted as a bit size.
ASSH_BIGNUM_MT'm'Temporary montgomery multiplication context.

void assh_bignum_init(struct assh_context_s *c, struct assh_bignum_s *bn, size_t bits) [link] 

This function is for internal use only.

This function is declared in assh/assh_bignum.h source file, line 233.

This function initializes a big number object. No buffer is allocated, the big number is left empty.

assh_bool_t assh_bignum_isempty(const struct assh_bignum_s *bn) [link] 

This function is for internal use only.

This function is declared in assh/assh_bignum.h source file, line 242.

This function test if a big number is actually stored in the object or if it's empty.

typedef uint32_t assh_bignum_op_t [link] 

This typedef is for internal use only.

This typedef is declared in assh/assh_bignum.h source file, line 64.

This typedef is the big number bytecode instruction word. The instruction binary formats is as follow:

op(6) d(6)
xxxxxx xxxxxx

op(6) c(8) d(6)
xxxxxx xxxxxxxx xxxxxx

op(6) b(12) c(8) d(6)
xxxxxx xxxxxx xxxxxxxx xxxxxx

op(6) a(6) b(6) c(8) d(6)
xxxxxx xxxxxx xxxxxx xxxxxxxx xxxxxx

See also ASSH_BOP_FMT1, ASSH_BOP_FMT2, ASSH_BOP_FMT3 and ASSH_BOP_FMT4.

enum assh_bignum_opcode_e [link] 

This enum is for internal use only.

This enum is declared in assh/assh_bignum.h source file, line 253.

IdentifierValueDescription
ASSH_BIGNUM_OP_END0
ASSH_BIGNUM_OP_MOVE1
ASSH_BIGNUM_OP_SIZER2
ASSH_BIGNUM_OP_SIZE3
ASSH_BIGNUM_OP_ADD4
ASSH_BIGNUM_OP_SUB5
ASSH_BIGNUM_OP_MUL6
ASSH_BIGNUM_OP_DIV7
ASSH_BIGNUM_OP_GCD8
ASSH_BIGNUM_OP_EXPM9
ASSH_BIGNUM_OP_INV10
ASSH_BIGNUM_OP_SHR11
ASSH_BIGNUM_OP_SHL12
ASSH_BIGNUM_OP_RAND13
ASSH_BIGNUM_OP_CMP14
ASSH_BIGNUM_OP_TEST15
ASSH_BIGNUM_OP_SET16
ASSH_BIGNUM_OP_UINT17
ASSH_BIGNUM_OP_MTUINT18
ASSH_BIGNUM_OP_JMP19
ASSH_BIGNUM_OP_CFAIL20
ASSH_BIGNUM_OP_LADINIT21
ASSH_BIGNUM_OP_LADTEST22
ASSH_BIGNUM_OP_LADNEXT23
ASSH_BIGNUM_OP_CSWAP24
ASSH_BIGNUM_OP_CMOVE25
ASSH_BIGNUM_OP_MTINIT26
ASSH_BIGNUM_OP_MTTO27
ASSH_BIGNUM_OP_MTFROM28
ASSH_BIGNUM_OP_PRIME29
ASSH_BIGNUM_OP_NEXTPRIME30
ASSH_BIGNUM_OP_ISPRIME31
ASSH_BIGNUM_OP_BOOL32
ASSH_BIGNUM_OP_PRIVACY33
ASSH_BIGNUM_OP_PRINT34
ASSH_BIGNUM_OP_TRACE35
ASSH_BIGNUM_OP_SHRINK36
ASSH_BIGNUM_OP_NOP37
ASSH_BIGNUM_OP_ISTRIVIAL38
ASSH_BIGNUM_OP_MOVEA39

void assh_bignum_release(struct assh_context_s *ctx, struct assh_bignum_s *bn) [link] 

This function is for internal use only.

This function is declared in assh/assh_bignum.h source file, line 249.

This function releases the internal storage of a bignum. The big number object become empty as if the assh_bignum_init function has just been called.

struct assh_bignum_s [link] 

This struct is for internal use only.

This struct is declared in assh/assh_bignum.h source file, line 109.

This struct represents a big number in native format. The number object is empty if no internal representation of the number is currently allocated (n is NULL).

FieldDescription
uint16_t bits;Bits size
uint16_t secret:1;The value must be stored in secure memory and can only be used with constant time operations. This flag is updated when a new value is stored.
uint16_t secure:1;Any new value stored in this big number object must use secure memory even if the value is not secret.
uint16_t storage:1;The current storage is allocated in secure memory.
uint16_t mt_mod:1;Whether the number is a montgomery modulus
uint16_t mt_num:1;Whether the number is in montgomery representation
uint16_t mt_id:6;Associated montgomery context id
uint16_t tmp:1;This is a temporary number stored in vm scratch buffer
void * n;Number data

size_t assh_bignum_size_of_bits(enum assh_bignum_fmt_e dst_fmt, size_t bits) [link] 

This function is for internal use only.

This function is declared in assh/assh_bignum.h source file, line 204.

This function returns the byte size needed to store a big number of given bit size using the specified format.

assh_status_t assh_bignum_size_of_data(enum assh_bignum_fmt_e fmt, const void *data, size_t *size, size_t *val_size, size_t *bits) [link] 

This function is for internal use only.

This function is declared in assh/assh_bignum.h source file, line 226.

This function evaluates the storage size in bytes, the actual embedded value size in bytes and the bit size of the big number value. The fmt parameter indicates the input format of data. No bound checking is performed, the buffer size of the input data must have been checked previously. Some value checks are performed on the format of the data.

Either size, val_size or bits may be NULL. When the input format is either ASSH_BIGNUM_MSB_RAW or ASSH_BIGNUM_LSB_RAW, the size parameter must be used to pass the bytes size of the buffer.

size_t assh_bignum_size_of_num(enum assh_bignum_fmt_e dst_fmt, const struct assh_bignum_s *bn) [link] 

This function is for internal use only.

This function is declared in assh/assh_bignum.h source file, line 210.

This function returns the byte size needed to store the given big number object.

Valid XHTML 1.0 StrictGenerated by diaxen on Sun Oct 25 23:31:03 2020 using MkDoc