added B64_GPG_PREFIX 'hQ' string for GnuPG prefix handling (similar to the 'Salted__' handling for Rijndael SPA packet encryption

git-svn-id: file:///home/mbr/svn/fwknop/trunk@111 510a4753-2344-4c79-9c09-4d669213fbeb
This commit is contained in:
Michael Rash 2009-07-16 00:28:04 +00:00
parent 111d24c89b
commit 31ef94024c
2 changed files with 9 additions and 4 deletions

View File

@ -119,14 +119,14 @@ _rijndael_decrypt(fko_ctx_t ctx, char *dec_key, int b64_len)
if(tbuf == NULL) if(tbuf == NULL)
return(FKO_ERROR_MEMORY_ALLOCATION); return(FKO_ERROR_MEMORY_ALLOCATION);
memmove(tbuf+10, tbuf, b64_len); memmove(tbuf+strlen(B64_RIJNDAEL_SALT), tbuf, b64_len);
ctx->encrypted_msg = memcpy(tbuf, B64_RIJNDAEL_SALT, strlen(B64_RIJNDAEL_SALT)); ctx->encrypted_msg = memcpy(tbuf, B64_RIJNDAEL_SALT, strlen(B64_RIJNDAEL_SALT));
/* Adjust b64_len for added SALT value and Make sure we are still /* Adjust b64_len for added SALT value and Make sure we are still
* a properly NULL-terminated string (Ubuntu was one system for * a properly NULL-terminated string (Ubuntu was one system for
* which this was an issue). * which this was an issue).
*/ */
b64_len += 10; b64_len += strlen(B64_RIJNDAEL_SALT);
tbuf[b64_len] = '\0'; tbuf[b64_len] = '\0';
} }

View File

@ -30,6 +30,7 @@
* of Rijndael encrypted data. * of Rijndael encrypted data.
*/ */
#define B64_RIJNDAEL_SALT "U2FsdGVkX1" #define B64_RIJNDAEL_SALT "U2FsdGVkX1"
#define B64_GPG_PREFIX "hQ"
/* Initialize an fko context. /* Initialize an fko context.
*/ */
@ -303,10 +304,14 @@ fko_get_spa_data(fko_ctx_t ctx, char **spa_data)
*spa_data = ctx->encrypted_msg; *spa_data = ctx->encrypted_msg;
/* Notice we omit the first 10 bytes if Rijndael encryption is /* Notice we omit the first 10 bytes if Rijndael encryption is
* used (to eliminate the consistent 'Salted__' string). * used (to eliminate the consistent 'Salted__' string), and
* in GnuPG mode we eliminate the consistent 'hQ' base64 encoded
* prefix
*/ */
if(ctx->encryption_type == FKO_ENCRYPTION_RIJNDAEL) if(ctx->encryption_type == FKO_ENCRYPTION_RIJNDAEL)
*spa_data += 10; *spa_data += strlen(B64_RIJNDAEL_SALT);
else if(ctx->encryption_type == FKO_ENCRYPTION_GPG)
*spa_data += strlen(B64_GPG_PREFIX);
return(FKO_SUCCESS); return(FKO_SUCCESS);
} }