File: __init__.py

package info (click to toggle)
python-pkcs11 0.9.3-1
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid
  • size: 932 kB
  • sloc: python: 4,067; ansic: 2,764; makefile: 24
file content (12 lines) | stat: -rw-r--r-- 351 bytes parent folder | download
1
2
3
4
5
6
7
8
9
10
11
12
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")