~ [ source navigation ] ~ [ diff markup ] ~ [ identifier search ] ~

TOMOYO Linux Cross Reference
Linux/tools/crypto/ccp/dbc.py

Version: ~ [ linux-6.12-rc7 ] ~ [ linux-6.11.7 ] ~ [ linux-6.10.14 ] ~ [ linux-6.9.12 ] ~ [ linux-6.8.12 ] ~ [ linux-6.7.12 ] ~ [ linux-6.6.60 ] ~ [ linux-6.5.13 ] ~ [ linux-6.4.16 ] ~ [ linux-6.3.13 ] ~ [ linux-6.2.16 ] ~ [ linux-6.1.116 ] ~ [ linux-6.0.19 ] ~ [ linux-5.19.17 ] ~ [ linux-5.18.19 ] ~ [ linux-5.17.15 ] ~ [ linux-5.16.20 ] ~ [ linux-5.15.171 ] ~ [ linux-5.14.21 ] ~ [ linux-5.13.19 ] ~ [ linux-5.12.19 ] ~ [ linux-5.11.22 ] ~ [ linux-5.10.229 ] ~ [ linux-5.9.16 ] ~ [ linux-5.8.18 ] ~ [ linux-5.7.19 ] ~ [ linux-5.6.19 ] ~ [ linux-5.5.19 ] ~ [ linux-5.4.285 ] ~ [ linux-5.3.18 ] ~ [ linux-5.2.21 ] ~ [ linux-5.1.21 ] ~ [ linux-5.0.21 ] ~ [ linux-4.20.17 ] ~ [ linux-4.19.323 ] ~ [ linux-4.18.20 ] ~ [ linux-4.17.19 ] ~ [ linux-4.16.18 ] ~ [ linux-4.15.18 ] ~ [ linux-4.14.336 ] ~ [ linux-4.13.16 ] ~ [ linux-4.12.14 ] ~ [ linux-4.11.12 ] ~ [ linux-4.10.17 ] ~ [ linux-4.9.337 ] ~ [ linux-4.4.302 ] ~ [ linux-3.10.108 ] ~ [ linux-2.6.32.71 ] ~ [ linux-2.6.0 ] ~ [ linux-2.4.37.11 ] ~ [ unix-v6-master ] ~ [ ccs-tools-1.8.12 ] ~ [ policy-sample ] ~
Architecture: ~ [ i386 ] ~ [ alpha ] ~ [ m68k ] ~ [ mips ] ~ [ ppc ] ~ [ sparc ] ~ [ sparc64 ] ~

Diff markup

