我有行车记录仪公司卡,用于在允许他通过远程下载下载行车记录仪的数据之前对客户端进行身份验证.我的代码中使用的APDU命令是在行车记录仪和公司卡之间成功验证的命令.
双方之间的联系如下:
行车记录仪< - 可以连线 - >设备<---蓝牙 - > Android应用程序< - 套接字API - >公司卡服务器< - USB电缆 - >公司读卡器< - >公司卡.
如上所述的通信运行良好,并且app用户正在进行身份验证.现在我试图直接从公司卡上读取一些信息而不使用以下应用程序:
我的客户端程序< - >读卡器< - >公司卡
在我的客户端程序中,我使用从Android应用程序发送到公司卡的相同APDU命令.目前,我正面临INS标签"82"的外部认证问题.我收到的错误66 88意味着wrong certification.
我已经下载了认证文件,D__TCC40-1.bin从
https://dtc.jrc.ec.europa.eu/dtc_public_key_certificates.php
公钥认证内容描述如下:
128字节签名+ 58字节公钥提醒+ 8字节证书Authorithy Reference = 194字节
在读取文件时,D__TCC40-1.bin它具有194字节长度(公司卡也使用长度为194的认证).外部认证从'84'INS命令开始低音开始.该命令由终端发送到智能卡,以提供8位数的随机数.随后,终端接收随机数并使用一些使用公钥进行加密的加密算法对其进行加密.然后,终端通过算法将带有82INS标签的加密号码发送到智能卡.
现在我正在尝试D__TCC40-1.bin从项目根目录加载下载的证书并使用它来加密我使用GET CHALLANGE 84INS标记获得的8位数随机数,但我不知道如何使用alogrithm 加密它以发送其结果到智能卡.我如何使用Public Key Certificateencyrpte随机数将其发送到智能卡以获得90 00响应?目前,正如我之前提到的,我正在66 88作为回应.
***码*
import java.io.FileInputStream;
import java.io.FileNotFoundException;
import java.io.IOException;
import java.util.List;
import javax.smartcardio.ATR;
import …Run Code Online (Sandbox Code Playgroud) 我的应用程序中有以下加密功能:
public static String encrypt(String key, String value) {
try {
IvParameterSpec iv = new IvParameterSpec(key.substring(0, 16).getBytes("UTF-8"));
SecretKeySpec skeySpec = new SecretKeySpec(key.getBytes("UTF-8"), "AES");
Cipher cipher = Cipher.getInstance("AES/CBC/PKCS5Padding");
cipher.init(Cipher.ENCRYPT_MODE, skeySpec, iv);
byte[] encrypted = cipher.doFinal(value.getBytes("UTF-8"));
return Base64.encodeBase64String(encrypted);
} catch (Exception ex) {
ex.printStackTrace();
}
return null;
}
Run Code Online (Sandbox Code Playgroud)
和在PHP加密的消息是使用解码openssl_decrypt()用AES-128-CBC组作为进行加密的方法.
然而,解密总是失败我从服务器得到的响应是它无法识别加密方法.
我无法控制服务器,因此我无法仅在我的Java应用程序中更改任何内容.
我尝试了不同的模式,AES/CBC/NoPadding但我得到了一个例外
Input Length Not Multiple of 16 bytes
Run Code Online (Sandbox Code Playgroud)
现在我知道加密没有任何问题,因为我能够在使用AES/CBC/PKCS5Padding它时在我的java应用程序中进行加密和解密,只是在发布到服务器时失败了.
密钥是md5哈希.
这是我需要加密的数据示例:
{
"merchant_id": "EXX-00000001",
"user_id": "000000000001",
"code": "000200",
"details": {
"acc_no": "1234691007924321",
"exp": …Run Code Online (Sandbox Code Playgroud) 我一直在想办法用python3从密码保护的pdf中获取页面数.到目前为止,我已经尝试过模块pypdf2和pdfminer2.两者都失败了,因为文件没有被解密.
#!/usr/bin/python3
from PyPDF2 import PdfFileReader
pdfFile = PdfFileReader(open("document.pdf", "rb"))
print(pdfFile.numPages)
Run Code Online (Sandbox Code Playgroud)
此代码将产生错误:
PyPDF2.utils.PdfReadError: File has not been decrypted
Run Code Online (Sandbox Code Playgroud)
有没有办法获得没有解密的页数?
我正在尝试编写并行压缩/加密备份脚本,以使用GNU parallel,xz和GnuPG进行归档。脚本的核心部分是:
tar --create --format=posix --preserve-permissions --same-owner --directory $BASE/$name --to-stdout . \
| parallel --pipe --recend '' --keep-order --block-size 128M "xz -9 --check=sha256 | gpg --encrypt --recipient $RECIPIENT" \
| pv > $TARGET/$FILENAME
Run Code Online (Sandbox Code Playgroud)
没有GnuPG加密,它会很好地工作(解压缩和解压缩工作),但是添加并行加密后,它解密失败,并出现以下错误:
[don't know]: invalid packet (ctb=0a)
gpg: WARNING: encrypted message has been manipulated!
gpg: decrypt_message failed: Unexpected error
: Truncated tar archive
tar: Error exit delayed from previous errors.
Run Code Online (Sandbox Code Playgroud)
因为未压缩的大小与gnu parallel的块大小相同(大约125M),所以我认为这与GnuPG对部分块加密的支持有关。我怎么解决这个问题?
费耶
关于随机数生成的另一个并行gpg加密问题
https://unix.stackexchange.com/questions/105059/parallel-pausing-and-resuming
我正在使用Ansible 2.2从我的笔记本电脑管理一些云服务器.我想将OpenSSL私钥传输到其中一个服务器上的特定位置,以供nginx用于TLS终止.当然,这是一个应保密的文件,因此我使用Ansible Vault对其进行了加密.但Vault仅保护控制计算机上的磁盘文件.将数据从控制机器传输到受管节点时,它不起作用.
我想确保监控网络流量的人在传输过程中不会泄露私钥.我没有具体提到我正在寻找的内容,我可以在模块的文档中copy看到.据我所知,我与被管节点的所有通信都是通过SSH完成的.这是一个安全的假设吗?它是否包含文件传输?
我想在C中使用小型AES库(https://github.com/kokke/tiny-AES-c)进行AES128 加密。
我的代码如下:
unsigned char cipher[64];
unsigned char in[] = "THJmaoeuf2jsn4jebc7ak3mUdnyHeklOYopdna/OOndu3bis/E7jTd/enasduR3h"; //64 bits
printf("Size of AES input msg: %d \n", sizeof(in));
unsigned char key[] = "Gns7AauH3dnaod=="; //16 bits
unsigned char IV[] = "vhdNaleuTHenaOlL"; //16 bits
printf("cipher(before): %x \n", cipher);
AES128_CBC_encrypt_buffer(cipher, in, 64, key, IV);
for(int n=0; n<64; n++){
printf("cipher[%d]: %x \n", n, cipher);
}
Run Code Online (Sandbox Code Playgroud)
我从小型AES 128库中使用的功能是这样的:
void AES128_CBC_encrypt_buffer(uint8_t* output, uint8_t* input, uint32_t length, const uint8_t* key, const uint8_t* iv)
Run Code Online (Sandbox Code Playgroud)
但是,打印“密码”的最后一行为空。我相信它应该在加密后打印原始输入的密文。这是使用库的正确方法吗?谢谢。
编辑:我在这里更新了代码,其中“密码”现在以一种奇怪的方式打印字符。它在加密前后会打印相同的内容,但实际情况并非如此。即使我将“键”和“ IV”更改为16位,并输入消息“ in”为64位,情况也是如此。这是输出的一部分:
cipher(before): 20003A34
cipher[0]: 20003A34 …Run Code Online (Sandbox Code Playgroud) 如何使用NodeJS(ExpressJS)实现MS SQL连接和CRUD操作?
我通过设置它来尝试使用乏味options.encrypt = true.但它仍然从我的本地开发服务器返回加密数据.
var config = {
userName: 'sa',
password: 'password',
server: 'localhost',
options: {
database: 'Employees',
encrypt: true
}
}
Run Code Online (Sandbox Code Playgroud) 我正在尝试在python中实现此代码(我是python的新手),它给了我以下错误:
AttributeError:'str'对象没有属性'decode'
如果我们删除.decode ('hex')只是为了避免这样的错误:
from itertools import product
from Crypto.Cipher import AES
import Crypto.Cipher.AES
key = ('2b7e151628aed2a6abf7158809cf4f3c').decode('hex')
IV = ('000102030405060708090a0b0c0d0e0f').decode('hex')
plaintext1 = ('6bc1bee22e409f96e93d7e117393172a').decode('hex')
plaintext2 = ('ae2d8a571e03ac9c9eb76fac45af8e51').decode('hex')
plaintext3 = ('30c81c46a35ce411e5fbc1191a0a52ef').decode('hex')
cipher = AES.new(key, AES.MODE_CBC, IV)
ciphertext = cipher.encrypt(plaintext1 + plaintext2 + plaintext3)
(ciphertext).encode('hex')
decipher = AES.new(key, AES.MODE_CBC, IV)
plaintext = decipher.decrypt(ciphertext)
(plaintext).encode('hex')
Run Code Online (Sandbox Code Playgroud)
但它给了我以下错误:
ValueError:IV必须长度为16个字节
因为算法需要.decode ('hex')我必须删除的
from itertools import product
from Crypto.Cipher import AES
import Crypto.Cipher.AES
key = ('2b7e151628aed2a6abf7158809cf4f3c')
IV = ('000102030405060708090a0b0c0d0e0f')
plaintext1 = ('6bc1bee22e409f96e93d7e117393172a')
plaintext2 = …Run Code Online (Sandbox Code Playgroud) 我似乎有Cipher和/或PBEKeySpec的线程安全问题.
我知道如果我们使用相同的实例,这些类不是安全的,但事实并非如此,我在每次解码时都会得到一个新的实例.但即便如此,有时解码失败,也没有例外,只是意外的解码值.
我已经能够重现这个问题:
@Test
public void shouldBeThreadSafe() {
final byte[] encoded = {
27, 26, 18, 88, 84, -87, -40, -91, 70, -74, 87, -21, -124,
-114, -44, -24, 7, -7, 104, -26, 45, 96, 119, 45, -74, 51
};
final String expected = "dummy data";
final Charset charset = StandardCharsets.UTF_8;
final String salt = "e47312da-bc71-4bde-8183-5e25db6f0987";
final String passphrase = "dummy-passphrase";
// Crypto configuration
final int iterationCount = 10;
final int keyStrength = 128; …Run Code Online (Sandbox Code Playgroud) I'm trying to make some keystores using keytool from the latest JRE (version 1.8.0_151). When I create the keystore using this command keytool -genkey -alias serverprivate -keystore server.private -keyalg rsa -storepass apassword -keypass apassword it shows me this warning:
Warning:
The JKS keystore uses a proprietary format. It is recommended to migrate
to PKCS12 which is an industry standard format using "keytool
-importkeystore -srckeystore server.private -destkeystore server.private
-deststoretype pkcs12".
Run Code Online (Sandbox Code Playgroud)
So I type the command, and it says it's done and …