~ubuntu-branches/ubuntu/raring/freerdp/raring-proposed

« back to all changes in this revision

Viewing changes to libfreerdp/crypto_polarssl.c

  • Committer: Package Import Robot
  • Author(s): Martin Pitt, Jeremy Bicha, Jean-Louis Dupond, Martin Pitt
  • Date: 2012-01-31 10:02:14 UTC
  • mfrom: (1.1.6)
  • Revision ID: package-import@ubuntu.com-20120131100214-jaok3uwvni7sqxth
Tags: 1.0.0-0git1
Upload current Debian packaging git to get this rolling for precise.

[ Jeremy Bicha ]
* New upstream release. Closes: #647498.
* Updated symbols and bumped soname
* debian/control:
  - Added new build dependencies
  - Bump Standards-Version to 3.9.2
* debian/source/format: Set to 3.0 (quilt)
* debian/rules: Turn on strict symbols checking
* debian/watch: Watch github

[ Jean-Louis Dupond ]
* debian/control: Updated homepage
* debian/copyright: Reflect upstream switch to the Apache license

[ Martin Pitt ]
* debian/libfreerdp0.symbols: Fix version number, should
  be 1.0~beta5, not 1.0-beta5.
* debian/control: Add libavcodec-dev build dependency, upstream build system
  checks for that. Thanks Jean-Louis Dupond!

Show diffs side-by-side

added added

removed removed

Lines of Context:
1
 
/* -*- c-basic-offset: 8 -*-
2
 
 FreeRDP: A Remote Desktop Protocol client.
3
 
 PolarSSL Cryptographic Abstraction Layer
4
 
 
5
 
 Copyright (C) Mads Kiilerich <mads@kiilerich.com> 2010
6
 
 
7
 
 This program is free software; you can redistribute it and/or modify
8
 
 it under the terms of the GNU General Public License as published by
9
 
 the Free Software Foundation; either version 2 of the License, or
10
 
 (at your option) any later version.
11
 
 
12
 
 This program is distributed in the hope that it will be useful,
13
 
 but WITHOUT ANY WARRANTY; without even the implied warranty of
14
 
 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
15
 
 GNU General Public License for more details.
16
 
 
17
 
 You should have received a copy of the GNU General Public License
18
 
 along with this program; if not, write to the Free Software
19
 
 Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
20
 
 */
21
 
 
22
 
#include "frdp.h"
23
 
#include "crypto.h"
24
 
#include "mem.h"
25
 
 
26
 
#include <assert.h>
27
 
 
28
 
#include <polarssl/sha1.h>
29
 
#include <polarssl/md5.h>
30
 
#include <polarssl/arc4.h>
31
 
#include <polarssl/x509.h>
32
 
#include <polarssl/rsa.h>
33
 
 
34
 
RD_BOOL
35
 
crypto_global_init(void)
36
 
{
37
 
        return True;
38
 
}
39
 
 
40
 
void
41
 
crypto_global_finish(void)
42
 
{
43
 
}
44
 
 
45
 
 
46
 
struct crypto_sha1_struct
47
 
{
48
 
        sha1_context ctx;
49
 
};
50
 
 
51
 
CryptoSha1
52
 
crypto_sha1_init(void)
53
 
{
54
 
        CryptoSha1 sha1 = xmalloc(sizeof(*sha1));
55
 
        sha1_starts(&sha1->ctx);
56
 
        return sha1;
57
 
}
58
 
 
59
 
void
60
 
crypto_sha1_update(CryptoSha1 sha1, uint8 * data, uint32 len)
61
 
{
62
 
        sha1_update(&sha1->ctx, data, len);
63
 
}
64
 
 
65
 
void
66
 
crypto_sha1_final(CryptoSha1 sha1, uint8 * out_data)
67
 
{
68
 
        sha1_finish(&sha1->ctx, out_data);
69
 
        xfree(sha1);
70
 
}
71
 
 
72
 
 
73
 
struct crypto_md5_struct
74
 
