File: __init__.py

package info (click to toggle)
python-pkcs11 0.7.0-1
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid, trixie
  • size: 804 kB
  • sloc: python: 3,844; ansic: 1,981; sh: 33; makefile: 24
file content (13 lines) | stat: -rw-r--r-- 377 bytes parent folder | download
1
2
3
4
5
6
7
8
9
10
11
12
13
def biginteger(value):
    """
    Returns a PKCS#11 biginteger bytestream from a Python integer or
    similar type (e.g. :class:`asn1crypto.core.Integer`).

    :param int value: Value
    :rtype: bytes
    """

    value = int(value)  # In case it's a asn1 type or similar

    return value.to_bytes((value.bit_length() + 7) // 8,
                          byteorder='big')