小编sim*_*nes的帖子

PyCrypto会生成错误的签名

我遇到了PyCrypto的主要问题,如下面的代码所示.一个问题是测试用例不会以可重复的方式失败,但在使用不同密钥的不同平台上有不同的原因.

请注意,测试用例为Alice和Bob提供了两组密钥,第一组由OpenSSL生成,第二组由PyCrypto生成(取消注释"备用密钥"部分).

测试案例是一个简单的往返:

  1. Alice生成对称密钥并加密数据
  2. Alice用Bob的公钥加密对称密钥,然后用她的私钥签署加密密钥(在这个简单的测试用例中不使用哈希).
  3. Bob用Alice的公钥验证签名,并用他的私钥解密对称密钥.
  4. Bob用对称密钥解密数据.

以下是一些示例运行的结果:

在Linux上使用OpenSSL密钥

attempts: 1000
 success: 0
mismatch: 0
    fail: 1000
  Bad signature = 993
  Ciphertext too large = 7
Run Code Online (Sandbox Code Playgroud)

在Linux上使用PyCrypto键

attempts: 1000
 success: 673
mismatch: 0
    fail: 327
  AES key must be either 16, 24, or 32 bytes long = 3
  Ciphertext too large = 324
Run Code Online (Sandbox Code Playgroud)

在Windows上使用OpenSSL密钥

attempts: 1000
 success: 993
mismatch: 0
    fail: 7
  AES key must be either 16, 24, or 32 bytes long = 3
  Bad signature = 4
Run Code Online (Sandbox Code Playgroud)

在Windows上使用PyCrypto键 …

python pycrypto

10
推荐指数
1
解决办法
1458
查看次数

Powershell和路径环境变量

我想powershell使用环境变量"PATH"来解析可执行文件.我敢肯定它应该可以做到这一点,但这就是我得到的.

PS C:\> $PSVersionTable.PSVersion

Major  Minor  Build  Revision
-----  -----  -----  --------
4      0      -1     -1

PS C:\> ${ENV:PATH} = "C:\WINDOWS\System32\"
PS C:\> ls ${ENV:PATH}\cmd.exe


Directory: C:\WINDOWS\System32


Mode                LastWriteTime     Length Name
----                -------------     ------ ----
-a---        22/08/2013   8:03 PM     355840 cmd.exe

PS C:\> & cmd.exe
& : The term 'cmd.exe' is not recognized as the name of a cmdlet, function, script file, or operable program. Check
the spelling of the name, or if a path was included, verify that the …
Run Code Online (Sandbox Code Playgroud)

powershell

2
推荐指数
1
解决办法
1403
查看次数

Azure.Security.KeyVault.Secrets 中的 Azure.RequestFailedException

我开发了一个在 Azure 虚拟机规模集中运行的服务,该服务从 Azure Key Vault 访问配置。最近在调试这个服务的RequestFailedException时候,访问配置的时候就开始收到了。

在 Azure 中,Key Vault 通过具有适当权限的用户分配的托管标识进行访问。该服务目前在 Azure 中运行良好,但我无法在本地调试。我在 Visual Studio 2019 版本 16.8.6 的 Azure 服务身份验证配置部分选择了我的 Azure 帐户,并且该帐户具有对 Key Vault 的权限(配置为允许从所有网络访问)。

这是一个片段,显示了我如何在.NET Core 3.1平台上使用Azure Identity 1.2.2Azure.Security.KeyVault.Secrets 4.1.0访问密钥保管库:

private const string KeyVault = "https://<key vault name>.vault.azure.net/";

var client = new SecretClient(new Uri(KeyVault), new DefaultAzureCredential());
var secret = client.GetSecret("<name of secret in key vault>");
Run Code Online (Sandbox Code Playgroud)

显然DefaultAzureCredential使用VisualStudioCredential来解决访问,但是这在某种程度上被 Visual Studio 的更新(自我上次成功调试会话以来唯一更改的)或可能来自 Azure Key Vault 的策略更改所破坏。

完全例外

Exception …
Run Code Online (Sandbox Code Playgroud)

azure azure-keyvault azure-authentication azure-managed-identity

2
推荐指数
1
解决办法
1185
查看次数