{
75
 
        md5_context ctx;
76
 
};
77
 
 
78
 
CryptoMd5
79
 
crypto_md5_init(void)
80
 
{
81
 
        CryptoMd5 md5 = xmalloc(sizeof(*md5));
82
 
        md5_starts(&md5->ctx);
83
 
        return md5;
84
 
}
85
 
 
86
 
void
87
 
crypto_md5_update(CryptoMd5 md5, uint8 * data, uint32 len)
88
 
{
89
 
        md5_update(&md5->ctx, data, len);
90
 
}
91
 
 
92
 
void
93
 
crypto_md5_final(CryptoMd5 md5, uint8 * out_data)
94
 
{
95
 
        md5_finish(&md5->ctx, out_data);
96
 
        xfree(md5);
97
 
}
98
 
 
99
 
 
100
 
struct crypto_rc4_struct
101
 
{
102
 
        arc4_context ctx;
103
 
};
104
 
 
105
 
CryptoRc4
106
 
crypto_rc4_init(uint8 * key, uint32 len)
107
 
{
108
 
        CryptoRc4 rc4 = xmalloc(sizeof(*rc4));
109
 
        arc4_setup(&rc4->ctx, key, len);
110
 
        return rc4;
111
 
}
112
 
 
113
 
void
114
 
crypto_rc4(CryptoRc4 rc4, uint32 len, uint8 * in_data, uint8 * out_data)
115
 
{
116
 
        arc4_crypt(&rc4->ctx, len, in_data, out_data);
117
 
}
118
 
 
119
 
void
120
 
crypto_rc4_free(CryptoRc4 rc4)
121
 
{
122
 
        xfree(rc4);
123
 
}
124
 
 
125
 
struct crypto_cert_struct
126
 
{
127
 
};
128
 
 
129
 
 
130
 
CryptoCert
131
 
crypto_cert_read(uint8 * data, uint32 len)
132
 
{
133
 
        return NULL;
134
 
}
135
 
 
136
 
void
137
 
crypto_cert_free(CryptoCert cert)
138
 
{
139
 
    xfree(cert);
140
 
}
141
 
 
142
 
RD_BOOL
143
 
crypto_cert_verify(CryptoCert server_cert, CryptoCert cacert)
144
 
{
145
 
        return False;
146
 
}
147
 
 
148
 
int
149
 
crypto_cert_print_fp(FILE * fp, CryptoCert cert)
150
 
{
151
 
        return False;
152
 
}
153
 
 
154
 
int
155
 
crypto_cert_get_pub_exp_mod(CryptoCert cert, uint32 * key_len,
156
 
                uint8 * exponent, uint32 max_exp_len, uint8 * modulus, uint32 max_mod_len)
157
 
{
158
 
        return False;
159
 
}
160
 
 
161
 
void
162
 
crypto_rsa_encrypt(int len, uint8 * in, uint8 * out, uint32 modulus_size, uint8 * modulus, uint8 * exponent)
163
 
{
164
 
        rsa_context ctx;
165
 
        rsa_init(&ctx, 0, 0);
166
 
        ctx.len = modulus_size;
167
 
        mpi_init(&ctx.N, &ctx.E, NULL);
168
 
        mpi_read_binary(&ctx.N, modulus, modulus_size);
169
 
        mpi_read_binary(&ctx.E, exponent, SEC_EXPONENT_SIZE);
170
 
        assert(!rsa_check_pubkey( &ctx ));
171
 
 
172
 
        assert(modulus_size <= SEC_MAX_MODULUS_SIZE);
173
 
        uint8 in2[SEC_MAX_MODULUS_SIZE];
174
 
        memset(in2, 0, modulus_size - len);
175
 
        memcpy(in2 + modulus_size - len, in, len);
176
 
        int err = rsa_public(&ctx, in2, out);
177
 
        assert(!err);
178
 
        mpi_free(&ctx.N, &ctx.E, NULL);
179
 
        rsa_free(&ctx);
180
 
}