Blame SOURCES/0043-CRYPTO-Save-prefix-in-s3crypt_sha512.patch

ca1eb8
From 62cfc6d28b770f56fcb103eeed32e961d3531f3d Mon Sep 17 00:00:00 2001
ca1eb8
From: Lukas Slebodnik <lslebodn@redhat.com>
ca1eb8
Date: Tue, 31 Jul 2018 20:44:06 +0000
ca1eb8
Subject: [PATCH] CRYPTO: Save prefix in s3crypt_sha512
ca1eb8
ca1eb8
Since commit 2951a9a84bd85f384213a3e071ffc167907df2d7 where we switched from
ca1eb8
stpncpy to memcpy the salt prefix "$6$" is not stored at all.
ca1eb8
This broke offline authentication if someone upgraded from old version
ca1eb8
that stored the prefix to one that doesn't store it.
ca1eb8
ca1eb8
Resolves:
ca1eb8
https://pagure.io/SSSD/sssd/issue/3791
ca1eb8
ca1eb8
Merges: https://pagure.io/SSSD/sssd/pull-request/3792
ca1eb8
ca1eb8
Reviewed-by: Jakub Hrozek <jhrozek@redhat.com>
ca1eb8
---
ca1eb8
 src/util/crypto/libcrypto/crypto_sha512crypt.c | 1 +
ca1eb8
 src/util/crypto/nss/nss_sha512crypt.c          | 1 +
ca1eb8
 2 files changed, 2 insertions(+)
ca1eb8
ca1eb8
diff --git a/src/util/crypto/libcrypto/crypto_sha512crypt.c b/src/util/crypto/libcrypto/crypto_sha512crypt.c
ca1eb8
index 5861f34b9325f7552491a07e8b85fe35ca5ae607..2275ccd96212b28984e47c128ba2acb233b865d0 100644
ca1eb8
--- a/src/util/crypto/libcrypto/crypto_sha512crypt.c
ca1eb8
+++ b/src/util/crypto/libcrypto/crypto_sha512crypt.c
ca1eb8
@@ -278,6 +278,7 @@ static int sha512_crypt_r(const char *key,
ca1eb8
     }
ca1eb8
 
ca1eb8
     cp = memcpy(buffer, sha512_salt_prefix, SALT_PREF_SIZE);
ca1eb8
+    cp += SALT_PREF_SIZE;
ca1eb8
     buflen -= SALT_PREF_SIZE;
ca1eb8
 
ca1eb8
     if (rounds_custom) {
ca1eb8
diff --git a/src/util/crypto/nss/nss_sha512crypt.c b/src/util/crypto/nss/nss_sha512crypt.c
ca1eb8
index 709cf51961bb7069ddebf3d636aa29b020756f0a..4d0594d9f21f0fe4228037901c6792625bd4f7c6 100644
ca1eb8
--- a/src/util/crypto/nss/nss_sha512crypt.c
ca1eb8
+++ b/src/util/crypto/nss/nss_sha512crypt.c
ca1eb8
@@ -268,6 +268,7 @@ static int sha512_crypt_r(const char *key,
ca1eb8
     }
ca1eb8
 
ca1eb8
     cp = memcpy(buffer, sha512_salt_prefix, SALT_PREF_SIZE);
ca1eb8
+    cp += SALT_PREF_SIZE;
ca1eb8
     buflen -= SALT_PREF_SIZE;
ca1eb8
 
ca1eb8
     if (rounds_custom) {
ca1eb8
-- 
ca1eb8
2.14.4
ca1eb8