Commit b90b143d authored by cRTrn13's avatar cRTrn13
Browse files

Start of openssl -> libgcrypt switchover. libgcrypt is now required bu libbluray

parent aaf8d46a
......@@ -44,6 +44,7 @@ AC_SEARCH_LIBS([gethostbyname], [nsl])
AC_SEARCH_LIBS([socket], [socket inet])
AC_SEARCH_LIBS([crypt], [crypt])
AC_SEARCH_LIBS([dlopen], [dl])
AC_SEARCH_LIBS([gcry_cipher_open], [gcrypt])
AC_CHECK_FUNC([snprintf],
[AC_DEFINE(HAVE_SNPRINTF,1,[Presence of snprintf found])],
......@@ -76,7 +77,7 @@ AC_CACHE_CHECK([for OpenSSL directory], ac_cv_openssl_dir, [
ssl_found=no
for ssldir in $tryssldir "" $prefix /usr/local/openssl /usr/lib/openssl /usr/local/ssl /usr/lib/ssl /usr/local /usr/athena /usr/pkg /opt /opt/openssl ; do
LDFLAGS="$saved_LDFLAGS"
LIBS="$saved_LIBS -lssl -lcrypto"
LIBS="$saved_LIBS -lssl -lcrypto -lgcrypt"
# Skip the directory if it isn't there.
if test ! -z "$ssldir" -a ! -d "$ssldir" ; then
......
......@@ -22,8 +22,9 @@
int _validate_pk(uint8_t *pk, uint8_t *cvalue, uint8_t *uv, uint8_t *vd, uint8_t *mk)
{
int a;
int a, ret = 0;
AES_KEY aes;
gcry_cipher_hd_t gcry_h;
uint8_t dec_vd[16];
DEBUG(DBG_AACS, "Validate processing key %s...\n", print_hex(pk, 16));
......@@ -32,22 +33,32 @@ int _validate_pk(uint8_t *pk, uint8_t *cvalue, uint8_t *uv, uint8_t *vd, uint8_t
DEBUG(DBG_AACS, " cvalue: %s\n", print_hex(cvalue, 16));
DEBUG(DBG_AACS, " Verification data: %s\n", print_hex(vd, 16));
AES_set_decrypt_key(pk, 128, &aes);
AES_decrypt(cvalue, mk, &aes);
gcry_cipher_open(&gcry_h, GCRY_CIPHER_AES, GCRY_CIPHER_MODE_ECB, NULL);
gcry_cipher_setkey(gcry_h, pk, 16);
gcry_cipher_decrypt (gcry_h, mk, 16, cvalue, 16);
//AES_set_decrypt_key(pk, 128, &aes);
//AES_decrypt(cvalue, mk, &aes);
for (a = 0; a < 4; a++) {
mk[a + 12] ^= uv[a];
}
AES_set_decrypt_key(mk, 128, &aes);
AES_decrypt(vd, dec_vd, &aes);
gcry_cipher_setkey(gcry_h, mk, 16);
gcry_cipher_decrypt (gcry_h, dec_vd, 16, vd, 16);
// AES_set_decrypt_key(mk, 128, &aes);
// AES_decrypt(vd, dec_vd, &aes);
if (!memcmp(dec_vd, "\x01\x23\x45\x67\x89\xAB\xCD\xEF", 8)) {
DEBUG(DBG_AACS, "Processing key is valid!\n");
return 1;
ret = 1;
}
return 0;
gcry_cipher_close(gcry_h);
return ret;
}
int _calc_mk(AACS *aacs, const char *path)
......@@ -317,6 +328,8 @@ AACS *aacs_open(const char *path, const char *configfile_path)
AACS *aacs = calloc(1, sizeof(AACS));
gcry_cipher_open (aacs->gcry_h, GCRY_CIPHER_AES, GCRY_CIPHER_MODE_ECB, NULL);
aacs->uks = NULL;
aacs->kf = NULL;
if ((aacs->kf = configfile_open(configfile_path))) {
......
......@@ -8,6 +8,7 @@
#include <stdint.h>
#include <unistd.h>
#include <openssl/aes.h>
#include <gcrypt.h>
#include "mkb.h"
#include "../file/configfile.h"
......@@ -22,6 +23,7 @@ struct aacs {
uint8_t iv[16];
AES_KEY aes;
CONFIGFILE *kf;
gcry_cipher_hd_t gcry_h;
};
AACS *aacs_open(const char *path, const char *keyfile_path);
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment