我在我的android项目中使用AES GCM身份验证,它工作正常.但与openssl API生成标记相比,在验证标记时遇到一些问题.请在下面找到java代码:
SecretKeySpec skeySpec = new SecretKeySpec(key, "AES");
byte[] iv = generateRandomIV();
IvParameterSpec ivspec = new IvParameterSpec(iv);
Cipher cipher = Cipher.getInstance("AES/GCM/NoPadding");
cipher.init(Cipher.ENCRYPT_MODE, skeySpec, ivspec);
int outputLength = cipher.getOutputSize(data.length); // Prepare output buffer
byte[] output = new byte[outputLength];
int outputOffset = cipher.update(data, 0, data.length, output, 0);// Produce cipher text
outputOffset += cipher.doFinal(output, outputOffset);
Run Code Online (Sandbox Code Playgroud)
我在iOS中使用openssl,并使用下面的代码生成身份验证标记
NSMutableData* tag = [NSMutableData dataWithLength:tagSize];
EVP_CIPHER_CTX_ctrl(&ctx, EVP_CTRL_GCM_GET_TAG, [tag length], [tag mutableBytes])
Run Code Online (Sandbox Code Playgroud)
在java或bouncy castle中,无法获得openssl返回的确切身份验证标记,并且可以帮助我解决此问题.谢谢
我们正在EBS优化的m3.xlarge EC2实例上测试标准EBS卷,EBS卷和加密.
在分析测试结果的同时,我们逐渐了解了这一点
与没有加密的EBS相比,具有加密的EBS卷在读取,写入,读取/写入操作期间花费的时间更少.我认为由于每个I/O请求都有额外的加密开销,因此会对加密的EBS卷产生延迟的影响.
EBS加密卷比普通EBS卷更快的原因是什么?
预期结果应该是EBS应该产生加密EEBS的更好结果.
结果:
加载EBS结果:
sysbench 0.4.12: multi-threaded system evaluation benchmark
Running the test with following options:
Number of threads: 8
Initializing random number generator from timer.
Extra file open flags: 16384
8 files, 512Mb each
4Gb total file size
Block size 16Kb
Calling fsync() at the end of test, Enabled.
Using synchronous I/O mode
Doing sequential write (creation) test
Threads started!
Done.
Operations performed: 0 Read, 262144 Write, 8 Other = 262152 Total
Read 0b Written …Run Code Online (Sandbox Code Playgroud) 我是新来的passport及passport-saml,我试图建立一个Node.js的使用我们的大学对单点登录的Shibboleth标识提供服务器.我非常接近让它全部正常工作,但我在/ login/callback期间遇到了障碍,我认为这与加密配置有关.
我能够将客户端重定向到登录页面,并且在成功登录后,IdP会将POST返回到我的/ login/callback路由.然后我收到这个错误:
Error: Invalid signature at SAML.validatePostResponse (.../node_modules/passport-saml/lib/passport-saml/saml.js:357:21) at Strategy.authenticate (.../node_modules/passport-saml/lib/passport-saml/strategy.js:68:18) at ...etc...
Run Code Online (Sandbox Code Playgroud)
这听起来像我传递给cert配置设置的证书可能不正确?我假设decryptionPvk和cert配置设置应该是我用来创建我的服务器证书的私钥,以及身份提供商的HTTPS证书?或者他们应该是别的什么?
我正在使用最新版本的节点和所有各种模块(快递,护照,护照,saml等)
作为参考,这是我用来测试所有这些的服务器脚本:
"use strict;"
var https = require('https');
var fs = require('fs');
var express = require("express");
var morgan = require('morgan');
var bodyParser = require('body-parser');
var cookieParser = require('cookie-parser');
var session = require('express-session');
var passport = require('passport');
var saml = require('passport-saml');
var cert = fs.readFileSync('./certs/my-server-https-cert.crt', 'utf-8');
var pvk = fs.readFileSync('./certs/my-server-private.key', 'utf-8'); …Run Code Online (Sandbox Code Playgroud) 我正在尝试使用c ++ openssl和aes cbc加密和解密字符串.
关于这一点的奇怪之处在于,它可以在一台PC上运行,而在另一台PC上却没有.我只有3/4的原始字符串,所以结尾是错误的.
另一个奇怪的是,当我在第二台PC上的exe文件目录中添加一个名为"libeay32.dll"的DLL时,它可以工作,但不能在第一台PC上运行.
总之,第一台PC只能在没有dll的情况下工作,第二台PC只能用于dll.
我的问题是,这段代码可以改进吗,为什么在一台计算机上需要这个dll而在另一台计算机上不需要.
这是我已经写的:
KEY和Iv定义如下:
#define KEY "abc"
#define Iv "abc"
Run Code Online (Sandbox Code Playgroud)
加密功能:
string aes_encrypt(string _InStr)
{
string EncKey,
EncIV;
AES_KEY enc_key;
unsigned char * aes_key = (unsigned char *) malloc (sizeof(unsigned char) * (32)),
* iv_enc = (unsigned char *) malloc (sizeof(unsigned char) * AES_BLOCK_SIZE),
* aes_input = (unsigned char *) malloc (sizeof(unsigned char) * _InStr.size ()),
* enc_out = (unsigned char *) malloc (sizeof(unsigned char) * ((_InStr.size () + AES_BLOCK_SIZE) / AES_BLOCK_SIZE) * AES_BLOCK_SIZE); …Run Code Online (Sandbox Code Playgroud) 我一直在阅读很多关于GCM的内容以及它有多棒,我想知道如何使用PHP进行AES-GCM认证加密.是否支持?我在Codeigniter框架文档中找到了一些对GCM的引用,这使我相信它可以在Codeigniter中使用.mcrypt()
我还在一篇关于Zend的文档中发现了一些东西.我不打算使用Codeigniter驱动程序,因为我不使用任何框架,也不打算用于我当前的项目.在我看来,如果Codeigniter能够做到这一点,那么我们应该能够没有框架.
似乎GCM是实现安全性和性能的方式(我看到非常令人印象深刻的性能数据).我的感觉是我们需要这个,但我找不到任何例子.有人必须知道如何实现这一目标.我知道OpenSSL支持它.
任何帮助将不胜感激.
我使用以下代码和类从AES_CMAC生成多样化密钥.每次给定输入时,doFinal方法返回不同的键,而masterKey是常量.
public byte[] calculateDiverseKey(byte [] input) throws InvalidKeyException, NoSuchAlgorithmException {
AesCmac mac = null;
mac = new AesCmac();
SecretKey key = new SecretKeySpec(masterKey, "AES");
mac.init(key); //set master key
mac.updateBlock(input); //given input
for (byte b: input) System.out.print(" "+b);
return mac.doFinal();
}
Run Code Online (Sandbox Code Playgroud)
AesCmac.java类
//package fi.aalto.spothip.crypto;
import java.security.InvalidKeyException;
import java.security.Key;
import java.security.NoSuchAlgorithmException;
import javax.crypto.*;
import javax.crypto.spec.SecretKeySpec;
public class AesCmac {
private static final byte CONSTANT = (byte) 0x87;
private static final int BLOCK_SIZE = 16;
private int macLength;
private Cipher aesCipher;
private byte[] …Run Code Online (Sandbox Code Playgroud) 鉴于Laravel Crypt总是添加盐,因此没有相同加密的两个实例是相同的.
通常,这很好,因为我可以比较两者的解密版本.但是,如果我想搜索在数据库中加密的值,该怎么办?
假设我有一张桌子,users我想加密电子邮件地址.现在我想通过电子邮件找到某人test@email.com.
我该如何为此编写查询?我不能只是Crypt::encrypt($email)和搜索,因为这个迭代encrypt将不同于数据库中的那个.
编辑
目前,我能想到的唯一的事情是获取所有内容,并通过它们进行过滤:
$match = User::all()->filter(function($record) use($email) {
$field = $record->email['email'];
if(Crypt::decrypt($field) == $email) return $record;
});
Run Code Online (Sandbox Code Playgroud)
但这太可怕了.我不想搜索所有内容.
我正在研究配置Java客户端,它的工作是与服务器建立TLS连接.我想用这3个密码配置我的客户端:
TLS_RSA_WITH_RC4_128_SHA
TLS_RSA_WITH_3DES_EDE_CBC_SHA
TLS_RSA_WITH_RC4_128_MD5
Run Code Online (Sandbox Code Playgroud)
在Java支持的密码套件中,我发现了相同的密码,但在开头的时候使用了SSL NOT TLS.问题,如果我配置我的客户:
SSL_RSA_WITH_RC4_128_SHA
SSL_RSA_WITH_3DES_EDE_CBC_SHA
SSL_RSA_WITH_RC4_128_MD5
Run Code Online (Sandbox Code Playgroud)
两个列表是否完全相同,服务器是否会解释相同?我担心如果我使用SSL_*密码配置客户端这意味着不同的东西TLS_*,可能是某些服务器不支持SSL_*.我怎么能确定?
我已经环顾四周,因为我不是安全或加密专家,我仍然对如何在我的程序中实现加密感到困惑.我需要一台服务器登录其gitHub帐户以更新带有特殊标头的代码文件.我现在唯一的挂断是如何存储/检索服务器的凭据.
PushOptions push = new PushOptions
{
Credentials =
new UsernamePasswordCredentials
{
Password = "password",
Username = "Username"
}
};
Run Code Online (Sandbox Code Playgroud)
我如何加密这些凭据以进行存储?我知道将它们存储在代码中是一个坏主意,就像示例那样,并且将它们存储在未加密的任何文件中也是一个坏主意.
此外,我想要的唯一用户交互是在服务器上编译和设置程序时发生的.它是Linux服务器上的cronjob,以防万一.需要注意的另一个细节是,我使用的是libgit2sharp,但之前使用的是bash脚本和ssh进行身份验证以进行测试.
我正在使用Spring Boot 1.2.3,我想了解是否可以在将属性值注入带注释的bean之前对其进行解密@ConfigurationProperties.
假设我在application.properties文件中有以下内容:
appprops.encryptedProperty=ENC(ENCRYPTEDVALUE)
和这样的示例应用程序:
package aaa.bb.ccc.propertyresearch;
import org.springframework.boot.SpringApplication;
import org.springframework.boot.autoconfigure.SpringBootApplication;
import org.springframework.boot.context.properties.ConfigurationProperties;
import org.springframework.boot.context.properties.EnableConfigurationProperties;
import javax.annotation.PostConstruct;
@SpringBootApplication
@EnableConfigurationProperties(PropertyResearchApplication.ApplicationProperties.class)
public class PropertyResearchApplication {
public static void main(String[] args) {
SpringApplication.run(PropertyResearchApplication.class, args);
}
@ConfigurationProperties("appprops")
public static class ApplicationProperties {
private String encryptedProperty;
@PostConstruct
public void postConstruct() throws Exception {
System.out.println("ApplicationProperties --> appprops.encryptedProperty = " + encryptedProperty);
}
public String getEncryptedProperty() {
return encryptedProperty;
}
public void setEncryptedProperty(String encryptedProperty) {
this.encryptedProperty = encryptedProperty;
}
}
} …Run Code Online (Sandbox Code Playgroud) encryption ×10
java ×4
aes ×3
aes-gcm ×2
amazon-ec2 ×1
android ×1
c# ×1
c++ ×1
cryptography ×1
debugging ×1
dll ×1
ios ×1
laravel ×1
laravel-4 ×1
libgit2sharp ×1
mcrypt ×1
mono ×1
mysql ×1
node.js ×1
openssl ×1
passport.js ×1
php ×1
saml-2.0 ×1
security ×1
shibboleth ×1
sockets ×1
spring ×1
spring-boot ×1
ssl ×1