Differences between /tools/crypto/ccp/dbc.py (Version linux-6.12-rc7) and /tools/crypto/ccp/dbc.py (Version linux-6.7.12)


  1 #!/usr/bin/python3                                  1 #!/usr/bin/python3
  2 # SPDX-License-Identifier: GPL-2.0                  2 # SPDX-License-Identifier: GPL-2.0
  3                                                     3 
  4 import ctypes                                       4 import ctypes
  5 import os                                           5 import os
  6                                                     6 
  7 DBC_UID_SIZE = 16                                   7 DBC_UID_SIZE = 16
  8 DBC_NONCE_SIZE = 16                                 8 DBC_NONCE_SIZE = 16
  9 DBC_SIG_SIZE = 32                                   9 DBC_SIG_SIZE = 32
 10                                                    10 
 11 PARAM_GET_FMAX_CAP = (0x3,)                        11 PARAM_GET_FMAX_CAP = (0x3,)
 12 PARAM_SET_FMAX_CAP = (0x4,)                        12 PARAM_SET_FMAX_CAP = (0x4,)
 13 PARAM_GET_PWR_CAP = (0x5,)                         13 PARAM_GET_PWR_CAP = (0x5,)
 14 PARAM_SET_PWR_CAP = (0x6,)                         14 PARAM_SET_PWR_CAP = (0x6,)
 15 PARAM_GET_GFX_MODE = (0x7,)                        15 PARAM_GET_GFX_MODE = (0x7,)
 16 PARAM_SET_GFX_MODE = (0x8,)                        16 PARAM_SET_GFX_MODE = (0x8,)
 17 PARAM_GET_CURR_TEMP = (0x9,)                       17 PARAM_GET_CURR_TEMP = (0x9,)
 18 PARAM_GET_FMAX_MAX = (0xA,)                        18 PARAM_GET_FMAX_MAX = (0xA,)
 19 PARAM_GET_FMAX_MIN = (0xB,)                        19 PARAM_GET_FMAX_MIN = (0xB,)
 20 PARAM_GET_SOC_PWR_MAX = (0xC,)                     20 PARAM_GET_SOC_PWR_MAX = (0xC,)
 21 PARAM_GET_SOC_PWR_MIN = (0xD,)                     21 PARAM_GET_SOC_PWR_MIN = (0xD,)
 22 PARAM_GET_SOC_PWR_CUR = (0xE,)                     22 PARAM_GET_SOC_PWR_CUR = (0xE,)
 23                                                    23 
 24 DEVICE_NODE = "/dev/dbc"                           24 DEVICE_NODE = "/dev/dbc"
 25                                                    25 
 26 lib = ctypes.CDLL("./dbc_library.so", mode=cty     26 lib = ctypes.CDLL("./dbc_library.so", mode=ctypes.RTLD_GLOBAL)
 27                                                    27 
 28                                                    28 
 29 def handle_error(code):                            29 def handle_error(code):
 30     raise OSError(code, os.strerror(code))         30     raise OSError(code, os.strerror(code))
 31                                                    31 
 32                                                    32 
 33 def get_nonce(device, signature):                  33 def get_nonce(device, signature):
 34     if not device:                                 34     if not device:
 35         raise ValueError("Device required")        35         raise ValueError("Device required")
 36     buf = ctypes.create_string_buffer(DBC_NONC     36     buf = ctypes.create_string_buffer(DBC_NONCE_SIZE)
 37     ret = lib.get_nonce(device.fileno(), ctype     37     ret = lib.get_nonce(device.fileno(), ctypes.byref(buf), signature)
 38     if ret:                                        38     if ret:
 39         handle_error(ret)                          39         handle_error(ret)
 40     return buf.value                               40     return buf.value
 41                                                    41 
 42                                                    42 
 43 def set_uid(device, new_uid, signature):           43 def set_uid(device, new_uid, signature):
 44     if not signature:                              44     if not signature:
 45         raise ValueError("Signature required")     45         raise ValueError("Signature required")
 46     if not new_uid:                                46     if not new_uid:
 47         raise ValueError("UID required")           47         raise ValueError("UID required")
 48     ret = lib.set_uid(device.fileno(), new_uid     48     ret = lib.set_uid(device.fileno(), new_uid, signature)
 49     if ret:                                        49     if ret:
 50         handle_error(ret)                          50         handle_error(ret)
 51     return True                                    51     return True
 52                                                    52 
 53                                                    53 
 54 def process_param(device, message, signature,      54 def process_param(device, message, signature, data=None):
 55     if not signature:                              55     if not signature:
 56         raise ValueError("Signature required")     56         raise ValueError("Signature required")
 57     if type(message) != tuple:                     57     if type(message) != tuple:
 58         raise ValueError("Expected message tup     58         raise ValueError("Expected message tuple")
 59     arg = ctypes.c_int(data if data else 0)        59     arg = ctypes.c_int(data if data else 0)
 60     sig = ctypes.create_string_buffer(signatur     60     sig = ctypes.create_string_buffer(signature, len(signature))
 61     ret = lib.process_param(device.fileno(), m     61     ret = lib.process_param(device.fileno(), message[0], ctypes.pointer(sig), ctypes.pointer(arg))
 62     if ret:                                        62     if ret:
 63         handle_error(ret)                          63         handle_error(ret)
 64     return arg.value, sig.value                    64     return arg.value, sig.value
                                                      

~ [ source navigation ] ~ [ diff markup ] ~ [ identifier search ] ~

kernel.org | git.kernel.org | LWN.net | Project Home | SVN repository | Mail admin

Linux® is a registered trademark of Linus Torvalds in the United States and other countries.
TOMOYO® is a registered trademark of NTT DATA CORPORATION.

sflogo.php