2010-07-13 12:15:46 +00:00
|
|
|
/*
|
|
|
|
Serval Distributed Numbering Architecture (DNA)
|
|
|
|
Copyright (C) 2010 Paul Gardner-Stephen
|
|
|
|
|
|
|
|
This program is free software; you can redistribute it and/or
|
|
|
|
modify it under the terms of the GNU General Public License
|
|
|
|
as published by the Free Software Foundation; either version 2
|
|
|
|
of the License, or (at your option) any later version.
|
|
|
|
|
|
|
|
This program is distributed in the hope that it will be useful,
|
|
|
|
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
|
|
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
|
|
GNU General Public License for more details.
|
|
|
|
|
|
|
|
You should have received a copy of the GNU General Public License
|
|
|
|
along with this program; if not, write to the Free Software
|
|
|
|
Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
|
|
|
|
*/
|
|
|
|
|
2012-02-23 02:15:42 +00:00
|
|
|
#include "serval.h"
|
2010-07-13 12:15:46 +00:00
|
|
|
|
2011-09-01 07:34:25 +00:00
|
|
|
int current_sid_set=0;
|
|
|
|
unsigned char current_sid[SID_SIZE];
|
|
|
|
|
|
|
|
int packetSetMySid(char *sid)
|
|
|
|
{
|
|
|
|
/* Set SID identity if not the first SID in the HLR */
|
|
|
|
|
|
|
|
|
|
|
|
return setReason("Not implemented");
|
|
|
|
}
|
|
|
|
|
|
|
|
int packetGetPrivateKeyForSid()
|
|
|
|
{
|
|
|
|
/* Add all local SIDs to our cache */
|
|
|
|
int ofs=0;
|
|
|
|
while(findHlr(hlr,&ofs,NULL,NULL)) {
|
|
|
|
// XXX If the SIDs match, then this is it */
|
2011-09-05 02:49:53 +00:00
|
|
|
if (!current_sid_set) {
|
2011-09-01 07:34:25 +00:00
|
|
|
/* we are using the first sid in the HLR */
|
|
|
|
} else {
|
|
|
|
/* Compare current SID with SID of this HLR record */
|
|
|
|
/* XXX get PIN field which contains the private key or ciphered private key.
|
|
|
|
Use code from ACTION_GET case in server.c as a guide */
|
|
|
|
}
|
|
|
|
if (nextHlr(hlr,&ofs)) break;
|
|
|
|
}
|
|
|
|
|
|
|
|
return setReason("Not implemented");
|
|
|
|
}
|
|
|
|
|
|
|
|
int packetClearPrivateKeys()
|
|
|
|
{
|
2011-09-05 02:49:53 +00:00
|
|
|
return setReason("Not implemented");
|
2011-09-01 07:34:25 +00:00
|
|
|
}
|
|
|
|
|
2010-07-13 12:15:46 +00:00
|
|
|
int packetDecipher(unsigned char *packet,int len,int cipher)
|
|
|
|
{
|
2011-09-01 07:34:25 +00:00
|
|
|
// Not encrypting for now
|
|
|
|
return 0;
|
|
|
|
|
|
|
|
switch(cipher) {
|
|
|
|
case 0: /* plain text */
|
|
|
|
case CRYPT_PUBLIC: /*make it public, with no other requirements == plain text */
|
|
|
|
return 0;
|
|
|
|
case CRYPT_SIGNED:
|
|
|
|
case CRYPT_PUBLIC|CRYPT_SIGNED:
|
|
|
|
/* Sign but don't encrypt, i.e., crypto_sign() */
|
|
|
|
return 0;
|
|
|
|
case CRYPT_CIPHERED:
|
|
|
|
/* encrypt, but don't sign.
|
|
|
|
Down the track we will use crypto_stream(), but we need a shared secret for the conversation.
|
|
|
|
*/
|
|
|
|
return 0;
|
|
|
|
case CRYPT_CIPHERED|CRYPT_SIGNED:
|
|
|
|
/* encrypt and sign, i.e., crypto_box() */
|
|
|
|
return 0;
|
|
|
|
default:
|
|
|
|
return setReason("Unknown packet cipher");
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2011-09-05 02:49:53 +00:00
|
|
|
int packetEncipher(unsigned char *packet,int maxlen,int *len,int cryptoflags)
|
2011-09-01 07:34:25 +00:00
|
|
|
{
|
|
|
|
// Not encrypting for now
|
|
|
|
return 0;
|
|
|
|
|
|
|
|
if (cryptoflags)
|
|
|
|
{
|
|
|
|
return setReason("Unknown packet cipher");
|
|
|
|
}
|
2010-07-13 12:15:46 +00:00
|
|
|
else return 0; /* plain text */
|
|
|
|
}
|