~ubuntu-branches/ubuntu/wily/pianobar/wily-proposed

« back to all changes in this revision

Viewing changes to src/libpiano/crypt.c

  • Committer: Package Import Robot
  • Author(s): Luke Faraone
  • Date: 2012-03-10 04:55:05 UTC
  • mfrom: (1.3.8)
  • Revision ID: package-import@ubuntu.com-20120310045505-cz2aqq552pbjp8o5
Tags: 2012.01.10-1
* New upstream version. (closes: #655744)
* Update debian/watch to point to new download URL.
* Review and update debian/copyright.
* Compy with standards version 3.9.2.

Show diffs side-by-side

added added

removed removed

Lines of Context:
27
27
#include <stdint.h>
28
28
#include <arpa/inet.h>
29
29
 
 
30
#include "crypt.h"
30
31
#include "crypt_key_output.h"
31
32
#include "crypt_key_input.h"
32
33
#include "piano_private.h"
46
47
 */
47
48
#define INITIAL_SHIFT 28
48
49
#define SHIFT_DEC 4
49
 
unsigned char *PianoDecryptString (const unsigned char *strInput) {
 
50
char *PianoDecryptString (const char * const s) {
 
51
        const unsigned char *strInput = (const unsigned char *) s;
50
52
        /* hex-decode => strlen/2 + null-byte */
51
53
        uint32_t *iDecrypt;
52
 
        unsigned char *strDecrypted;
 
54
        char *strDecrypted;
53
55
        unsigned char shift = INITIAL_SHIFT, intsDecoded = 0, j;
54
56
        /* blowfish blocks, 32-bit */
55
57
        uint32_t f, l, r, lrExchange;
56
58
 
57
 
        if ((iDecrypt = calloc (strlen ((char *) strInput)/2/sizeof (*iDecrypt)+1,
 
59
        if ((iDecrypt = calloc (strlen ((const char *) strInput)/2/sizeof (*iDecrypt)+1,
58
60
                        sizeof (*iDecrypt))) == NULL) {
59
61
                return NULL;
60
62
        }
61
 
        strDecrypted = (unsigned char *) iDecrypt;
 
63
        strDecrypted = (char *) iDecrypt;
62
64
 
63
65
        while (*strInput != '\0') {
64
66
                /* hex-decode string */
119
121
 *      @param encrypt this
120
122
 *      @return encrypted, hex-encoded string
121
123
 */
122
 
unsigned char *PianoEncryptString (const unsigned char *strInput) {
123
 
        const size_t strInputN = strlen ((char *) strInput);
 
124
char *PianoEncryptString (const char *s) {
 
125
        const unsigned char *strInput = (const unsigned char *) s;
 
126
        const size_t strInputN = strlen ((const char *) strInput);
124
127
        /* num of 64-bit blocks, rounded to next block */
125
128
        size_t blockN = strInputN / 8 + 1;
126
129
        uint32_t *blockInput, *blockPtr;
193
196
 
194
197
        free (blockInput);
195
198
 
196
 
        return strHex;
 
199
        return (char *) strHex;
197
200
}