~ubuntu-branches/ubuntu/trusty/postgresql-8.4/trusty

« back to all changes in this revision

Viewing changes to contrib/pgcrypto/pgp-cfb.c

  • Committer: Bazaar Package Importer
  • Author(s): Martin Pitt
  • Date: 2009-07-11 16:59:35 UTC
  • mfrom: (5.1.1 karmic)
  • Revision ID: james.westby@ubuntu.com-20090711165935-jfwin6gfrxf0gfsi
Tags: 8.4.0-2
* debian/libpq-dev.install: Ship catalog/genbki.h. (Closes: #536139)
* debian/rules: Drop --enable-cassert for final release.

Show diffs side-by-side

added added

removed removed

Lines of Context:
26
26
 * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
27
27
 * SUCH DAMAGE.
28
28
 *
29
 
 * $PostgreSQL: pgsql/contrib/pgcrypto/pgp-cfb.c,v 1.3 2005/10/15 02:49:06 momjian Exp $
 
29
 * $PostgreSQL: pgsql/contrib/pgcrypto/pgp-cfb.c,v 1.4 2009/06/11 14:48:52 momjian Exp $
30
30
 */
31
31
 
32
32
#include "postgres.h"
35
35
#include "px.h"
36
36
#include "pgp.h"
37
37
 
38
 
typedef int (*mix_data_t) (PGP_CFB * ctx, const uint8 *data, int len, uint8 *dst);
 
38
typedef int (*mix_data_t) (PGP_CFB *ctx, const uint8 *data, int len, uint8 *dst);
39
39
 
40
40
struct PGP_CFB
41
41
{
50
50
};
51
51
 
52
52
int
53
 
pgp_cfb_create(PGP_CFB ** ctx_p, int algo, const uint8 *key, int key_len,
 
53
pgp_cfb_create(PGP_CFB **ctx_p, int algo, const uint8 *key, int key_len,
54
54
                           int resync, uint8 *iv)
55
55
{
56
56
        int                     res;
82
82
}
83
83
 
84
84
void
85
 
pgp_cfb_free(PGP_CFB * ctx)
 
85
pgp_cfb_free(PGP_CFB *ctx)
86
86
{
87
87
        px_cipher_free(ctx->ciph);
88
88
        memset(ctx, 0, sizeof(*ctx));
93
93
 * Data processing for normal CFB.      (PGP_PKT_SYMENCRYPTED_DATA_MDC)
94
94
 */
95
95
static int
96
 
mix_encrypt_normal(PGP_CFB * ctx, const uint8 *data, int len, uint8 *dst)
 
96
mix_encrypt_normal(PGP_CFB *ctx, const uint8 *data, int len, uint8 *dst)
97
97
{
98
98
        int                     i;
99
99
 
104
104
}
105
105
 
106
106
static int
107
 
mix_decrypt_normal(PGP_CFB * ctx, const uint8 *data, int len, uint8 *dst)
 
107
mix_decrypt_normal(PGP_CFB *ctx, const uint8 *data, int len, uint8 *dst)
108
108
{
109
109
        int                     i;
110
110
 
124
124
 * thus its all concentrated here.
125
125
 */
126
126
static int
127
 
mix_encrypt_resync(PGP_CFB * ctx, const uint8 *data, int len, uint8 *dst)
 
127
mix_encrypt_resync(PGP_CFB *ctx, const uint8 *data, int len, uint8 *dst)
128
128
{
129
129
        int                     i,
130
130
                                n;
156
156
}
157
157
 
158
158
static int
159
 
mix_decrypt_resync(PGP_CFB * ctx, const uint8 *data, int len, uint8 *dst)
 
159
mix_decrypt_resync(PGP_CFB *ctx, const uint8 *data, int len, uint8 *dst)
160
160
{
161
161
        int                     i,
162
162
                                n;
196
196
 * common code for both encrypt and decrypt.
197
197
 */
198
198
static int
199
 
cfb_process(PGP_CFB * ctx, const uint8 *data, int len, uint8 *dst,
 
199
cfb_process(PGP_CFB *ctx, const uint8 *data, int len, uint8 *dst,
200
200
                        mix_data_t mix_data)
201
201
{
202
202
        int                     n;
249
249
 */
250
250
 
251
251
int
252
 
pgp_cfb_encrypt(PGP_CFB * ctx, const uint8 *data, int len, uint8 *dst)
 
252
pgp_cfb_encrypt(PGP_CFB *ctx, const uint8 *data, int len, uint8 *dst)
253
253
{
254
254
        mix_data_t      mix = ctx->resync ? mix_encrypt_resync : mix_encrypt_normal;
255
255
 
257
257
}
258
258
 
259
259
int
260
 
pgp_cfb_decrypt(PGP_CFB * ctx, const uint8 *data, int len, uint8 *dst)
 
260
pgp_cfb_decrypt(PGP_CFB *ctx, const uint8 *data, int len, uint8 *dst)
261
261
{
262
262
        mix_data_t      mix = ctx->resync ? mix_decrypt_resync : mix_decrypt_normal;
263
263