首先,我必须说我使用Sage数学的知识非常有限,但我真的想改进一个能够解决我遇到的这些问题.我被要求实施以下内容:
1 - 阅读FIPS 186-4(http://nvlpubs.nist.gov/nistpubs/FIPS/NIST.FIPS.186-4.pdf)ECDSA的定义,并使用Sage数学实现:
(a) prime eliptic curves (P-xxx)
(b) binary eliptic curves (B-xxx)
Run Code Online (Sandbox Code Playgroud)
我尝试通过浏览互联网来解决(a)并最终得到以下代码:
class ECDSA_a:
def __init__(self):
#Parameters for Curve p-256 as stated on FIPS 186-4 D1.2.3
p256 = 115792089210356248762697446949407573530086143415290314195533631308867097853951
a256 = p256 - 3
b256 = ZZ("5ac635d8aa3a93e7b3ebbd55769886bc651d06b0cc53b0f63bce3c3e27d2604b", 16)
## base point values
gx = ZZ("6b17d1f2e12c4247f8bce6e563a440f277037d812deb33a0f4a13945d898c296", 16)
gy = ZZ("4fe342e2fe1a7f9b8ee7eb4a7c0f9e162bce33576b315ececbb6406837bf51f5", 16)
self.F = GF(p256)
self.C = EllipticCurve ([self.F(a256), self.F(b256)])
self.G = self.C(self.F(gx), self.F(gy))
self.N = FiniteField (self.C.order()) # how many points are …
Run Code Online (Sandbox Code Playgroud) 我正在开发一个项目,与Firefox中存在的新Push API集成,并且正在开发为W3C标准.
部分原因是加密数据.服务器将收到Diffie Hellman P256曲线(使用JS生成var key = subscription.getKey('p256dh');
)
转换为.NET base64时的一个例子是
BOAiqZO6ucAzDlZKKhF1aLjNpU8 + R2Pfsz4bQzNpV145D + agNxvLqyu5Q2tLalK2w31RpoDHE8Sipo0m2jiX4WA =
但是我遇到了生成派生材料的问题.
var key1 = Convert.FromBase64String("<stringFromAbove>").ToList() // You can criticize my .toList inefficiencies later
// .NET doesn't like the key without these prefixes. See here
// http://stackoverflow.com/questions/24251336/import-a-public-key-from-somewhere-else-to-cngkey
// I know the bytes don't match that post, but that is because the key type is different between their example and mine.
var keyType = new byte[] { 0x45, 0x43, 0x4B, 0x31 }; …
Run Code Online (Sandbox Code Playgroud) 我使用函数SSL_CTX_set_cipher_list来设置SSL连接支持的密码.传递给SSL_CTX_set_cipher_list以禁用弱密码的参数.
我试过传球 ALL:!ADH:!LOW:!EXP:!MD5:@STRENGTH
但它似乎没有用.
我的工具检测以下弱密码报告仍然启用
** SSLv3:DES-CBC-SHA - ENABLED - WEAK 56 bits ** ** TLSv1:DES-CBC-SHA - ENABLED - WEAK 56 bits ** ** SSLv2:RC4-MD5 - ENABLED - WEAK 128 bits ** ** SSLv2:RC2-CBC-MD5 - ENABLED - WEAK 128 bits ** ** SSLv2:RC4-64-MD5 - ENABLED - WEAK 64 bits ** ** SSLv2:DES-CBC-MD5 - ENABLED - WEAK 56 bits ** ** SSLv2:EXP-RC4-MD5 - ENABLED - WEAK 40 bits ** ** SSLv2:EXP-RC2-CBC-MD5 - ENABLED - WEAK 40 bits ** ** SSLv2:DES-CBC3-MD5 - …
我正在构建一个使用BouncyCastle作为加密提供程序的网络应用程序.假设你有这个生成密钥对:
ECParameterSpec ecSpec = ECNamedCurveTable.getParameterSpec("prime192v1");
KeyPairGenerator g = KeyPairGenerator.getInstance("ECDSA", "BC");
g.initialize(ecSpec, new SecureRandom());
KeyPair pair = g.generateKeyPair();
Run Code Online (Sandbox Code Playgroud)
我很困惑为什么你得到一个ECDSA KeyPairGenerator 的实例.为什么不说EC呢?我知道BouncyCastle附带了一个ECDH Key类型,但我认为这两个代表关于曲线上的点的相同内容 - 或者我完全错误的背后的理论?
我问的原因是,我现在的应用程序使用ECDH罚款来建立AES密钥,但现在我想使用相同的EC密钥使用ECDSA对每条消息进行签名.
libsodium是一个很棒的加密库,GnuPG是一个很棒的密钥管理和签名软件.
GnuPG的最近发布了Ed25519签名密钥的支持,并提交了一份草案,IETF.
我想通过我的Web应用程序使用GnuPG离线使用Sodium生成的密钥.这样就可以了,所以每次签名时我都不必用我的私钥来信任服务器,而且我不需要在我的客户端上使用特殊的软件(即使我必须写它)因为我已经拥有了信任GnuPG.
我怎么能这样做?如何将libsodium私钥转换为OpenPGP兼容的私钥包?
我想在javascript中使用椭圆曲线加密来实现类似于双人规则的东西.
编辑:我基本上在寻找像比特币multisig这样的东西.
所以我需要结合使用两个公钥来获得一个组合密钥,它需要两个私钥才能生成签名.请参阅https://crypto.stackexchange.com/questions/25250/adding-two-public-keys.
我怎么能在节点中这样做?
我有一项任务,需要使用NIST SP 800-56A第5.8.1节中描述的密钥导出函数来获取密钥材料.我不是密码学方面的专家,所以如果问题很幼稚,请原谅我.这是我到目前为止所做的:
现在我尝试使用C#(.NET 4)ECDiffieHellmanCng类使用ECDH 1.3.132.1.12生成共享密钥,如下所示:
// The GetCngKey method reads the private key from a certificate in my Personal certificate store
CngKey cngPrivateKey = GetCngKey();
ECDiffieHellmanCng ecDiffieHellmanCng = new ECDiffieHellmanCng(cngPrivateKey);
ecDiffieHellmanCng.HashAlgorithm = CngAlgorithm.ECDiffieHellmanP256;
ecDiffieHellmanCng.KeyDerivationFunction = ?? // What do I set here
Run Code Online (Sandbox Code Playgroud)最后这样做:
ecDiffieHellmanCng.DeriveKeyMaterial(otherPartyPublicKey:);
Run Code Online (Sandbox Code Playgroud)
在哪里/如何设置其他参数算法ID,Party U Info,Party V Info?
编辑 我愿意使用像Bouncy Castle这样的其他库(只要它们可以从.NET调用)
在iOS中有使用ECC的示例吗?
我注意到Apple Developer Documents中的kSecAttrKeyTypeEC,但是我不能将它用于通用密钥对.
下面的代码是从示例CryptoExercise修改的
// Container dictionaries.
NSMutableDictionary * privateKeyAttr = [[NSMutableDictionary alloc] init];
NSMutableDictionary * publicKeyAttr = [[NSMutableDictionary alloc] init];
NSMutableDictionary * keyPairAttr = [[NSMutableDictionary alloc] init];
// Set top level dictionary for the keypair.
[keyPairAttr setObject:(id)kSecAttrKeyTypeEC forKey:(id)kSecAttrKeyType];
[keyPairAttr setObject:[NSNumber numberWithUnsignedInteger:keySize] forKey:(id)kSecAttrKeySizeInBits];
// Set the private key dictionary.
[privateKeyAttr setObject:[NSNumber numberWithBool:YES] forKey:(id)kSecAttrIsPermanent];
[privateKeyAttr setObject:privateTag forKey:(id)kSecAttrApplicationTag];
// See SecKey.h to set other flag values.
// Set the public key dictionary.
[publicKeyAttr setObject:[NSNumber numberWithBool:YES] forKey:(id)kSecAttrIsPermanent];
[publicKeyAttr setObject:publicTag forKey:(id)kSecAttrApplicationTag];
// See …
Run Code Online (Sandbox Code Playgroud) 我正在自学matplotlib和Python,我很难绘制椭圆曲线的方程.我有等式,但我没有做y^2
这和我到目前为止所遇到的一样麻烦:
from mpl_toolkits.axes_grid.axislines import SubplotZero
import matplotlib.pyplot as plt
import numpy as np
from pylab import *
def plotGraph():
fig = plt.figure(1)
ax = SubplotZero(fig, 111)
fig.add_subplot(ax)
for direction in ["xzero", "yzero"]:
ax.axis[direction].set_axisline_style("-|>")
ax.axis[direction].set_visible(True)
a = 5; b = 25
x = np.arange(-50.0, 50.0, 1.0)
y = pow(x,3) + a*x + b
xmin = -50; xmax = 50; ymin = -50; ymax = 50
v = [xmin, xmax, ymin, ymax]
ax.axis(v)
ax.plot(x, pow(y,2))
#grid()
#ax.grid(color='r', linestyle='-', linewidth=2)
show() …
Run Code Online (Sandbox Code Playgroud) elliptic-curve ×10
cryptography ×5
c# ×2
ecdsa ×2
python ×2
bouncycastle ×1
encryption ×1
finite-field ×1
ios ×1
java ×1
javascript ×1
matplotlib ×1
node.js ×1
openpgp ×1
openssl ×1
python-2.7 ×1
sage ×1
security ×1
signature ×1
ssl ×1