How to use the padding.PKCS1_v15.FUNC_TABLE function in Padding

To help you get started, we’ve selected a few Padding examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github alexmgr / pybleach / pkcs1_test_client.py View on Github external
if args.length != None:
    k = NumUtils.pow2_round(args.length)

  if args.hex:
    try:
      cleartexts = [unhexlify(cleartext) for cleartext in cleartexts]
    except TypeError as te:
      print("Cleartext provided is not in hex format: %s: " % cleartext, te, file=stderr)
      parser.print_help()
      exit(1)

  pkcs1 = PKCS1_v15(k)
  for m in cleartexts:
    for i in tests:
      padded_cleartext = getattr(pkcs1, PKCS1_v15.FUNC_TABLE[i])(m)
      if print_encrypted:
        c = rsa.encrypt(padded_cleartext, 0)[0]
        c = "\x00"*(k/8-len(c)) + c
        print(hexlify(c))
      else:
        print(hexlify(padded_cleartext))