Iam在尝试使用MAGE.exe和SHA256 RFC 3161时间戳签署clickonce(.application)时出错.
mage.exe -s /path/to/our/.application"-cf certfile -ti [RFC 3161 timestamp]
我收到以下错误:
"内部错误,请稍后再试.参数不正确."
如果我尝试在没有时间戳或SHA1时间戳的情况下进行签名,一切正常.
你能否建议使用SHA256 RFC 3161时间戳的一次应用程序签名点击的正确方法
我正在尝试使用 RsaSsaPssSha256 签署 JWToken,并使用我从密钥库中读取的自签名 X509certificate2。
使用.net 4.61;
SecurityTokenDescriptor tokenDescriptor = new SecurityTokenDescriptor
{
Subject = ,
SigningCredentials = new SigningCredentials(privateKey, SecurityAlgorithms.RsaSsaPssSha256Signature),
Expires = DateTime.UtcNow.AddMinutes(expirationMinutes),
};
Run Code Online (Sandbox Code Playgroud)
并得到以下错误:
"IDX10634: Unable to create the SignatureProvider.\nAlgorithm: 'PS256', SecurityKey: 'Microsoft.IdentityModel.Tokens.X509SecurityKey, KeyId: 'xxxxxxxxxxxxxxxxxxxxxxxxxx', InternalId: 'xxxxx-xxxxxx-xxxx-xxxxxx'.'\n is not supported. The list of supported algorithms is available here: https://aka.ms/IdentityModel/supported-algorithms"
Run Code Online (Sandbox Code Playgroud)
不用说,SecurityAlgorithms.RsaSha256 按预期工作。
2.尝试使用Jose-JWT模块,得到如下错误:
"RsaUsingSha with PSS padding alg expects key to be of CngKey type."
Run Code Online (Sandbox Code Playgroud)
我在这里错过了什么?
我正在尝试用 python 对 JWT 进行编码,我需要用 base64 对其进行编码,我就是这么做的。然后我必须在发送到服务器之前用私钥对其进行签名。其实我被屏蔽了,什么时候签名我不知道怎么办,我从昨天开始就在网上搜索,我有点迷失了。这是我的代码。
import jwt
print ("\nStart..")
encoded = jwt.encode({'some': 'payload'}, 'secret', algorithm='HS256')
print("\nJWT : ",encoded)
try:
decoded = jwt.decode(encoded, 'secret', algorithms=['HS256'])
except jwt.InvalidTokenError:
print("Invalid token!!")
print("\ndecoded : ", decoded)
print("\nencodage : ")
#LOAD THE PRIVATE KEY
#SIGN THE ENCODED token
Run Code Online (Sandbox Code Playgroud)
还有我的密钥的格式,它是 RSA 私钥。
-----BEGIN RSA PRIVATE KEY-----
dsjkfhsdfkshkdfhks...
-----END RSA PRIVATE KEY-----
Run Code Online (Sandbox Code Playgroud)
我向服务器 crt.crt 提供了一个证书,我认为我需要用我的私钥进行加密,然后他们将能够使用证书中的密钥来解密消息,这就是我的理解。
预先感谢,G.B
我安装了 Crypto 模块和 SHA256 但显示 ModuleNotFoundError :-
回溯(最近一次调用最后一次):文件“Digitalsig.py”,第 1 行,来自 Crypto.Hash import SHA256 ModuleNotFoundError:没有名为“Crypto”的模块
这是参考代码
from Crypto.Hash import SHA256
from Crypto.PublicKey import RSA
from Crypto import Random
random_generator = Random.new().read
#used to generate a keypair which contain a public and private key
keyPair = RSA.generate(1024,random_generator)
pubKey = keyPair.publicKey()
plainText = 'Hello World'
hashA = SHA256.new(plainText).digest()
digitalSignature = keyPair.sign(hashA,'')
print("Hash A: "+repr(hashA) + "\n");
print("Digital Signature: " + repr(digitalSignature) + "\n")
#Bob receives the plainText and digitalSignature from Alice
#plainTextChanged ='Hello …Run Code Online (Sandbox Code Playgroud) 我们的系统将通过身份验证服务器调用 API。这个服务器是用java构建的,需要大量的密钥加密。一项要求是使用“SHA256 with RSA”算法使用客户端(我们)的私钥生成签名。我已经用 Java 做到了这一点,但不确定它是否正确。Rur 服务器是用 Nodejs 编写的。如何将下面的 Java 代码转换为 Node.js?
public static String signSHA256RSA(String input, String strPk) throws Exception {
Security.addProvider(new BouncyCastleProvider());
// Remove markers and new line characters in private key
String realPK = strPk.replaceAll("-----END PRIVATE KEY-----", "")
.replaceAll("-----BEGIN PRIVATE KEY-----", "")
.replaceAll("\n", "");
byte[] b1 = Base64.getDecoder().decode(realPK);
PKCS8EncodedKeySpec spec = new PKCS8EncodedKeySpec(b1);
KeyFactory kf = KeyFactory.getInstance("RSA");
Signature privateSignature = Signature.getInstance("SHA256withRSA");
privateSignature.initSign(kf.generatePrivate(spec));
privateSignature.update(input.getBytes("UTF-8"));
byte[] s = privateSignature.sign();
return Base64.getEncoder().encodeToString(s);
}
Run Code Online (Sandbox Code Playgroud) 我正在尝试从公钥证书中读取 sha256。证书如下所示。
我正在运行以下命令来读取 sha256 哈希,但它没有给出正确的结果:
openssl x509 -in test.crt -pubkey -noout | openssl rsa -pubin -outform der | \
openssl dgst -sha256 -binary | openssl enc -base64
Run Code Online (Sandbox Code Playgroud)
我得到了一些错误的值 RTy7aSpufwRDWUudgZCwR5Xc7NETd6Imk4YlzvgKTRU=
正确的值是:
sha256/i1RfARNCYn9+K3xmRNTaXG9sVSK6TMgY9l8SDm3MUZ4=
sha256/7HIpactkIAq2Y49orFOOQKurWxmmSFZhBCoQYcRhJ3Y=
sha256/h6801m+z8v3zbgkRHpq6L29Esgfzhj89C1SyUCOQmqU=
Run Code Online (Sandbox Code Playgroud)
我想知道三个值是如何进来的,是的,只有一个是正确的,但是为了验证这些值,我确实运行了下面给出的示例程序:
public class Main {
public static void main(String[] args) throws IOException {
HttpLoggingInterceptor interceptor = new HttpLoggingInterceptor();
interceptor.setLevel(HttpLoggingInterceptor.Level.BODY);
String hostName = "www.google.com";
CertificatePinner certificatePinner = new CertificatePinner.Builder()
.add(hostName, "sha256/pqrmt")
.build();
OkHttpClient client = new OkHttpClient.Builder()
.addNetworkInterceptor(interceptor)
.certificatePinner(certificatePinner)
.build();
Request request = new Request.Builder()
.url("https://" + hostName) …Run Code Online (Sandbox Code Playgroud) 我尝试了对我的查询的搜索解决方案,但无法找到我正在寻找的匹配项,这是非常基本的,但为了我更好地理解,我在下面发布了查询。
我想使用“SHA256withRSA”算法对我的字符串进行编码和签名。我可以使用“SHA256withRSA”在java中看到很多示例代码,但在C#中我可以看到首先我们使用SHA256对数据进行哈希处理,然后我们使用RSACryptoServiceProvider对哈希进行签名。
我的问题是:
在 C# 中,我们有单独的“SHA256withRSA”算法,如果是,请帮助提供示例代码。
如果不是,那么用 C# 实现它的更好方法是什么?
我需要使用 SAML 2.0 标准化算法 (RSAwithSHA256) 对 XML SAML 消息进行签名。但我的 saml 插件(passport-saml)似乎只支持 sha1 和 sha256。SHA256 听起来与 RSAwithSHA256 非常接近,但可能不是同一件事?有什么区别,如何使用 RSAwithSHA256 代替?我可能需要编辑 Passport-saml 库,以允许使用 RSAwithSHA256 算法?
rsa-sha256 ×8
sha256 ×6
c# ×2
jwt ×2
python ×2
clickonce ×1
cryptography ×1
java ×1
javascript ×1
mage ×1
node.js ×1
passport.js ×1
private-key ×1
pycrypto ×1
rsa ×1
saml-2.0 ×1
ssl ×1