本文整理汇总了Python中pyelliptic.openssl.OpenSSL.i2d_ECPKParameters方法的典型用法代码示例。如果您正苦于以下问题:Python OpenSSL.i2d_ECPKParameters方法的具体用法?Python OpenSSL.i2d_ECPKParameters怎么用?Python OpenSSL.i2d_ECPKParameters使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类pyelliptic.openssl.OpenSSL
的用法示例。
在下文中一共展示了OpenSSL.i2d_ECPKParameters方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: __set_parameters
# 需要导入模块: from pyelliptic.openssl import OpenSSL [as 别名]
# 或者: from pyelliptic.openssl.OpenSSL import i2d_ECPKParameters [as 别名]
def __set_parameters(self):
size = OpenSSL.i2d_ECPKParameters(self.os_group, 0)
mb = ctypes.create_string_buffer(size)
OpenSSL.i2d_ECPKParameters(self.os_group, ctypes.byref(ctypes.pointer(mb)))
asntree = [x for x in ASNHelper.consume( mb.raw )][0]
self.ver, self.field, self.curve, self.G_raw, self.order, self.h = asntree
if self.field[0] == '42.134.72.206.61.1.1': # Prime field
self.field_type = 'prime'
self.p = self.field[1]
self.bitlength = int( math.ceil( math.log( self.p, 2 ) ) )
self.a = self.curve[0]
self.b = self.curve[1]
self.f = lambda x: x**3 + self.a*x + self.b
elif self.field[0] == '42.134.72.206.61.1.2': # Characteristic two field
self.field_type = 'power-of-two'
self.m = self.field[1][0]
# Maybe bitlength below is not correct..?
self.bitlength = self.m + 1
if self.field[1][1] == '42.134.72.206.61.1.2.3.2': # Only one coefficient
self.poly_coeffs = [self.field[1][2]]
elif self.field[1][1] == '42.134.72.206.61.1.2.3.3': # Several coefficients
self.poly_coeffs = self.field[1][2]
else:
raise Exception('Unknown field OID %s' % self.field[1][1])
self.a = self.curve[0]
self.b = self.curve[1]
else:
raise Exception( 'Unknown curve field' )