projects
/
silc.git
/ blobdiff
commit
grep
author
committer
pickaxe
?
search:
re
summary
|
shortlog
|
log
|
commit
|
commitdiff
|
tree
raw
|
inline
| side by side
Added SILC Thread Queue API
[silc.git]
/
lib
/
silccrypt
/
silcpk.c
diff --git
a/lib/silccrypt/silcpk.c
b/lib/silccrypt/silcpk.c
index ad03a023610ff65356e1ba9b099a2dc470cfee91..42aada1c1b7c2d7f6c9c6c924a4d74100c79d332 100644
(file)
--- a/
lib/silccrypt/silcpk.c
+++ b/
lib/silccrypt/silcpk.c
@@
-126,7
+126,7
@@
SilcBool silc_pkcs_silc_decode_identifier(const char *identifier,
int len;
/* Protocol says that at least UN and HN must be provided as identifier */
int len;
/* Protocol says that at least UN and HN must be provided as identifier */
- if (!strstr(identifier, "UN=")
&&
!strstr(identifier, "HN=")) {
+ if (!strstr(identifier, "UN=")
||
!strstr(identifier, "HN=")) {
SILC_LOG_DEBUG(("The public does not have the required UN= and HN= "
"identifiers"));
return FALSE;
SILC_LOG_DEBUG(("The public does not have the required UN= and HN= "
"identifiers"));
return FALSE;
@@
-207,9
+207,11
@@
char *silc_pkcs_silc_encode_identifier(SilcStack stack,
SilcBufferStruct buf;
char *identifier;
SilcBufferStruct buf;
char *identifier;
- if (!username || !host)
+ if (!username || !host) {
+ SILC_LOG_ERROR(("Public key identifier is missing UN and/or HN"));
return NULL;
return NULL;
- if (strlen(username) < 3 || strlen(host) < 3)
+ }
+ if (strlen(username) < 1 || strlen(host) < 1)
return NULL;
memset(&buf, 0, sizeof(buf));
return NULL;
memset(&buf, 0, sizeof(buf));
@@
-264,6
+266,7
@@
char *silc_pkcs_silc_encode_identifier(SilcStack stack,
if (version) {
if (strlen(version) > 1 || !isdigit(version[0])) {
silc_buffer_spurge(stack, &buf);
if (version) {
if (strlen(version) > 1 || !isdigit(version[0])) {
silc_buffer_spurge(stack, &buf);
+ SILC_LOG_ERROR(("Public key identifier has invalid version (V)"));
return NULL;
}
silc_buffer_sformat(stack, &buf,
return NULL;
}
silc_buffer_sformat(stack, &buf,
@@
-324,12
+327,12
@@
SILC_PKCS_IMPORT_PUBLIC_KEY_FILE(silc_pkcs_silc_import_public_key_file)
/* Check start of file and remove header from the data. */
len = strlen(SILC_PKCS_PUBLIC_KEYFILE_BEGIN);
if (filedata_len < len + strlen(SILC_PKCS_PUBLIC_KEYFILE_END)) {
/* Check start of file and remove header from the data. */
len = strlen(SILC_PKCS_PUBLIC_KEYFILE_BEGIN);
if (filedata_len < len + strlen(SILC_PKCS_PUBLIC_KEYFILE_END)) {
- SILC_LOG_
ERROR
(("Malformed SILC public key header"));
+ SILC_LOG_
DEBUG
(("Malformed SILC public key header"));
return FALSE;
}
for (i = 0; i < len; i++) {
if (*filedata != SILC_PKCS_PUBLIC_KEYFILE_BEGIN[i]) {
return FALSE;
}
for (i = 0; i < len; i++) {
if (*filedata != SILC_PKCS_PUBLIC_KEYFILE_BEGIN[i]) {
- SILC_LOG_
ERROR
(("Malformed SILC public key header"));
+ SILC_LOG_
DEBUG
(("Malformed SILC public key header"));
return FALSE;
}
filedata++;
return FALSE;
}
filedata++;
@@
-349,7
+352,7
@@
SILC_PKCS_IMPORT_PUBLIC_KEY_FILE(silc_pkcs_silc_import_public_key_file)
break;
}
break;
}
- ret = silc_pkcs_silc_import_public_key(pkcs, filedata, filedata_len,
+ ret = silc_pkcs_silc_import_public_key(pkcs,
NULL,
filedata, filedata_len,
ret_public_key, ret_alg);
silc_free(data);
ret_public_key, ret_alg);
silc_free(data);
@@
-360,7
+363,6
@@
SILC_PKCS_IMPORT_PUBLIC_KEY_FILE(silc_pkcs_silc_import_public_key_file)
SILC_PKCS_IMPORT_PUBLIC_KEY(silc_pkcs_silc_import_public_key)
{
SILC_PKCS_IMPORT_PUBLIC_KEY(silc_pkcs_silc_import_public_key)
{
- const SilcPKCSAlgorithm *alg;
SilcBufferStruct buf, alg_key;
SilcSILCPublicKey silc_pubkey = NULL;
SilcAsn1 asn1 = NULL;
SilcBufferStruct buf, alg_key;
SilcSILCPublicKey silc_pubkey = NULL;
SilcAsn1 asn1 = NULL;
@@
-846,12
+848,12
@@
SILC_PKCS_IMPORT_PRIVATE_KEY_FILE(silc_pkcs_silc_import_private_key_file)
/* Check start of file and remove header from the data. */
len = strlen(SILC_PKCS_PRIVATE_KEYFILE_BEGIN);
if (filedata_len < len + strlen(SILC_PKCS_PRIVATE_KEYFILE_END)) {
/* Check start of file and remove header from the data. */
len = strlen(SILC_PKCS_PRIVATE_KEYFILE_BEGIN);
if (filedata_len < len + strlen(SILC_PKCS_PRIVATE_KEYFILE_END)) {
- SILC_LOG_
ERROR
(("Malformed SILC private key header"));
+ SILC_LOG_
DEBUG
(("Malformed SILC private key header"));
return FALSE;
}
for (i = 0; i < len; i++) {
if (*filedata != SILC_PKCS_PRIVATE_KEYFILE_BEGIN[i]) {
return FALSE;
}
for (i = 0; i < len; i++) {
if (*filedata != SILC_PKCS_PRIVATE_KEYFILE_BEGIN[i]) {
- SILC_LOG_
ERROR
(("Malformed SILC private key header"));
+ SILC_LOG_
DEBUG
(("Malformed SILC private key header"));
return FALSE;
}
filedata++;
return FALSE;
}
filedata++;
@@
-963,8
+965,8
@@
SILC_PKCS_IMPORT_PRIVATE_KEY_FILE(silc_pkcs_silc_import_private_key_file)
silc_cipher_free(aes);
/* Import the private key */
silc_cipher_free(aes);
/* Import the private key */
- ret = silc_pkcs_silc_import_private_key(pkcs,
filedata, len, ret_private_key
,
- ret_alg);
+ ret = silc_pkcs_silc_import_private_key(pkcs,
NULL, filedata
,
+
len, ret_private_key,
ret_alg);
silc_free(data);
silc_free(data);
@@
-980,7
+982,6
@@
SILC_PKCS_IMPORT_PRIVATE_KEY_FILE(silc_pkcs_silc_import_private_key_file)
SILC_PKCS_IMPORT_PRIVATE_KEY(silc_pkcs_silc_import_private_key)
{
SilcBufferStruct buf;
SILC_PKCS_IMPORT_PRIVATE_KEY(silc_pkcs_silc_import_private_key)
{
SilcBufferStruct buf;
- const SilcPKCSAlgorithm *alg;
SilcBufferStruct alg_key;
SilcSILCPrivateKey silc_privkey = NULL;
SilcAsn1 asn1 = NULL;
SilcBufferStruct alg_key;
SilcSILCPrivateKey silc_privkey = NULL;
SilcAsn1 asn1 = NULL;
@@
-1636,7
+1637,7
@@
SILC_PKCS_SIGN(silc_pkcs_silc_sign)
return silc_privkey->pkcs->sign(silc_privkey->pkcs,
silc_privkey->private_key,
src, src_len,
return silc_privkey->pkcs->sign(silc_privkey->pkcs,
silc_privkey->private_key,
src, src_len,
- compute_hash, hash,
+ compute_hash, hash,
rng,
sign_cb, context);
}
sign_cb, context);
}
@@
-1654,6
+1655,6
@@
SILC_PKCS_VERIFY(silc_pkcs_silc_verify)
return silc_pubkey->pkcs->verify(silc_pubkey->pkcs,
silc_pubkey->public_key,
signature, signature_len,
return silc_pubkey->pkcs->verify(silc_pubkey->pkcs,
silc_pubkey->public_key,
signature, signature_len,
- data, data_len, hash,
+ data, data_len, hash,
rng,
verify_cb, context);
}
verify_cb, context);
}