• Main Page
  • Classes
  • Files
  • File List
  • File Members

aegis_crypto.h

Go to the documentation of this file.
00001 /* -*- mode:c; tab-width:4; c-basic-offset:4; -*-
00002  *
00003  * This file is part of Aegis crypto services
00004  *
00005  * Copyright (C) 2010-2011 Nokia Corporation and/or its subsidiary(-ies).
00006  *
00007  * Contact: Juhani Mäkelä <ext-juhani.3.makela@nokia.com>
00008  *
00009  * This library is free software; you can redistribute it and/or
00010  * modify it under the terms of the GNU Lesser General Public License
00011  * version 2.1 as published by the Free Software Foundation.
00012  *
00013  * This library is distributed in the hope that it will be useful, but
00014  * WITHOUT ANY WARRANTY; without even the implied warranty of
00015  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
00016  * Lesser General Public License for more details.
00017  *
00018  * You should have received a copy of the GNU Lesser General Public
00019  * License along with this library; if not, write to the Free Software
00020  * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
00021  * 02110-1301 USA
00022  *
00023  */
00024 
00040 #ifndef AEGIS_CRYPTO_H
00041 #define AEGIS_CRYPTO_H
00042 #endif
00043 
00044 #include "aegis_common.h"
00045 
00046 #ifdef  __cplusplus
00047 extern "C" {
00048 #endif
00049 
00061 #define MAX_CRYPTO_INPUT_SIZE 4050
00062 
00067 #define SIGNATURE_LENGTH 20
00068 
00075     typedef struct aegis_signature_t {
00076         unsigned char d[SIGNATURE_LENGTH]; 
00077     } AEGIS_SIGNATURE_T;
00078 
00085 #define DIGESTLEN 20
00086 
00093     typedef struct aegis_digest_t {
00094         unsigned char d[DIGESTLEN]; 
00095     } AEGIS_DIGEST_T;
00096 
00102 #define SIGNATURE_STRING_LENGTH_HEX 40
00103 
00109 #define SIGNATURE_STRING_LENGTH_BASE64 30
00110 
00116 #define APPLICATION_ID NULL
00117 
00130 #define AEGISFS_SGN_XATTR ".aegisfs-signature"
00131 
00137 #define AEGISFS_VFY_TOKEN "aegisfs::aegisfs-verify"
00138 
00144 #define AEGISFS_VFY_DATALEN 32
00145 
00156     typedef enum {
00157         aegis_system_open,      
00158         aegis_system_protected, 
00159         aegis_system_emulated,  
00160         aegis_system_plain      
00161     } aegis_system_mode_t;
00162 
00173     aegis_system_mode_t
00174     aegis_current_mode(void);
00175 
00183     typedef enum {
00184         aegis_crypto_ok = 0,                  
00185         aegis_crypto_error,                   
00188         aegis_crypto_error_signature_missing, 
00189         aegis_crypto_error_wrong_signature    
00190     } aegis_crypto_result;
00191 
00198     typedef enum {
00199         sysinvariant_imei 
00200     } aegis_sysinvariant_t;
00201 
00206     const char*
00207     aegis_system_invariant(aegis_sysinvariant_t invariant);
00208 
00209 
00217     void aegis_application_id(pid_t of_pid, char **to_this);
00218 
00224      #define UNKNOWN_APP_ID "unknown.unknown."
00225 
00233     void aegis_application_id_of_bin(const char* pathname, char **to_this);
00234 
00246     aegis_crypto_result
00247     aegis_crypto_sign(const RAWDATA_PTR data,
00248                       const size_t nbrof_bytes,
00249                       const char *with_token,
00250                       struct aegis_signature_t *signature);
00251 
00262     aegis_crypto_result
00263     aegis_crypto_verify(struct aegis_signature_t *signature,
00264                         const char *with_token,
00265                         const RAWDATA_PTR data,
00266                         const size_t nbrof_bytes,
00267                         aegis_system_mode_t* made_in_mode);
00268 
00273     typedef enum {
00274         aegis_as_hexstring, 
00275         aegis_as_base64     
00276     } aegis_format_t;
00277 
00288     size_t
00289     aegis_crypto_signature_to_string(struct aegis_signature_t *from,
00290                                      const aegis_format_t use_format,
00291                                      const char* token_name,
00292                                      char **to);
00293 
00303     aegis_crypto_result
00304     aegis_crypto_string_to_signature(const char *from,
00305                                      struct aegis_signature_t *to,
00306                                          char **token_name);
00307 
00313     aegis_crypto_result
00314     aegis_crypto_free(RAWDATA_PTR ptr);
00315 
00328     aegis_crypto_result
00329     aegis_crypto_encrypt(const RAWDATA_PTR plaintext,
00330                          const size_t nbrof_bytes,
00331                          const char *token_name,
00332                          RAWDATA_RPTR ciphertext,
00333                          size_t *result_size);
00334 
00347     aegis_crypto_result
00348     aegis_crypto_decrypt(const RAWDATA_PTR ciphertext,
00349                          const size_t nbrof_bytes,
00350                          const char *token_name,
00351                          RAWDATA_RPTR plaintext,
00352                          size_t *result_size);
00353 
00363     const char*
00364     aegis_crypto_last_error_str(void);
00365 
00383     int aegis_crypto_init(void);
00384 
00395     void aegis_crypto_finish(void);
00396 
00405     ssize_t aegis_crypto_random(RAWDATA_PTR to_buf, size_t bytes);
00406 
00415     size_t aegis_crypto_new_symkey(RAWDATA_RPTR to_buf);
00416 
00423     size_t aegis_crypto_symkeylen(void);
00424 
00437     aegis_crypto_result
00438     aegis_crypto_sign_file(const char *pathname,
00439                            const void *data,
00440                            const size_t len,
00441                            const char *with_token);
00452     aegis_crypto_result
00453     aegis_crypto_verify_file(const char *pathname,
00454                              const void *data,
00455                              const size_t len,
00456                              const char *with_token);
00457 
00476     aegis_crypto_result
00477     aegis_crypto_verify_aegisfs(const char *dir,
00478                                 aegis_system_mode_t *cmode);
00479 
00480 #ifdef  __cplusplus
00481 };
00482 #endif

Generated on Tue Jun 28 2011 14:39:10 for Aegis Crypto by  doxygen 1.7.1