diff options
author | George Hazan <george.hazan@gmail.com> | 2012-06-02 20:55:18 +0000 |
---|---|---|
committer | George Hazan <george.hazan@gmail.com> | 2012-06-02 20:55:18 +0000 |
commit | 78c0815c4118fe24ab78cce2dc48a6232dcd824a (patch) | |
tree | 8512c50df70b8dd80c919e88ade3419207c95956 /plugins/MirOTR | |
parent | ce816d83a8c75808e0eb06832592bffefe4a8dc4 (diff) |
- code cleaning
git-svn-id: http://svn.miranda-ng.org/main/trunk@270 1316c22d-e87f-b044-9b9b-93d7a3e3ba9c
Diffstat (limited to 'plugins/MirOTR')
65 files changed, 555 insertions, 555 deletions
diff --git a/plugins/MirOTR/MirOTR/dbfilter.cpp b/plugins/MirOTR/MirOTR/dbfilter.cpp index bfc2f80e9d..aab60e18e5 100644 --- a/plugins/MirOTR/MirOTR/dbfilter.cpp +++ b/plugins/MirOTR/MirOTR/dbfilter.cpp @@ -25,7 +25,7 @@ VOID CALLBACK DeleteTimerProc(HWND hwnd, UINT uMsg, UINT_PTR idEvent, DWORD dwTi next = DeleteEvents.first;
while (current = next) {
if (difftime(time(0), current->timestamp) < 1) break;
- if(!CallService(MS_DB_EVENT_GET, (WPARAM)current->hDbEvent, (LPARAM)&info)) // && info.flags&DBEF_READ)
+ if (!CallService(MS_DB_EVENT_GET, (WPARAM)current->hDbEvent, (LPARAM)&info)) // && info.flags&DBEF_READ)
{
CallService(MS_DB_EVENT_DELETE, (WPARAM)current->hContact, (LPARAM)current->hDbEvent);
next = current->next;
@@ -44,7 +44,7 @@ VOID CALLBACK DeleteTimerProc(HWND hwnd, UINT uMsg, UINT_PTR idEvent, DWORD dwTi // add prefix to sent messages
int OnDatabaseEventPreAdd(WPARAM wParam, LPARAM lParam) {
- if(!options.prefix_messages || !lParam) return 0;
+ if (!options.prefix_messages || !lParam) return 0;
HANDLE hContact = (HANDLE)wParam;
DBEVENTINFO *dbei = (DBEVENTINFO *)lParam;
if ((dbei->eventType != EVENTTYPE_MESSAGE) || !(dbei->flags & DBEF_SENT) || (dbei->flags & DBEF_OTR_PREFIXED))
@@ -53,21 +53,21 @@ int OnDatabaseEventPreAdd(WPARAM wParam, LPARAM lParam) { return 0; // just to be safe
const char *proto = contact_get_proto(hContact);
- if(!proto ) return 0;
+ if (!proto ) return 0;
if (DBGetContactSettingByte(hContact, proto, "ChatRoom", 0) == 1)
return 0;
if(g_metaproto && strcmp(proto, g_metaproto) == 0) {
hContact = (HANDLE)CallService(MS_MC_GETMOSTONLINECONTACT, (WPARAM)hContact, 0);
- if(!hContact) return 0;
+ if (!hContact) return 0;
proto = contact_get_proto(hContact);
- if(!proto ) return 0;
+ if (!proto ) return 0;
}
ConnContext *context = otrl_context_find_miranda(otr_user_state, hContact);
bool encrypted = otr_context_get_trust(context) != TRUST_NOT_PRIVATE;
- if(!encrypted) return 0;
+ if (!encrypted) return 0;
DBEVENTINFO my_dbei = *dbei; // copy the other event
@@ -178,7 +178,7 @@ int OnDatabaseEventPreAdd(WPARAM wParam, LPARAM lParam) { }
int OnDatabaseEventAdded(WPARAM wParam, LPARAM lParam) {
- if(!options.delete_history) return 0;
+ if (!options.delete_history) return 0;
DBEVENTINFO info = {0};
info.cbSize = sizeof(info);
@@ -189,7 +189,7 @@ int OnDatabaseEventPreAdd(WPARAM wParam, LPARAM lParam) { static DWORD len = strlen(prefix);
info.cbBlob = lenutf*2;
info.pBlob = (PBYTE)mir_alloc(info.cbBlob);
- if(!CallService(MS_DB_EVENT_GET, (WPARAM)lParam, (LPARAM)&info)) {
+ if (!CallService(MS_DB_EVENT_GET, (WPARAM)lParam, (LPARAM)&info)) {
if(info.eventType == EVENTTYPE_MESSAGE) {
HANDLE hContact = (HANDLE)wParam, hSub;
if(options.bHaveMetaContacts && (hSub = (HANDLE)CallService
@@ -249,13 +249,13 @@ int WindowEvent(WPARAM wParam, LPARAM lParam) { }
if(mwd->uType != MSG_WINDOW_EVT_OPEN) return 0;
- if(!options.bHaveSRMMIcons) return 0;
+ if (!options.bHaveSRMMIcons) return 0;
HANDLE hContact = mwd->hContact, hTemp;
if(options.bHaveMetaContacts && (hTemp = (HANDLE)CallService(MS_MC_GETMOSTONLINECONTACT, (WPARAM)hContact, 0)) != 0)
hContact = hTemp;
- if(!CallService(MS_PROTO_ISPROTOONCONTACT, (WPARAM)hContact, (LPARAM)MODULENAME))
+ if (!CallService(MS_PROTO_ISPROTOONCONTACT, (WPARAM)hContact, (LPARAM)MODULENAME))
return 0;
lib_cs_lock();
diff --git a/plugins/MirOTR/MirOTR/entities.cpp b/plugins/MirOTR/MirOTR/entities.cpp index ce11fe3bec..ae2335bc01 100644 --- a/plugins/MirOTR/MirOTR/entities.cpp +++ b/plugins/MirOTR/MirOTR/entities.cpp @@ -327,7 +327,7 @@ static _Bool parse_entity(const char *current, char **to, const char **from, size_t maxlen) { const char *end = (const char *)memchr(current, ';', maxlen); - if(!end) return 0; + if (!end) return 0; if(current[1] == '#') { @@ -367,7 +367,7 @@ static _Bool parse_entity(const char *current, char **to, size_t decode_html_entities_utf8(char *dest, const char *src, size_t len) { - if(!src) src = dest; + if (!src) src = dest; char *to = dest; const char *from = src; diff --git a/plugins/MirOTR/MirOTR/options.cpp b/plugins/MirOTR/MirOTR/options.cpp index 1109a8fffd..f8d1dba7a1 100644 --- a/plugins/MirOTR/MirOTR/options.cpp +++ b/plugins/MirOTR/MirOTR/options.cpp @@ -88,7 +88,7 @@ void LoadOptions() { options.autoshow_verify = (DBGetContactSettingByte(0, MODULENAME, "AutoShowVerify", 1) == 1);
DBVARIANT dbv;
- if(!DBGetContactSettingUTF8String(0, MODULENAME, "Prefix", &dbv)) {
+ if (!DBGetContactSettingUTF8String(0, MODULENAME, "Prefix", &dbv)) {
strncpy(options.prefix, dbv.pszVal, OPTIONS_PREFIXLEN);
options.prefix[OPTIONS_PREFIXLEN-1] = 0;
DBFreeVariant(&dbv);
diff --git a/plugins/MirOTR/MirOTR/otr.cpp b/plugins/MirOTR/MirOTR/otr.cpp index c094314d56..dfc5575fa4 100644 --- a/plugins/MirOTR/MirOTR/otr.cpp +++ b/plugins/MirOTR/MirOTR/otr.cpp @@ -268,7 +268,7 @@ extern "C" { TCHAR buff[512];
mir_sntprintf(buff, 512, TranslateT(LANG_SESSION_TERMINATED_BY_OTR), contact_get_nameT((HANDLE)opdata));
//MessageBox(0, buff, Translate("OTR Information"), MB_OK);
- if(!Miranda_Terminated()) {
+ if (!Miranda_Terminated()) {
ShowMessage((HANDLE)opdata, buff);
}
@@ -283,7 +283,7 @@ extern "C" { TrustLevel trusted = otr_context_get_trust(context);
SetEncryptionStatus((HANDLE)opdata, trusted);
TCHAR buff[1024];
- if(!is_reply) {
+ if (!is_reply) {
if(trusted == TRUST_PRIVATE) {
mir_sntprintf(buff, 1024, TranslateT(LANG_SESSION_CONTINUE_OTR), contact_get_nameT((HANDLE)opdata));
} else if (trusted == TRUST_UNVERIFIED) {
diff --git a/plugins/MirOTR/MirOTR/svcs_menu.cpp b/plugins/MirOTR/MirOTR/svcs_menu.cpp index 83ef6cd660..712ea4d5b6 100644 --- a/plugins/MirOTR/MirOTR/svcs_menu.cpp +++ b/plugins/MirOTR/MirOTR/svcs_menu.cpp @@ -9,9 +9,9 @@ HANDLE hMenuBuildEvent, hStopItem, hStartItem; int StartOTR(HANDLE hContact) {
const char *proto = contact_get_proto(hContact);
- if(!proto) return 1; // error
+ if (!proto) return 1; // error
char *uname = contact_get_id(hContact);
- if(!uname) return 1; // error
+ if (!uname) return 1; // error
DWORD pol = DBGetContactSettingDword(hContact, MODULENAME, "Policy", CONTACT_DEFAULT_POLICY);
if(pol == CONTACT_DEFAULT_POLICY) pol = options.default_policy;
@@ -74,9 +74,9 @@ int otr_disconnect_contact(HANDLE hContact) { }
const char *proto = contact_get_proto(hContact);
- if(!proto) return 1; // error
+ if (!proto) return 1; // error
char *uname = contact_get_id(hContact);
- if(!uname) return 1; // error
+ if (!uname) return 1; // error
lib_cs_lock();
otrl_message_disconnect(otr_user_state, &ops, hContact, proto, proto, uname);
@@ -164,14 +164,14 @@ int SVC_PrebuildContactMenu(WPARAM wParam, LPARAM lParam) { const char *proto = contact_get_proto(hContact);
DWORD pol = CONTACT_DEFAULT_POLICY;
- if(!proto || DBGetContactSettingByte(hContact, proto, "ChatRoom", 0) == 1) {
+ if (!proto || DBGetContactSettingByte(hContact, proto, "ChatRoom", 0) == 1) {
goto hide_all;
}
if(proto && g_metaproto && strcmp(proto, g_metaproto) == 0) {
// make menu act as per most online subcontact
hContact = (HANDLE)CallService(MS_MC_GETMOSTONLINECONTACT, (WPARAM)hContact, 0);
- if(!hContact)
+ if (!hContact)
goto hide_all;
proto = contact_get_proto(hContact);
}
diff --git a/plugins/MirOTR/MirOTR/svcs_proto.cpp b/plugins/MirOTR/MirOTR/svcs_proto.cpp index 5ea6055908..89f2473597 100644 --- a/plugins/MirOTR/MirOTR/svcs_proto.cpp +++ b/plugins/MirOTR/MirOTR/svcs_proto.cpp @@ -9,7 +9,7 @@ //TODO: Social-Millionaire-Dialoge
INT_PTR SVC_OTRSendMessage(WPARAM wParam,LPARAM lParam){
- if(!lParam) return 0;
+ if (!lParam) return 0;
CCSDATA *ccs = (CCSDATA *) lParam;
@@ -21,7 +21,7 @@ INT_PTR SVC_OTRSendMessage(WPARAM wParam,LPARAM lParam){ char *proto = (char *)CallService(MS_PROTO_GETCONTACTBASEPROTO, (WPARAM)ccs->hContact, 0);
if(proto && g_metaproto && strcmp(proto, g_metaproto) == 0) // bypass for metacontacts
return CallService(MS_PROTO_CHAINSEND, wParam, lParam);
- if(!proto || !ccs->hContact) return 1; // error
+ if (!proto || !ccs->hContact) return 1; // error
gcry_error_t err;
char *newmessage = 0;
@@ -40,7 +40,7 @@ INT_PTR SVC_OTRSendMessage(WPARAM wParam,LPARAM lParam){ } else {
oldmessage_utf = mir_utf8encode(oldmessage);
}
- if(!oldmessage_utf) return 1;
+ if (!oldmessage_utf) return 1;
// don't filter OTR messages being sent (OTR messages should only happen *after* the otrl_message_sending call below)
if(strncmp(oldmessage_utf, "?OTR", 4) == 0) {
@@ -128,7 +128,7 @@ INT_PTR SVC_OTRSendMessage(WPARAM wParam,LPARAM lParam){ }
INT_PTR SVC_OTRSendMessageW(WPARAM wParam, LPARAM lParam){
- if(!lParam) return 0;
+ if (!lParam) return 0;
CCSDATA *ccs = (CCSDATA *) lParam;
if (!(ccs->wParam & PREF_UTF)) ccs->wParam |= PREF_UNICODE;
@@ -159,7 +159,7 @@ INT_PTR SVC_OTRRecvMessage(WPARAM wParam,LPARAM lParam){ }
char *proto = (char *)CallService(MS_PROTO_GETCONTACTBASEPROTO, (WPARAM)ccs->hContact, 0);
- if(!proto)
+ if (!proto)
return 1; //error
else if(proto && g_metaproto && strcmp(proto, g_metaproto) == 0) // bypass for metacontacts
return CallService(MS_PROTO_CHAINRECV, wParam, lParam);
@@ -176,7 +176,7 @@ INT_PTR SVC_OTRRecvMessage(WPARAM wParam,LPARAM lParam){ } else {
oldmessage_utf = mir_utf8encode(oldmessage);
}
- if(!oldmessage_utf) return 1;
+ if (!oldmessage_utf) return 1;
char *newmessage = NULL;
@@ -194,7 +194,7 @@ INT_PTR SVC_OTRRecvMessage(WPARAM wParam,LPARAM lParam){ lib_cs_unlock();
mir_free(uname);
- if( !(pre->flags & PREF_UTF)) mir_free(oldmessage_utf);
+ if ( !(pre->flags & PREF_UTF)) mir_free(oldmessage_utf);
oldmessage_utf = NULL;
diff --git a/plugins/MirOTR/MirOTR/svcs_srmm.cpp b/plugins/MirOTR/MirOTR/svcs_srmm.cpp index e37ee9db51..fbc2797178 100644 --- a/plugins/MirOTR/MirOTR/svcs_srmm.cpp +++ b/plugins/MirOTR/MirOTR/svcs_srmm.cpp @@ -14,13 +14,13 @@ BBButton OTRButton; // }
//
// if(mwd->uType != MSG_WINDOW_EVT_OPEN) return 0;
-// if(!options.bHaveSRMMIcons) return 0;
+// if (!options.bHaveSRMMIcons) return 0;
//
// HANDLE hContact = mwd->hContact, hTemp;
// if(options.bHaveMetaContacts && (hTemp = (HANDLE)CallService(MS_MC_GETMOSTONLINECONTACT, (WPARAM)hContact, 0)) != 0)
// hContact = hTemp;
//
-// if(!CallService(MS_PROTO_ISPROTOONCONTACT, (WPARAM)hContact, (LPARAM)MODULENAME))
+// if (!CallService(MS_PROTO_ISPROTOONCONTACT, (WPARAM)hContact, (LPARAM)MODULENAME))
// return 0;
//
// lib_cs_lock();
@@ -148,7 +148,7 @@ void SetEncryptionStatus(HANDLE hContact, TrustLevel level) { char *proto = (char *)CallService(MS_PROTO_GETCONTACTBASEPROTO, (WPARAM)hContact, 0);
bool chat_room = (proto && DBGetContactSettingByte(hContact, proto, "ChatRoom", 0));
- // if(!chat_room) DBWriteContactSettingByte(hContact, MODULENAME, "Encrypted", (encrypted ? 1 : 0));
+ // if (!chat_room) DBWriteContactSettingByte(hContact, MODULENAME, "Encrypted", (encrypted ? 1 : 0));
if(options.bHaveSRMMIcons || options.bHaveButtonsBar) {
//strcat(dbg_msg, "\nchanging icon");
@@ -197,7 +197,7 @@ void SetEncryptionStatus(HANDLE hContact, TrustLevel level) { if (options.bHaveButtonsBar) CallService(MS_BB_SETBUTTONSTATE, (WPARAM)hContact, (LPARAM)&button);
db_dword_set(hContact, MODULENAME, "TrustLevel", level);
- if(!chat_room && options.bHaveMetaContacts) {
+ if (!chat_room && options.bHaveMetaContacts) {
HANDLE hMeta = (HANDLE)CallService(MS_MC_GETMETACONTACT, (WPARAM)hContact, 0);
HANDLE hMostOnline = (HANDLE)CallService(MS_MC_GETMOSTONLINECONTACT, (WPARAM)hMeta, 0);
if(hMeta && hContact == hMostOnline) {
diff --git a/plugins/MirOTR/MirOTR/utils.cpp b/plugins/MirOTR/MirOTR/utils.cpp index 3d3a50506e..2b592742d4 100644 --- a/plugins/MirOTR/MirOTR/utils.cpp +++ b/plugins/MirOTR/MirOTR/utils.cpp @@ -370,7 +370,7 @@ bool GetEncryptionStatus(HANDLE hContact) { char *proto = (char *)CallService(MS_PROTO_GETCONTACTBASEPROTO, (WPARAM)hContact, 0);
bool chat_room = (proto && DBGetContactSettingByte(hContact, proto, "ChatRoom", 0));
- if(!chat_room) {
+ if (!chat_room) {
if (options.bHaveMetaContacts) {
HANDLE hMeta = (HANDLE)CallService(MS_MC_GETMETACONTACT, (WPARAM)hContact, 0);
if(hMeta && hContact == (HANDLE)CallService(MS_MC_GETMOSTONLINECONTACT, (WPARAM)hMeta, 0)) {
diff --git a/plugins/MirOTR/ekhtml/include/ekhtml_private.h b/plugins/MirOTR/ekhtml/include/ekhtml_private.h index 47d31282fa..90d99caeb2 100644 --- a/plugins/MirOTR/ekhtml/include/ekhtml_private.h +++ b/plugins/MirOTR/ekhtml/include/ekhtml_private.h @@ -150,8 +150,8 @@ char *ekhtml_find_notcharsmap(const char *buf, int len, { const char *endp = buf + len; - for(;buf<endp;buf++) - if(!(charmap[(unsigned char )*buf] & mask)) + for (;buf<endp;buf++) + if (!(charmap[(unsigned char )*buf] & mask)) break; return (char *)((buf == endp) ? endp : buf); diff --git a/plugins/MirOTR/ekhtml/src/ekhtml.c b/plugins/MirOTR/ekhtml/src/ekhtml.c index f3697469f6..8c432cc00e 100644 --- a/plugins/MirOTR/ekhtml/src/ekhtml.c +++ b/plugins/MirOTR/ekhtml/src/ekhtml.c @@ -89,7 +89,7 @@ static void ekhtml_buffer_grow(ekhtml_parser_t *parser){ newsize = parser->nalloced + EKHTML_BLOCKSIZE; - if((newbuf = realloc(parser->buf, newsize)) == NULL){ + if ((newbuf = realloc(parser->buf, newsize)) == NULL){ fprintf(stderr, "BAD! Can't allocate %d bytes in ekhtml_buffer_grow\n", newsize); fflush(stderr); /* Just in case someone changes the buffering scheme */ @@ -119,7 +119,7 @@ int parser_state_determine(const char *startp, const char *endp){ assert(startp != endp); - if(*startp != '<') + if (*startp != '<') return EKHTML_STATE_INDATA; firstchar = startp + 1; @@ -130,7 +130,7 @@ int parser_state_determine(const char *startp, const char *endp){ if(newstate == EKHTML_STATE_NONE){ if(firstchar + 2 >= endp) /* Not enough data to evaluate */ return EKHTML_STATE_NONE; - if(*(firstchar + 1) == '-' && *(firstchar + 2) == '-') + if (*(firstchar + 1) == '-' && *(firstchar + 2) == '-') return EKHTML_STATE_COMMENT; else return EKHTML_STATE_SPECIAL; @@ -238,7 +238,7 @@ void ekhtml_parser_feed(ekhtml_parser_t *parser, ekhtml_string_t *str){ parser->nbuf += tocopy; if(parser->nalloced == parser->nbuf){ /* Process the buffer */ - if(!ekhtml_parser_flush(parser, 0)){ + if (!ekhtml_parser_flush(parser, 0)) { /* If we didn't actually process anything, grow our buffer */ ekhtml_buffer_grow(parser); } @@ -270,7 +270,7 @@ ekhtml_parser_startendcb_add(ekhtml_parser_t *parser, const char *tag, unsigned int taglen; hnode_t *hn; - if(!tag){ + if (!tag){ if(isStart) parser->startcb_unk = startcb; else @@ -289,7 +289,7 @@ ekhtml_parser_startendcb_add(ekhtml_parser_t *parser, const char *tag, lookup_str.str = newtag; lookup_str.len = taglen; - if((hn = hash_lookup(parser->startendcb, &lookup_str))){ + if ((hn = hash_lookup(parser->startendcb, &lookup_str))) { cont = hnode_get(hn); free(newtag); if(isStart) @@ -333,7 +333,7 @@ static hash_val_t ekhtml_string_hash(const void *key){ size_t len = s->len; int c; - while(len--){ + while(len--) { c = str[len]; res = ((res << 5) + res) + c; /* res * 33 + c */ } @@ -353,7 +353,7 @@ void ekhtml_parser_destroy(ekhtml_parser_t *ekparser){ hscan_t hs; hash_scan_begin(&hs, ekparser->startendcb); - while((hn = hash_scan_next(&hs))){ + while((hn = hash_scan_next(&hs))) { ekhtml_string_t *key = (ekhtml_string_t *)hnode_getkey(hn); ekhtml_tag_container *cont = hnode_get(hn); diff --git a/plugins/MirOTR/ekhtml/src/ekhtml_comment.c b/plugins/MirOTR/ekhtml/src/ekhtml_comment.c index e37cc487b5..11c4e8cf2e 100644 --- a/plugins/MirOTR/ekhtml/src/ekhtml_comment.c +++ b/plugins/MirOTR/ekhtml/src/ekhtml_comment.c @@ -66,22 +66,22 @@ char *ekhtml_parse_comment(ekhtml_parser_t *parser, void **state_data, if(comstate->dashes == 0){ /* Still on the quest for the double dash*/ /* XXX -- Searching for '--' could be faster, doing multibyte searching, or something similar */ - for(; workp < endp - 1; workp += 2){ - if(*workp == '-') + for (; workp < endp - 1; workp += 2){ + if (*workp == '-') break; } - if(!(workp < endp - 1)){ + if (!(workp < endp - 1)) { *offset = endp - 1 - curp; return NULL; } - if((*(workp - 1) == '-') && + if ((*(workp - 1) == '-') && (workp - curp) > (sizeof("<!--") - 1)) { comstate->lastdash = workp - 1 - curp; comstate->dashes = 1; - } else if(*(workp + 1) == '-'){ + } else if (*(workp + 1) == '-') { comstate->lastdash = workp - curp; comstate->dashes = 1; } else { @@ -99,7 +99,7 @@ char *ekhtml_parse_comment(ekhtml_parser_t *parser, void **state_data, return NULL; } - if(*workp == '>'){ + if (*workp == '>') { if(parser->commentcb){ ekhtml_string_t str; diff --git a/plugins/MirOTR/ekhtml/src/ekhtml_endtag.c b/plugins/MirOTR/ekhtml/src/ekhtml_endtag.c index f7095dcdfe..7e4ba7650d 100644 --- a/plugins/MirOTR/ekhtml/src/ekhtml_endtag.c +++ b/plugins/MirOTR/ekhtml/src/ekhtml_endtag.c @@ -47,7 +47,7 @@ static void handle_endtag(ekhtml_parser_t *parser, ekhtml_string_t *str){ ekhtml_tag_container *container; hnode_t *hn; - if((hn = hash_lookup(parser->startendcb, str)) && + if ((hn = hash_lookup(parser->startendcb, str)) && (container = hnode_get(hn)) && container->endfunc) { @@ -73,8 +73,8 @@ char *ekhtml_parse_endtag(ekhtml_parser_t *parser, void **state_data, const char *secondchar = curp + 2; /* Initial check to make sure this isn't some bad tag */ - if(!isalpha(*secondchar)){ - if(*secondchar != '>' && *secondchar != '<'){ + if (!isalpha(*secondchar)) { + if (*secondchar != '>' && *secondchar != '<') { /* Bogus tag */ *baddata = EKHTML_STATE_BADDATA; return (char *)curp; @@ -100,7 +100,7 @@ char *ekhtml_parse_endtag(ekhtml_parser_t *parser, void **state_data, arrowp != endp && *arrowp != '<' && *arrowp != '>'; arrowp++) { - if(!(EKCMap_CharMap[(unsigned char)*arrowp] & EKHTML_CHAR_WHITESPACE)) + if (!(EKCMap_CharMap[(unsigned char)*arrowp] & EKHTML_CHAR_WHITESPACE)) endstate->lastchar = arrowp - curp; } @@ -120,7 +120,7 @@ char *ekhtml_parse_endtag(ekhtml_parser_t *parser, void **state_data, handle_endtag(parser, &str); *state_data = NULL; assert(arrowp < endp); - if(*arrowp == '<'){ /* Malformed HTML */ + if (*arrowp == '<') { /* Malformed HTML */ return (char *)(arrowp); } else { return (char *)(arrowp + 1); diff --git a/plugins/MirOTR/ekhtml/src/ekhtml_mktables.c b/plugins/MirOTR/ekhtml/src/ekhtml_mktables.c index 9a8dea2a03..235a0a7e75 100644 --- a/plugins/MirOTR/ekhtml/src/ekhtml_mktables.c +++ b/plugins/MirOTR/ekhtml/src/ekhtml_mktables.c @@ -106,21 +106,21 @@ static EKHTML_CHARMAP_TYPE charmap_values(char in){ #define EKHTML_STRINGIFY(x) #x -static void print_charmap(char *name, EKHTML_CHARMAP_TYPE (*cmap_func)(char)){ +static void print_charmap(char *name, EKHTML_CHARMAP_TYPE (*cmap_func)(char)) { int ch; char sbuf[256]; sprintf_s(sbuf, 256, "0x%%0%dx ", EKHTML_CHARMAP_LEN * 2); printf("#ifdef EKHTML_USE_TABLES\n"); printf("const %s %s[256] = {\n", EKHTML_CHARMAP_TYPE_S, name); - for(ch=0; ch < 256; ch++){ + for(ch=0; ch < 256; ch++) { printf(sbuf, cmap_func((char)ch)); if(isgraph(ch)) printf("/* '%c' */", ch); else printf("/* 0x%.2x */", ch); printf(", "); - if(!((ch + 1) % 4)) + if (!((ch + 1) % 4)) printf("\n"); } printf("};\n\n"); @@ -129,7 +129,7 @@ static void print_charmap(char *name, EKHTML_CHARMAP_TYPE (*cmap_func)(char)){ printf("#endif\n"); } -int main(int argc, char *argv[]){ +int main(int argc, char *argv[]) { printf("#ifndef EKHTML_MKTABLES_DOT_H\n"); printf("#define EKHTML_MKTABLES_DOT_H\n"); diff --git a/plugins/MirOTR/ekhtml/src/ekhtml_special.c b/plugins/MirOTR/ekhtml/src/ekhtml_special.c index f43a62dac4..b29e6422cd 100644 --- a/plugins/MirOTR/ekhtml/src/ekhtml_special.c +++ b/plugins/MirOTR/ekhtml/src/ekhtml_special.c @@ -41,13 +41,13 @@ char *ekhtml_parse_special(ekhtml_parser_t *parser, void **state_data, assert(*curp == '<' && *(curp + 1) == '!'); - if(*state_data == NULL){/* Only called the first time the tag is started */ + if (*state_data == NULL){/* Only called the first time the tag is started */ *offset = 2; *state_data = (void *)1; /* Assign it any non-NULL value */ } for(workp=curp + *offset;workp != endp; workp++) - if(*workp == '<' || *workp == '>') + if (*workp == '<' || *workp == '>') break; if(workp == endp){ @@ -65,7 +65,7 @@ char *ekhtml_parse_special(ekhtml_parser_t *parser, void **state_data, } *state_data = NULL; - if(*workp == '<') /* Malformed HTML */ + if (*workp == '<') /* Malformed HTML */ return (char *)workp; else return (char *)workp + 1; diff --git a/plugins/MirOTR/ekhtml/src/ekhtml_starttag.c b/plugins/MirOTR/ekhtml/src/ekhtml_starttag.c index cfd3ea4fd4..ea0b213ec7 100644 --- a/plugins/MirOTR/ekhtml/src/ekhtml_starttag.c +++ b/plugins/MirOTR/ekhtml/src/ekhtml_starttag.c @@ -133,7 +133,7 @@ static void handle_starttag(ekhtml_parser_t *parser, char *curp, str.str = upper_str; str.len = taglen; - if((hn = hash_lookup(parser->startendcb, &str)) && + if ((hn = hash_lookup(parser->startendcb, &str)) && (container = hnode_get(hn)) && container->startfunc) { @@ -141,14 +141,14 @@ static void handle_starttag(ekhtml_parser_t *parser, char *curp, } else if(parser->startcb_unk) cback = parser->startcb_unk; - if(!cback) + if (!cback) return; /* Formulate real attribute callback data from the 'offset' pointer values */ for(attr=sstate->attrs;attr;attr=attr->next){ attr->name.str = curp + (int)attr->name.str; - if(!attr->isBoolean) + if (!attr->isBoolean) attr->val.str = curp + (int)attr->val.str; } @@ -223,7 +223,7 @@ char *ekhtml_parse_starttag(ekhtml_parser_t *parser, void **state_data, if(workp == endp) break; - if(!(EKCMap_CharMap[(unsigned char)*workp] & + if (!(EKCMap_CharMap[(unsigned char)*workp] & EKHTML_CHAR_BEGATTRNAME)) { /* Bad attrname character */ @@ -254,11 +254,11 @@ char *ekhtml_parse_starttag(ekhtml_parser_t *parser, void **state_data, of file */ startstate->curattr->name.len = workp - (curp + (int)startstate->curattr->name.str); - if(*workp == '='){ + if (*workp == '=') { startstate->mode = EKHTML_STMODE_BEGVALUE; workp++; /* Skip the equals sign */ } else { - if(!(EKCMap_CharMap[(unsigned char)*workp] & + if (!(EKCMap_CharMap[(unsigned char)*workp] & EKHTML_CHAR_WHITESPACE)) { /* Found something we weren't expecting. Use the current @@ -277,7 +277,7 @@ char *ekhtml_parse_starttag(ekhtml_parser_t *parser, void **state_data, if(workp == endp) break; - if(*workp != '='){ + if (*workp != '=') { /* Unexpected value. Could either be time to suck, or this was really only a boolean value */ scroll_attribute(startstate); @@ -306,12 +306,12 @@ char *ekhtml_parse_starttag(ekhtml_parser_t *parser, void **state_data, startstate->curattr->isBoolean = 0; startstate->curattr->val.str = (char *)NULL + (workp - curp); startstate->quote = '\0'; - if(*workp == '"' || *workp == '\''){ + if (*workp == '"' || *workp == '\'') { startstate->curattr->val.str++; /* Skip the quote */ startstate->mode = EKHTML_STMODE_GETVALUE; startstate->quote = *workp; workp++; - } else if(!(EKCMap_CharMap[(unsigned char)*workp] & + } else if (!(EKCMap_CharMap[(unsigned char)*workp] & EKHTML_CHAR_ATTRVALUE)) { /* Bad value .. */ @@ -326,8 +326,8 @@ char *ekhtml_parse_starttag(ekhtml_parser_t *parser, void **state_data, if(startstate->mode == EKHTML_STMODE_GETVALUE){ if(startstate->quote){ - for(;workp != endp && *workp != '>' && *workp != '<'; workp++){ - if(*workp == startstate->quote){ + for (;workp != endp && *workp != '>' && *workp != '<'; workp++) { + if (*workp == startstate->quote){ startstate->curattr->val.len = workp - (curp + (int)startstate->curattr->val.str); scroll_attribute(startstate); @@ -351,12 +351,12 @@ char *ekhtml_parse_starttag(ekhtml_parser_t *parser, void **state_data, workp - (curp + (int)startstate->curattr->val.str); scroll_attribute(startstate); - if(*workp == '>' || *workp == '<') { + if (*workp == '>' || *workp == '<') { *offset = workp - curp; handle_starttag(parser, curp, startstate); release_attributes(parser, startstate); *state_data = NULL; - if(*workp == '<') + if (*workp == '<') return workp; else return workp + 1; @@ -369,7 +369,7 @@ char *ekhtml_parse_starttag(ekhtml_parser_t *parser, void **state_data, if(startstate->mode == EKHTML_STMODE_SUCK){ /* The sucking mode is here in case someone puts a bad character in an attribute name. We suck until what looks like end of tag*/ - for(;workp != endp && *workp != '<' && *workp != '>'; workp++) + for (;workp != endp && *workp != '<' && *workp != '>'; workp++) ; if(workp == endp) break; @@ -378,7 +378,7 @@ char *ekhtml_parse_starttag(ekhtml_parser_t *parser, void **state_data, handle_starttag(parser, curp, startstate); release_attributes(parser, startstate); *state_data = NULL; - if(*workp == '<') + if (*workp == '<') return workp; else return workp + 1; diff --git a/plugins/MirOTR/ekhtml/testsuite/tester.c b/plugins/MirOTR/ekhtml/testsuite/tester.c index 972a1564c2..226cb21393 100644 --- a/plugins/MirOTR/ekhtml/testsuite/tester.c +++ b/plugins/MirOTR/ekhtml/testsuite/tester.c @@ -61,7 +61,7 @@ static void handle_starttag(void *cbdata, ekhtml_string_t *tag, printf("START: \"%.*s\"\n", tag->len, tag->str); for(attr=attrs; attr; attr=attr->next) { printf("ATTRIBUTE: \"%.*s\" = ", attr->name.len, attr->name.str); - if(!attr->isBoolean) + if (!attr->isBoolean) printf("\"%.*s\"\n", attr->val.len, attr->val.str); else printf("\"%.*s\"\n", attr->name.len, attr->name.str); @@ -101,7 +101,7 @@ static void handle_data(void *cbdata, ekhtml_string_t *str){ fwrite(str->str, str->len, 1, stdout); } -int main(int argc, char *argv[]){ +int main(int argc, char *argv[]) { tester_cbdata cbdata; ekhtml_parser_t *ekparser; char *buf; @@ -133,7 +133,7 @@ int main(int argc, char *argv[]){ ekhtml_parser_cbdata_set(ekparser, &cbdata); buf = malloc(feedsize); - while((nbuf = fread(buf, 1, feedsize, stdin))){ + while((nbuf = fread(buf, 1, feedsize, stdin))) { ekhtml_string_t str; str.str = buf; diff --git a/plugins/MirOTR/libgcrypt-1.4.6/cipher/arcfour.c b/plugins/MirOTR/libgcrypt-1.4.6/cipher/arcfour.c index 6bb0555c60..eab52a4714 100644 --- a/plugins/MirOTR/libgcrypt-1.4.6/cipher/arcfour.c +++ b/plugins/MirOTR/libgcrypt-1.4.6/cipher/arcfour.c @@ -84,13 +84,13 @@ do_arcfour_setkey (void *context, const byte *key, unsigned int keylen) { initialized = 1; selftest_failed = selftest(); - if( selftest_failed ) + if ( selftest_failed ) log_error ("ARCFOUR selftest failed (%s)\n", selftest_failed ); } - if( selftest_failed ) + if ( selftest_failed ) return GPG_ERR_SELFTEST_FAILED; - if( keylen < 40/8 ) /* we want at least 40 bits */ + if ( keylen < 40/8 ) /* we want at least 40 bits */ return GPG_ERR_INV_KEYLEN; ctx->idx_i = ctx->idx_j = 0; diff --git a/plugins/MirOTR/libgcrypt-1.4.6/cipher/blowfish.c b/plugins/MirOTR/libgcrypt-1.4.6/cipher/blowfish.c index 6ef68e371d..de89b59271 100644 --- a/plugins/MirOTR/libgcrypt-1.4.6/cipher/blowfish.c +++ b/plugins/MirOTR/libgcrypt-1.4.6/cipher/blowfish.c @@ -475,18 +475,18 @@ selftest(void) bf_setkey( (void *) &c, (const unsigned char*)"abcdefghijklmnopqrstuvwxyz", 26 ); encrypt_block( (void *) &c, buffer, plain ); - if( memcmp( buffer, "\x32\x4E\xD0\xFE\xF4\x13\xA2\x03", 8 ) ) + if ( memcmp( buffer, "\x32\x4E\xD0\xFE\xF4\x13\xA2\x03", 8 ) ) return "Blowfish selftest failed (1)."; decrypt_block( (void *) &c, buffer, buffer ); - if( memcmp( buffer, plain, 8 ) ) + if ( memcmp( buffer, plain, 8 ) ) return "Blowfish selftest failed (2)."; bf_setkey( (void *) &c, key3, 8 ); encrypt_block( (void *) &c, buffer, plain3 ); - if( memcmp( buffer, cipher3, 8 ) ) + if ( memcmp( buffer, cipher3, 8 ) ) return "Blowfish selftest failed (3)."; decrypt_block( (void *) &c, buffer, buffer ); - if( memcmp( buffer, plain3, 8 ) ) + if ( memcmp( buffer, plain3, 8 ) ) return "Blowfish selftest failed (4)."; return NULL; } @@ -501,14 +501,14 @@ do_bf_setkey (BLOWFISH_context *c, const byte *key, unsigned keylen) static int initialized; static const char *selftest_failed; - if( !initialized ) + if ( !initialized ) { initialized = 1; selftest_failed = selftest(); - if( selftest_failed ) + if ( selftest_failed ) log_error ("%s\n", selftest_failed ); } - if( selftest_failed ) + if ( selftest_failed ) return GPG_ERR_SELFTEST_FAILED; for(i=0; i < BLOWFISH_ROUNDS+2; i++ ) @@ -575,9 +575,9 @@ do_bf_setkey (BLOWFISH_context *c, const byte *key, unsigned keylen) the P-array (here c) occurs more than once per table. */ for(i=0; i < 255; i++ ) { - for( j=i+1; j < 256; j++) + for ( j=i+1; j < 256; j++) { - if( (c->s0[i] == c->s0[j]) || (c->s1[i] == c->s1[j]) || + if ( (c->s0[i] == c->s0[j]) || (c->s1[i] == c->s1[j]) || (c->s2[i] == c->s2[j]) || (c->s3[i] == c->s3[j]) ) return GPG_ERR_WEAK_KEY; } diff --git a/plugins/MirOTR/libgcrypt-1.4.6/cipher/camellia-glue.c b/plugins/MirOTR/libgcrypt-1.4.6/cipher/camellia-glue.c index 067af85bca..99174c55f1 100644 --- a/plugins/MirOTR/libgcrypt-1.4.6/cipher/camellia-glue.c +++ b/plugins/MirOTR/libgcrypt-1.4.6/cipher/camellia-glue.c @@ -81,7 +81,7 @@ camellia_setkey(void *c, const byte *key, unsigned keylen) if(keylen!=16 && keylen!=24 && keylen!=32) return GPG_ERR_INV_KEYLEN; - if(!initialized) + if (!initialized) { initialized=1; selftest_failed=selftest(); diff --git a/plugins/MirOTR/libgcrypt-1.4.6/cipher/cast5.c b/plugins/MirOTR/libgcrypt-1.4.6/cipher/cast5.c index 333d55e91f..a532acfd4d 100644 --- a/plugins/MirOTR/libgcrypt-1.4.6/cipher/cast5.c +++ b/plugins/MirOTR/libgcrypt-1.4.6/cipher/cast5.c @@ -476,10 +476,10 @@ selftest(void) cast_setkey( &c, key, 16 ); encrypt_block( &c, buffer, plain ); - if( memcmp( buffer, cipher, 8 ) ) + if ( memcmp( buffer, cipher, 8 ) ) return "1"; decrypt_block( &c, buffer, buffer ); - if( memcmp( buffer, plain, 8 ) ) + if ( memcmp( buffer, plain, 8 ) ) return "2"; #if 0 /* full maintenance test */ @@ -502,7 +502,7 @@ selftest(void) encrypt_block( &c, b0, b0 ); encrypt_block( &c, b0+8, b0+8 ); } - if( memcmp( a0, a1, 16 ) || memcmp( b0, b1, 16 ) ) + if ( memcmp( a0, a1, 16 ) || memcmp( b0, b1, 16 ) ) return "3"; } @@ -569,17 +569,17 @@ do_cast_setkey( CAST5_context *c, const byte *key, unsigned keylen ) u32 z[4]; u32 k[16]; - if( !initialized ) + if ( !initialized ) { initialized = 1; selftest_failed = selftest(); - if( selftest_failed ) + if ( selftest_failed ) log_error ("CAST5 selftest failed (%s).\n", selftest_failed ); } - if( selftest_failed ) + if ( selftest_failed ) return GPG_ERR_SELFTEST_FAILED; - if( keylen != 16 ) + if ( keylen != 16 ) return GPG_ERR_INV_KEYLEN; x[0] = key[0] << 24 | key[1] << 16 | key[2] << 8 | key[3]; diff --git a/plugins/MirOTR/libgcrypt-1.4.6/cipher/cipher.c b/plugins/MirOTR/libgcrypt-1.4.6/cipher/cipher.c index 8cfe54fce1..7594ee593a 100644 --- a/plugins/MirOTR/libgcrypt-1.4.6/cipher/cipher.c +++ b/plugins/MirOTR/libgcrypt-1.4.6/cipher/cipher.c @@ -1294,7 +1294,7 @@ do_ofb_encrypt( gcry_cipher_hd_t c, return; } - if( c->unused ) + if ( c->unused ) { nbytes -= c->unused; for(ivp=c->u_iv.iv+blocksize - c->unused; c->unused; c->unused-- ) @@ -1331,7 +1331,7 @@ do_ofb_decrypt( gcry_cipher_hd_t c, byte *ivp; size_t blocksize = c->cipher->blocksize; - if( nbytes <= c->unused ) + if ( nbytes <= c->unused ) { /* Short enough to be encoded by the remaining XOR mask. */ for (ivp=c->u_iv.iv+blocksize - c->unused; nbytes; nbytes--,c->unused--) @@ -1874,7 +1874,7 @@ gcry_cipher_ctl( gcry_cipher_hd_t h, int cmd, void *buffer, size_t buflen) case GCRYCTL_DISABLE_ALGO: /* This command expects NULL for H and BUFFER to point to an integer with the algo number. */ - if( h || !buffer || buflen != sizeof(int) ) + if ( h || !buffer || buflen != sizeof(int) ) return gcry_error (GPG_ERR_CIPHER_ALGO); disable_cipher_algo( *(int*)buffer ); break; diff --git a/plugins/MirOTR/libgcrypt-1.4.6/cipher/des.c b/plugins/MirOTR/libgcrypt-1.4.6/cipher/des.c index f91df77713..3dfd27812e 100644 --- a/plugins/MirOTR/libgcrypt-1.4.6/cipher/des.c +++ b/plugins/MirOTR/libgcrypt-1.4.6/cipher/des.c @@ -129,8 +129,8 @@ static int working_memcmp( const char *a, const char *b, size_t n ) { - for( ; n; n--, a++, b++ ) - if( *a != *b ) + for ( ; n; n--, a++, b++ ) + if ( *a != *b ) return (int)(*(byte*)a) - (int)(*(byte*)b); return 0; } @@ -1012,7 +1012,7 @@ do_tripledes_setkey ( void *context, const byte *key, unsigned keylen ) { struct _tripledes_ctx *ctx = (struct _tripledes_ctx *) context; - if( keylen != 24 ) + if ( keylen != 24 ) return GPG_ERR_INV_KEYLEN; tripledes_set3keys ( ctx, key, key+8, key+16); diff --git a/plugins/MirOTR/libgcrypt-1.4.6/cipher/dsa.c b/plugins/MirOTR/libgcrypt-1.4.6/cipher/dsa.c index ceb94965c5..24e07b59ab 100644 --- a/plugins/MirOTR/libgcrypt-1.4.6/cipher/dsa.c +++ b/plugins/MirOTR/libgcrypt-1.4.6/cipher/dsa.c @@ -145,7 +145,7 @@ gen_k( gcry_mpi_t q ) log_debug("choosing a random k "); for (;;) { - if( DBG_CIPHER ) + if ( DBG_CIPHER ) progress('.'); if ( !rndbuf || nbits < 32 ) @@ -171,22 +171,22 @@ gen_k( gcry_mpi_t q ) mpi_clear_bit( k, nbits-1 ); } - if( !(mpi_cmp( k, q ) < 0) ) /* check: k < q */ + if ( !(mpi_cmp( k, q ) < 0) ) /* check: k < q */ { - if( DBG_CIPHER ) + if ( DBG_CIPHER ) progress('+'); continue; /* no */ } - if( !(mpi_cmp_ui( k, 0 ) > 0) ) /* check: k > 0 */ + if ( !(mpi_cmp_ui( k, 0 ) > 0) ) /* check: k > 0 */ { - if( DBG_CIPHER ) + if ( DBG_CIPHER ) progress('-'); continue; /* no */ } break; /* okay */ } gcry_free(rndbuf); - if( DBG_CIPHER ) + if ( DBG_CIPHER ) progress('\n'); return k; @@ -332,9 +332,9 @@ generate (DSA_secret_key *sk, unsigned int nbits, unsigned int qbits, rndbuf = NULL; do { - if( DBG_CIPHER ) + if ( DBG_CIPHER ) progress('.'); - if( !rndbuf ) + if ( !rndbuf ) rndbuf = gcry_random_bytes_secure ((qbits+7)/8, random_level); else { /* Change only some of the higher bits (= 2 bytes)*/ @@ -355,7 +355,7 @@ generate (DSA_secret_key *sk, unsigned int nbits, unsigned int qbits, y = mpi_alloc( mpi_get_nlimbs(p) ); gcry_mpi_powm( y, g, x, p ); - if( DBG_CIPHER ) + if ( DBG_CIPHER ) { progress('\n'); log_mpidump("dsa p", p ); @@ -508,7 +508,7 @@ generate_fips186 (DSA_secret_key *sk, unsigned int nbits, unsigned int qbits, value_x = gcry_mpi_snew (qbits); do { - if( DBG_CIPHER ) + if ( DBG_CIPHER ) progress('.'); gcry_mpi_randomize (value_x, qbits, GCRY_VERY_STRONG_RANDOM); mpi_clear_highbit (value_x, qbits+1); @@ -634,9 +634,9 @@ verify (gcry_mpi_t r, gcry_mpi_t s, gcry_mpi_t hash, DSA_public_key *pkey ) gcry_mpi_t base[3]; gcry_mpi_t ex[3]; - if( !(mpi_cmp_ui( r, 0 ) > 0 && mpi_cmp( r, pkey->q ) < 0) ) + if ( !(mpi_cmp_ui( r, 0 ) > 0 && mpi_cmp( r, pkey->q ) < 0) ) return 0; /* assertion 0 < r < q failed */ - if( !(mpi_cmp_ui( s, 0 ) > 0 && mpi_cmp( s, pkey->q ) < 0) ) + if ( !(mpi_cmp_ui( s, 0 ) > 0 && mpi_cmp( s, pkey->q ) < 0) ) return 0; /* assertion 0 < s < q failed */ w = mpi_alloc( mpi_get_nlimbs(pkey->q) ); diff --git a/plugins/MirOTR/libgcrypt-1.4.6/cipher/ecc.c b/plugins/MirOTR/libgcrypt-1.4.6/cipher/ecc.c index fcbd8e3a9d..fec7e86ee6 100644 --- a/plugins/MirOTR/libgcrypt-1.4.6/cipher/ecc.c +++ b/plugins/MirOTR/libgcrypt-1.4.6/cipher/ecc.c @@ -760,9 +760,9 @@ verify (gcry_mpi_t input, ECC_public_key *pkey, gcry_mpi_t r, gcry_mpi_t s) mpi_point_t Q, Q1, Q2; mpi_ec_t ctx; - if( !(mpi_cmp_ui (r, 0) > 0 && mpi_cmp (r, pkey->E.n) < 0) ) + if ( !(mpi_cmp_ui (r, 0) > 0 && mpi_cmp (r, pkey->E.n) < 0) ) return GPG_ERR_BAD_SIGNATURE; /* Assertion 0 < r < n failed. */ - if( !(mpi_cmp_ui (s, 0) > 0 && mpi_cmp (s, pkey->E.n) < 0) ) + if ( !(mpi_cmp_ui (s, 0) > 0 && mpi_cmp (s, pkey->E.n) < 0) ) return GPG_ERR_BAD_SIGNATURE; /* Assertion 0 < s < n failed. */ h = mpi_alloc (0); diff --git a/plugins/MirOTR/libgcrypt-1.4.6/cipher/elgamal.c b/plugins/MirOTR/libgcrypt-1.4.6/cipher/elgamal.c index 0b0c07cb4b..776d7a52c2 100644 --- a/plugins/MirOTR/libgcrypt-1.4.6/cipher/elgamal.c +++ b/plugins/MirOTR/libgcrypt-1.4.6/cipher/elgamal.c @@ -117,7 +117,7 @@ wiener_map( unsigned int n ) for(i=0; t[i].p_n; i++ ) { - if( n <= t[i].p_n ) + if ( n <= t[i].p_n ) return t[i].q_n; } /* Not in table - use an arbitrary high number. */ @@ -188,7 +188,7 @@ gen_k( gcry_mpi_t p, int small_k ) * it greatly improves the encryption performance. We use * Wiener's table and add a large safety margin. */ nbits = wiener_map( orig_nbits ) * 3 / 2; - if( nbits >= orig_nbits ) + if ( nbits >= orig_nbits ) BUG(); } else @@ -196,12 +196,12 @@ gen_k( gcry_mpi_t p, int small_k ) nbytes = (nbits+7)/8; - if( DBG_CIPHER ) + if ( DBG_CIPHER ) log_debug("choosing a random k "); mpi_sub_ui( p_1, p, 1); - for(;;) + for (;;) { - if( !rndbuf || nbits < 32 ) + if ( !rndbuf || nbits < 32 ) { gcry_free(rndbuf); rndbuf = gcry_random_bytes_secure( nbytes, GCRY_STRONG_RANDOM ); @@ -219,30 +219,30 @@ gen_k( gcry_mpi_t p, int small_k ) } _gcry_mpi_set_buffer( k, rndbuf, nbytes, 0 ); - for(;;) + for (;;) { - if( !(mpi_cmp( k, p_1 ) < 0) ) /* check: k < (p-1) */ + if ( !(mpi_cmp( k, p_1 ) < 0) ) /* check: k < (p-1) */ { - if( DBG_CIPHER ) + if ( DBG_CIPHER ) progress('+'); break; /* no */ } - if( !(mpi_cmp_ui( k, 0 ) > 0) ) /* check: k > 0 */ + if ( !(mpi_cmp_ui( k, 0 ) > 0) ) /* check: k > 0 */ { - if( DBG_CIPHER ) + if ( DBG_CIPHER ) progress('-'); break; /* no */ } if (gcry_mpi_gcd( temp, k, p_1 )) goto found; /* okay, k is relative prime to (p-1) */ mpi_add_ui( k, k, 1 ); - if( DBG_CIPHER ) + if ( DBG_CIPHER ) progress('.'); } } found: gcry_free(rndbuf); - if( DBG_CIPHER ) + if ( DBG_CIPHER ) progress('\n'); mpi_free(p_1); mpi_free(temp); @@ -269,7 +269,7 @@ generate ( ELG_secret_key *sk, unsigned int nbits, gcry_mpi_t **ret_factors ) p_min1 = gcry_mpi_new ( nbits ); qbits = wiener_map( nbits ); - if( qbits & 1 ) /* better have a even one */ + if ( qbits & 1 ) /* better have a even one */ qbits++; g = mpi_alloc(1); p = _gcry_generate_elg_prime( 0, nbits, qbits, g, ret_factors ); @@ -288,19 +288,19 @@ generate ( ELG_secret_key *sk, unsigned int nbits, gcry_mpi_t **ret_factors ) * will be much faster with such an x. */ xbits = qbits * 3 / 2; - if( xbits >= nbits ) + if ( xbits >= nbits ) BUG(); x = gcry_mpi_snew ( xbits ); - if( DBG_CIPHER ) + if ( DBG_CIPHER ) log_debug("choosing a random x of size %u", xbits ); rndbuf = NULL; do { - if( DBG_CIPHER ) + if ( DBG_CIPHER ) progress('.'); - if( rndbuf ) + if ( rndbuf ) { /* Change only some of the higher bits */ - if( xbits < 16 ) /* should never happen ... */ + if ( xbits < 16 ) /* should never happen ... */ { gcry_free(rndbuf); rndbuf = gcry_random_bytes_secure( (xbits+7)/8, @@ -328,7 +328,7 @@ generate ( ELG_secret_key *sk, unsigned int nbits, gcry_mpi_t **ret_factors ) y = gcry_mpi_new (nbits); gcry_mpi_powm( y, g, x, p ); - if( DBG_CIPHER ) + if ( DBG_CIPHER ) { progress('\n'); log_mpidump("elg p= ", p ); @@ -467,7 +467,7 @@ do_encrypt(gcry_mpi_t a, gcry_mpi_t b, gcry_mpi_t input, ELG_public_key *pkey ) gcry_mpi_powm( b, pkey->y, k, pkey->p ); gcry_mpi_mulm( b, b, input, pkey->p ); #if 0 - if( DBG_CIPHER ) + if ( DBG_CIPHER ) { log_mpidump("elg encrypted y= ", pkey->y); log_mpidump("elg encrypted p= ", pkey->p); @@ -493,7 +493,7 @@ decrypt(gcry_mpi_t output, gcry_mpi_t a, gcry_mpi_t b, ELG_secret_key *skey ) mpi_invm( t1, t1, skey->p ); mpi_mulm( output, b, t1, skey->p ); #if 0 - if( DBG_CIPHER ) + if ( DBG_CIPHER ) { log_mpidump("elg decrypted x= ", skey->x); log_mpidump("elg decrypted p= ", skey->p); @@ -533,7 +533,7 @@ sign(gcry_mpi_t a, gcry_mpi_t b, gcry_mpi_t input, ELG_secret_key *skey ) mpi_mulm(b, t, inv, p_1 ); #if 0 - if( DBG_CIPHER ) + if ( DBG_CIPHER ) { log_mpidump("elg sign p= ", skey->p); log_mpidump("elg sign g= ", skey->g); @@ -564,7 +564,7 @@ verify(gcry_mpi_t a, gcry_mpi_t b, gcry_mpi_t input, ELG_public_key *pkey ) gcry_mpi_t base[4]; gcry_mpi_t ex[4]; - if( !(mpi_cmp_ui( a, 0 ) > 0 && mpi_cmp( a, pkey->p ) < 0) ) + if ( !(mpi_cmp_ui( a, 0 ) > 0 && mpi_cmp( a, pkey->p ) < 0) ) return 0; /* assertion 0 < a < p failed */ t1 = mpi_alloc( mpi_get_nlimbs(a) ); diff --git a/plugins/MirOTR/libgcrypt-1.4.6/cipher/md4.c b/plugins/MirOTR/libgcrypt-1.4.6/cipher/md4.c index 680cf87f5d..ce277fa4f5 100644 --- a/plugins/MirOTR/libgcrypt-1.4.6/cipher/md4.c +++ b/plugins/MirOTR/libgcrypt-1.4.6/cipher/md4.c @@ -197,22 +197,22 @@ md4_write ( void *context, const void *inbuf_arg, size_t inlen) const unsigned char *inbuf = inbuf_arg; MD4_CONTEXT *hd = context; - if( hd->count == 64 ) /* flush the buffer */ + if ( hd->count == 64 ) /* flush the buffer */ { transform( hd, hd->buf ); _gcry_burn_stack (80+6*sizeof(void*)); hd->count = 0; hd->nblocks++; } - if( !inbuf ) + if ( !inbuf ) return; - if( hd->count ) + if ( hd->count ) { - for( ; inlen && hd->count < 64; inlen-- ) + for ( ; inlen && hd->count < 64; inlen-- ) hd->buf[hd->count++] = *inbuf++; md4_write( hd, NULL, 0 ); - if( !inlen ) + if ( !inlen ) return; } _gcry_burn_stack (80+6*sizeof(void*)); @@ -225,7 +225,7 @@ md4_write ( void *context, const void *inbuf_arg, size_t inlen) inlen -= 64; inbuf += 64; } - for( ; inlen && hd->count < 64; inlen-- ) + for ( ; inlen && hd->count < 64; inlen-- ) hd->buf[hd->count++] = *inbuf++; } @@ -252,7 +252,7 @@ md4_final( void *context ) msb = t >> 26; /* add the count */ t = lsb; - if( (lsb += hd->count) < t ) + if ( (lsb += hd->count) < t ) msb++; /* multiply by 8 to make a bit count */ t = lsb; @@ -260,7 +260,7 @@ md4_final( void *context ) msb <<= 3; msb |= t >> 29; - if( hd->count < 56 ) /* enough room */ + if ( hd->count < 56 ) /* enough room */ { hd->buf[hd->count++] = 0x80; /* pad */ while( hd->count < 56 ) diff --git a/plugins/MirOTR/libgcrypt-1.4.6/cipher/md5.c b/plugins/MirOTR/libgcrypt-1.4.6/cipher/md5.c index 899dce89ad..d57a6b7838 100644 --- a/plugins/MirOTR/libgcrypt-1.4.6/cipher/md5.c +++ b/plugins/MirOTR/libgcrypt-1.4.6/cipher/md5.c @@ -222,22 +222,22 @@ md5_write( void *context, const void *inbuf_arg , size_t inlen) const unsigned char *inbuf = inbuf_arg; MD5_CONTEXT *hd = context; - if( hd->count == 64 ) /* flush the buffer */ + if ( hd->count == 64 ) /* flush the buffer */ { transform( hd, hd->buf ); _gcry_burn_stack (80+6*sizeof(void*)); hd->count = 0; hd->nblocks++; } - if( !inbuf ) + if ( !inbuf ) return; - if( hd->count ) + if ( hd->count ) { - for( ; inlen && hd->count < 64; inlen-- ) + for ( ; inlen && hd->count < 64; inlen-- ) hd->buf[hd->count++] = *inbuf++; md5_write( hd, NULL, 0 ); - if( !inlen ) + if ( !inlen ) return; } _gcry_burn_stack (80+6*sizeof(void*)); @@ -250,7 +250,7 @@ md5_write( void *context, const void *inbuf_arg , size_t inlen) inlen -= 64; inbuf += 64; } - for( ; inlen && hd->count < 64; inlen-- ) + for ( ; inlen && hd->count < 64; inlen-- ) hd->buf[hd->count++] = *inbuf++; } @@ -278,7 +278,7 @@ md5_final( void *context) msb = t >> 26; /* add the count */ t = lsb; - if( (lsb += hd->count) < t ) + if ( (lsb += hd->count) < t ) msb++; /* multiply by 8 to make a bit count */ t = lsb; @@ -286,7 +286,7 @@ md5_final( void *context) msb <<= 3; msb |= t >> 29; - if( hd->count < 56 ) /* enough room */ + if ( hd->count < 56 ) /* enough room */ { hd->buf[hd->count++] = 0x80; /* pad */ while( hd->count < 56 ) diff --git a/plugins/MirOTR/libgcrypt-1.4.6/cipher/primegen.c b/plugins/MirOTR/libgcrypt-1.4.6/cipher/primegen.c index b869bee839..c9b5414501 100644 --- a/plugins/MirOTR/libgcrypt-1.4.6/cipher/primegen.c +++ b/plugins/MirOTR/libgcrypt-1.4.6/cipher/primegen.c @@ -936,7 +936,7 @@ is_prime (gcry_mpi_t n, int steps, unsigned int *count) for (i=0 ; i < steps; i++ ) { ++*count; - if( !i ) + if ( !i ) { mpi_set_ui( x, 2 ); } @@ -963,7 +963,7 @@ is_prime (gcry_mpi_t n, int steps, unsigned int *count) for ( j=1; j < k && mpi_cmp( y, nminus1 ); j++ ) { gcry_mpi_powm(y, y, a2, n); - if( !mpi_cmp_ui( y, 1 ) ) + if ( !mpi_cmp_ui( y, 1 ) ) goto leave; /* Not a prime. */ } if (mpi_cmp( y, nminus1 ) ) @@ -1005,18 +1005,18 @@ m_out_of_n ( char *array, int m, int n ) { int i=0, i1=0, j=0, jp=0, j1=0, k1=0, k2=0; - if( !m || m >= n ) + if ( !m || m >= n ) return; /* Need to handle this simple case separately. */ - if( m == 1 ) + if ( m == 1 ) { for (i=0; i < n; i++ ) { if ( array[i] ) { array[i++] = 0; - if( i >= n ) + if ( i >= n ) i = 0; array[i] = 1; return; @@ -1037,25 +1037,25 @@ m_out_of_n ( char *array, int m, int n ) if ( (m & 1) ) { /* M is odd. */ - if( array[n-1] ) + if ( array[n-1] ) { - if( j1 & 1 ) + if ( j1 & 1 ) { k1 = n - j1; k2 = k1+2; - if( k2 > n ) + if ( k2 > n ) k2 = n; goto leave; } goto scan; } k2 = n - j1 - 1; - if( k2 == 0 ) + if ( k2 == 0 ) { k1 = i; k2 = n - j1; } - else if( array[k2] && array[k2-1] ) + else if ( array[k2] && array[k2-1] ) k1 = n; else k1 = k2 + 1; @@ -1063,18 +1063,18 @@ m_out_of_n ( char *array, int m, int n ) else { /* M is even. */ - if( !array[n-1] ) + if ( !array[n-1] ) { k1 = n - j1; k2 = k1 + 1; goto leave; } - if( !(j1 & 1) ) + if ( !(j1 & 1) ) { k1 = n - j1; k2 = k1+2; - if( k2 > n ) + if ( k2 > n ) k2 = n; goto leave; } @@ -1083,9 +1083,9 @@ m_out_of_n ( char *array, int m, int n ) for (i=1; i <= jp; i++ ) { i1 = jp + 2 - i; - if( array[i1-1] ) + if ( array[i1-1] ) { - if( array[i1-2] ) + if ( array[i1-2] ) { k1 = i1 - 1; k2 = n - j1; diff --git a/plugins/MirOTR/libgcrypt-1.4.6/cipher/pubkey.c b/plugins/MirOTR/libgcrypt-1.4.6/cipher/pubkey.c index 08abcbfdec..b888d4b936 100644 --- a/plugins/MirOTR/libgcrypt-1.4.6/cipher/pubkey.c +++ b/plugins/MirOTR/libgcrypt-1.4.6/cipher/pubkey.c @@ -1518,7 +1518,7 @@ sexp_data_to_mpi (gcry_sexp_t input, unsigned int nbits, gcry_mpi_t *ret_mpi, the given algorithm. */ rc = GPG_ERR_CONFLICT; } - else if( !dlen || dlen + asnlen + 4 > nframe) + else if ( !dlen || dlen + asnlen + 4 > nframe) { /* Can't encode an DLEN byte digest MD into a NFRAME byte frame. */ diff --git a/plugins/MirOTR/libgcrypt-1.4.6/cipher/rijndael.c b/plugins/MirOTR/libgcrypt-1.4.6/cipher/rijndael.c index d43b349b41..0c092f78aa 100644 --- a/plugins/MirOTR/libgcrypt-1.4.6/cipher/rijndael.c +++ b/plugins/MirOTR/libgcrypt-1.4.6/cipher/rijndael.c @@ -134,7 +134,7 @@ do_setkey (RIJNDAEL_context *ctx, const byte *key, const unsigned keylen) ctx->use_padlock = 0; #endif - if( keylen == 128/8 ) + if ( keylen == 128/8 ) { ROUNDS = 10; KC = 4; diff --git a/plugins/MirOTR/libgcrypt-1.4.6/cipher/rmd160.c b/plugins/MirOTR/libgcrypt-1.4.6/cipher/rmd160.c index 7805bf53b0..6e3dc68ee6 100644 --- a/plugins/MirOTR/libgcrypt-1.4.6/cipher/rmd160.c +++ b/plugins/MirOTR/libgcrypt-1.4.6/cipher/rmd160.c @@ -406,21 +406,21 @@ rmd160_write ( void *context, const void *inbuf_arg, size_t inlen) const unsigned char *inbuf = inbuf_arg; RMD160_CONTEXT *hd = context; - if( hd->count == 64 ) /* flush the buffer */ + if ( hd->count == 64 ) /* flush the buffer */ { transform( hd, hd->buf ); _gcry_burn_stack (108+5*sizeof(void*)); hd->count = 0; hd->nblocks++; } - if( !inbuf ) + if ( !inbuf ) return; - if( hd->count ) + if ( hd->count ) { - for( ; inlen && hd->count < 64; inlen-- ) + for ( ; inlen && hd->count < 64; inlen-- ) hd->buf[hd->count++] = *inbuf++; rmd160_write( hd, NULL, 0 ); - if( !inlen ) + if ( !inlen ) return; } @@ -433,7 +433,7 @@ rmd160_write ( void *context, const void *inbuf_arg, size_t inlen) inbuf += 64; } _gcry_burn_stack (108+5*sizeof(void*)); - for( ; inlen && hd->count < 64; inlen-- ) + for ( ; inlen && hd->count < 64; inlen-- ) hd->buf[hd->count++] = *inbuf++; } @@ -477,7 +477,7 @@ rmd160_final( void *context ) msb = t >> 26; /* add the count */ t = lsb; - if( (lsb += hd->count) < t ) + if ( (lsb += hd->count) < t ) msb++; /* multiply by 8 to make a bit count */ t = lsb; @@ -485,7 +485,7 @@ rmd160_final( void *context ) msb <<= 3; msb |= t >> 29; - if( hd->count < 56 ) /* enough room */ + if ( hd->count < 56 ) /* enough room */ { hd->buf[hd->count++] = 0x80; /* pad */ while( hd->count < 56 ) diff --git a/plugins/MirOTR/libgcrypt-1.4.6/cipher/rsa.c b/plugins/MirOTR/libgcrypt-1.4.6/cipher/rsa.c index cf278c2532..a6b225e0f0 100644 --- a/plugins/MirOTR/libgcrypt-1.4.6/cipher/rsa.c +++ b/plugins/MirOTR/libgcrypt-1.4.6/cipher/rsa.c @@ -285,7 +285,7 @@ generate_std (RSA_secret_key *sk, unsigned int nbits, unsigned long use_e, u = gcry_mpi_snew ( nbits ); mpi_invm(u, p, q ); - if( DBG_CIPHER ) + if ( DBG_CIPHER ) { log_mpidump(" p= ", p ); log_mpidump(" q= ", q ); @@ -534,7 +534,7 @@ generate_x931 (RSA_secret_key *sk, unsigned int nbits, unsigned long e_value, u = f; f = NULL; mpi_invm (u, p, q ); - if( DBG_CIPHER ) + if ( DBG_CIPHER ) { if (*swapped) log_debug ("p and q are swapped\n"); @@ -599,7 +599,7 @@ check_secret_key( RSA_secret_key *sk ) static void public(gcry_mpi_t output, gcry_mpi_t input, RSA_public_key *pkey ) { - if( output == input ) /* powm doesn't like output and input the same */ + if ( output == input ) /* powm doesn't like output and input the same */ { gcry_mpi_t x = mpi_alloc( mpi_get_nlimbs(input)*2 ); mpi_powm( x, input, pkey->e, pkey->n ); @@ -625,7 +625,7 @@ stronger_key_check ( RSA_secret_key *skey ) log_info ( "RSA Oops: n != p * q\n" ); /* check that p is less than q */ - if( mpi_cmp( skey->p, skey->q ) > 0 ) + if ( mpi_cmp( skey->p, skey->q ) > 0 ) { log_info ("RSA Oops: p >= q - fixed\n"); _gcry_mpi_swap ( skey->p, skey->q); diff --git a/plugins/MirOTR/libgcrypt-1.4.6/cipher/seed.c b/plugins/MirOTR/libgcrypt-1.4.6/cipher/seed.c index b0980d61ec..f1e921148f 100644 --- a/plugins/MirOTR/libgcrypt-1.4.6/cipher/seed.c +++ b/plugins/MirOTR/libgcrypt-1.4.6/cipher/seed.c @@ -273,7 +273,7 @@ do_setkey (SEED_context *ctx, const byte *key, const unsigned keylen) { initialized = 1; selftest_failed = selftest (); - if( selftest_failed ) + if ( selftest_failed ) log_error ("%s\n", selftest_failed ); } if (selftest_failed) diff --git a/plugins/MirOTR/libgcrypt-1.4.6/cipher/sha1.c b/plugins/MirOTR/libgcrypt-1.4.6/cipher/sha1.c index 8862c64b0a..c7f697c7bb 100644 --- a/plugins/MirOTR/libgcrypt-1.4.6/cipher/sha1.c +++ b/plugins/MirOTR/libgcrypt-1.4.6/cipher/sha1.c @@ -300,7 +300,7 @@ sha1_final(void *context) msb = t >> 26; /* add the count */ t = lsb; - if( (lsb += hd->count) < t ) + if ( (lsb += hd->count) < t ) msb++; /* multiply by 8 to make a bit count */ t = lsb; @@ -308,7 +308,7 @@ sha1_final(void *context) msb <<= 3; msb |= t >> 29; - if( hd->count < 56 ) /* enough room */ + if ( hd->count < 56 ) /* enough room */ { hd->buf[hd->count++] = 0x80; /* pad */ while( hd->count < 56 ) diff --git a/plugins/MirOTR/libgcrypt-1.4.6/cipher/tiger.c b/plugins/MirOTR/libgcrypt-1.4.6/cipher/tiger.c index a6feb316c2..afc756d50e 100644 --- a/plugins/MirOTR/libgcrypt-1.4.6/cipher/tiger.c +++ b/plugins/MirOTR/libgcrypt-1.4.6/cipher/tiger.c @@ -743,21 +743,21 @@ tiger_write ( void *context, const void *inbuf_arg, size_t inlen) const unsigned char *inbuf = inbuf_arg; TIGER_CONTEXT *hd = context; - if( hd->count == 64 ) /* flush the buffer */ + if ( hd->count == 64 ) /* flush the buffer */ { transform( hd, hd->buf ); _gcry_burn_stack (21*8+11*sizeof(void*)); hd->count = 0; hd->nblocks++; } - if( !inbuf ) + if ( !inbuf ) return; - if( hd->count ) + if ( hd->count ) { - for( ; inlen && hd->count < 64; inlen-- ) + for ( ; inlen && hd->count < 64; inlen-- ) hd->buf[hd->count++] = *inbuf++; tiger_write( hd, NULL, 0 ); - if( !inlen ) + if ( !inlen ) return; } @@ -770,7 +770,7 @@ tiger_write ( void *context, const void *inbuf_arg, size_t inlen) inbuf += 64; } _gcry_burn_stack (21*8+11*sizeof(void*)); - for( ; inlen && hd->count < 64; inlen-- ) + for ( ; inlen && hd->count < 64; inlen-- ) hd->buf[hd->count++] = *inbuf++; } @@ -794,7 +794,7 @@ tiger_final( void *context ) msb = t >> 26; /* add the count */ t = lsb; - if( (lsb += hd->count) < t ) + if ( (lsb += hd->count) < t ) msb++; /* multiply by 8 to make a bit count */ t = lsb; @@ -802,7 +802,7 @@ tiger_final( void *context ) msb <<= 3; msb |= t >> 29; - if( hd->count < 56 ) /* enough room */ + if ( hd->count < 56 ) /* enough room */ { hd->buf[hd->count++] = pad; while( hd->count < 56 ) diff --git a/plugins/MirOTR/libgcrypt-1.4.6/cipher/twofish.c b/plugins/MirOTR/libgcrypt-1.4.6/cipher/twofish.c index 5274c4001d..2183aa0b7b 100644 --- a/plugins/MirOTR/libgcrypt-1.4.6/cipher/twofish.c +++ b/plugins/MirOTR/libgcrypt-1.4.6/cipher/twofish.c @@ -584,7 +584,7 @@ do_twofish_setkey (TWOFISH_context *ctx, const byte *key, const unsigned keylen) static const char *selftest_failed=0; /* Check key length. */ - if( ( ( keylen - 16 ) | 16 ) != 16 ) + if ( ( ( keylen - 16 ) | 16 ) != 16 ) return GPG_ERR_INV_KEYLEN; /* Do self-test if necessary. */ @@ -592,10 +592,10 @@ do_twofish_setkey (TWOFISH_context *ctx, const byte *key, const unsigned keylen) { initialized = 1; selftest_failed = selftest (); - if( selftest_failed ) + if ( selftest_failed ) log_error("%s\n", selftest_failed ); } - if( selftest_failed ) + if ( selftest_failed ) return GPG_ERR_SELFTEST_FAILED; /* Compute the first two words of the S vector. The magic numbers are diff --git a/plugins/MirOTR/libgcrypt-1.4.6/mpi/mpi-add.c b/plugins/MirOTR/libgcrypt-1.4.6/mpi/mpi-add.c index ada257ae1e..a5cbc0f0fe 100644 --- a/plugins/MirOTR/libgcrypt-1.4.6/mpi/mpi-add.c +++ b/plugins/MirOTR/libgcrypt-1.4.6/mpi/mpi-add.c @@ -48,18 +48,18 @@ gcry_mpi_add_ui(gcry_mpi_t w, gcry_mpi_t u, unsigned long v ) /* If not space for W (and possible carry), increase space. */ wsize = usize + 1; - if( w->alloced < wsize ) + if ( w->alloced < wsize ) mpi_resize(w, wsize); /* These must be after realloc (U may be the same as W). */ up = u->d; wp = w->d; - if( !usize ) { /* simple */ + if ( !usize ) { /* simple */ wp[0] = v; wsize = v? 1:0; } - else if( !usign ) { /* mpi is not negative */ + else if ( !usign ) { /* mpi is not negative */ mpi_limb_t cy; cy = _gcry_mpih_add_1(wp, up, usize, v); wp[usize] = cy; @@ -67,7 +67,7 @@ gcry_mpi_add_ui(gcry_mpi_t w, gcry_mpi_t u, unsigned long v ) } else { /* The signs are different. Need exact comparison to determine * which operand to subtract from which. */ - if( usize == 1 && up[0] < v ) { + if ( usize == 1 && up[0] < v ) { wp[0] = v - up[0]; wsize = 1; } @@ -91,7 +91,7 @@ gcry_mpi_add(gcry_mpi_t w, gcry_mpi_t u, gcry_mpi_t v) mpi_size_t usize, vsize, wsize; int usign, vsign, wsign; - if( u->nlimbs < v->nlimbs ) { /* Swap U and V. */ + if ( u->nlimbs < v->nlimbs ) { /* Swap U and V. */ usize = v->nlimbs; usign = v->sign; vsize = u->nlimbs; @@ -116,31 +116,31 @@ gcry_mpi_add(gcry_mpi_t w, gcry_mpi_t u, gcry_mpi_t v) wp = w->d; wsign = 0; - if( !vsize ) { /* simple */ + if ( !vsize ) { /* simple */ MPN_COPY(wp, up, usize ); wsize = usize; wsign = usign; } - else if( usign != vsign ) { /* different sign */ + else if ( usign != vsign ) { /* different sign */ /* This test is right since USIZE >= VSIZE */ - if( usize != vsize ) { + if ( usize != vsize ) { _gcry_mpih_sub(wp, up, usize, vp, vsize); wsize = usize; MPN_NORMALIZE(wp, wsize); wsign = usign; } - else if( _gcry_mpih_cmp(up, vp, usize) < 0 ) { + else if ( _gcry_mpih_cmp(up, vp, usize) < 0 ) { _gcry_mpih_sub_n(wp, vp, up, usize); wsize = usize; MPN_NORMALIZE(wp, wsize); - if( !usign ) + if ( !usign ) wsign = 1; } else { _gcry_mpih_sub_n(wp, up, vp, usize); wsize = usize; MPN_NORMALIZE(wp, wsize); - if( usign ) + if ( usign ) wsign = 1; } } @@ -148,7 +148,7 @@ gcry_mpi_add(gcry_mpi_t w, gcry_mpi_t u, gcry_mpi_t v) mpi_limb_t cy = _gcry_mpih_add(wp, up, usize, vp, vsize); wp[usize] = cy; wsize = usize + cy; - if( usign ) + if ( usign ) wsign = 1; } @@ -174,19 +174,19 @@ gcry_mpi_sub_ui(gcry_mpi_t w, gcry_mpi_t u, unsigned long v ) /* If not space for W (and possible carry), increase space. */ wsize = usize + 1; - if( w->alloced < wsize ) + if ( w->alloced < wsize ) mpi_resize(w, wsize); /* These must be after realloc (U may be the same as W). */ up = u->d; wp = w->d; - if( !usize ) { /* simple */ + if ( !usize ) { /* simple */ wp[0] = v; wsize = v? 1:0; wsign = 1; } - else if( usign ) { /* mpi and v are negative */ + else if ( usign ) { /* mpi and v are negative */ mpi_limb_t cy; cy = _gcry_mpih_add_1(wp, up, usize, v); wp[usize] = cy; @@ -194,7 +194,7 @@ gcry_mpi_sub_ui(gcry_mpi_t w, gcry_mpi_t u, unsigned long v ) } else { /* The signs are different. Need exact comparison to determine * which operand to subtract from which. */ - if( usize == 1 && up[0] < v ) { + if ( usize == 1 && up[0] < v ) { wp[0] = v - up[0]; wsize = 1; wsign = 1; diff --git a/plugins/MirOTR/libgcrypt-1.4.6/mpi/mpi-bit.c b/plugins/MirOTR/libgcrypt-1.4.6/mpi/mpi-bit.c index 32c820c291..5aeedbbf6d 100644 --- a/plugins/MirOTR/libgcrypt-1.4.6/mpi/mpi-bit.c +++ b/plugins/MirOTR/libgcrypt-1.4.6/mpi/mpi-bit.c @@ -54,10 +54,10 @@ _gcry_clz_tab[] = void _gcry_mpi_normalize( gcry_mpi_t a ) { - if( mpi_is_opaque(a) ) + if ( mpi_is_opaque(a) ) return; - for( ; a->nlimbs && !a->d[a->nlimbs-1]; a->nlimbs-- ) + for ( ; a->nlimbs && !a->d[a->nlimbs-1]; a->nlimbs-- ) ; } @@ -71,14 +71,14 @@ gcry_mpi_get_nbits( gcry_mpi_t a ) { unsigned n; - if( mpi_is_opaque(a) ) { + if ( mpi_is_opaque(a) ) { return a->sign; /* which holds the number of bits */ } _gcry_mpi_normalize( a ); - if( a->nlimbs ) { + if ( a->nlimbs ) { mpi_limb_t alimb = a->d[a->nlimbs-1]; - if( alimb ) + if ( alimb ) count_leading_zeros( n, alimb ); else n = BITS_PER_MPI_LIMB; @@ -102,7 +102,7 @@ gcry_mpi_test_bit( gcry_mpi_t a, unsigned int n ) limbno = n / BITS_PER_MPI_LIMB; bitno = n % BITS_PER_MPI_LIMB; - if( limbno >= a->nlimbs ) + if ( limbno >= a->nlimbs ) return 0; /* too far left: this is a 0 */ limb = a->d[limbno]; return (limb & (A_LIMB_1 << bitno))? 1: 0; @@ -161,11 +161,11 @@ gcry_mpi_clear_highbit( gcry_mpi_t a, unsigned int n ) limbno = n / BITS_PER_MPI_LIMB; bitno = n % BITS_PER_MPI_LIMB; - if( limbno >= a->nlimbs ) + if ( limbno >= a->nlimbs ) return; /* not allocated, therefore no need to clear bits :-) */ - for( ; bitno < BITS_PER_MPI_LIMB; bitno++ ) + for ( ; bitno < BITS_PER_MPI_LIMB; bitno++ ) a->d[limbno] &= ~(A_LIMB_1 << bitno); a->nlimbs = limbno+1; } @@ -181,7 +181,7 @@ gcry_mpi_clear_bit( gcry_mpi_t a, unsigned int n ) limbno = n / BITS_PER_MPI_LIMB; bitno = n % BITS_PER_MPI_LIMB; - if( limbno >= a->nlimbs ) + if ( limbno >= a->nlimbs ) return; /* don't need to clear this bit, it's to far to left */ a->d[limbno] &= ~(A_LIMB_1 << bitno); } @@ -198,12 +198,12 @@ _gcry_mpi_rshift_limbs( gcry_mpi_t a, unsigned int count ) mpi_size_t n = a->nlimbs; unsigned int i; - if( count >= n ) { + if ( count >= n ) { a->nlimbs = 0; return; } - for( i = 0; i < n - count; i++ ) + for ( i = 0; i < n - count; i++ ) ap[i] = ap[i+count]; ap[i] = 0; a->nlimbs -= count; diff --git a/plugins/MirOTR/libgcrypt-1.4.6/mpi/mpi-cmp.c b/plugins/MirOTR/libgcrypt-1.4.6/mpi/mpi-cmp.c index 9dd10830b0..eb62885e21 100644 --- a/plugins/MirOTR/libgcrypt-1.4.6/mpi/mpi-cmp.c +++ b/plugins/MirOTR/libgcrypt-1.4.6/mpi/mpi-cmp.c @@ -75,15 +75,15 @@ gcry_mpi_cmp (gcry_mpi_t u, gcry_mpi_t v) /* U and V are either both positive or both negative. */ - if( usize != vsize && !u->sign && !v->sign ) + if ( usize != vsize && !u->sign && !v->sign ) return usize - vsize; - if( usize != vsize && u->sign && v->sign ) + if ( usize != vsize && u->sign && v->sign ) return vsize + usize; - if( !usize ) + if ( !usize ) return 0; - if( !(cmp = _gcry_mpih_cmp( u->d, v->d, usize )) ) + if ( !(cmp = _gcry_mpih_cmp( u->d, v->d, usize )) ) return 0; - if( (cmp < 0?1:0) == (u->sign?1:0)) + if ( (cmp < 0?1:0) == (u->sign?1:0)) return 1; return -1; diff --git a/plugins/MirOTR/libgcrypt-1.4.6/mpi/mpi-div.c b/plugins/MirOTR/libgcrypt-1.4.6/mpi/mpi-div.c index 0d8a2d1688..690a7e3885 100644 --- a/plugins/MirOTR/libgcrypt-1.4.6/mpi/mpi-div.c +++ b/plugins/MirOTR/libgcrypt-1.4.6/mpi/mpi-div.c @@ -42,17 +42,17 @@ _gcry_mpi_fdiv_r( gcry_mpi_t rem, gcry_mpi_t dividend, gcry_mpi_t divisor ) /* We need the original value of the divisor after the remainder has been * preliminary calculated. We have to copy it to temporary space if it's * the same variable as REM. */ - if( rem == divisor ) { + if ( rem == divisor ) { temp_divisor = mpi_copy( divisor ); divisor = temp_divisor; } _gcry_mpi_tdiv_r( rem, dividend, divisor ); - if( ((divisor_sign?1:0) ^ (dividend->sign?1:0)) && rem->nlimbs ) + if ( ((divisor_sign?1:0) ^ (dividend->sign?1:0)) && rem->nlimbs ) gcry_mpi_add( rem, rem, divisor); - if( temp_divisor ) + if ( temp_divisor ) mpi_free(temp_divisor); } @@ -70,10 +70,10 @@ _gcry_mpi_fdiv_r_ui( gcry_mpi_t rem, gcry_mpi_t dividend, ulong divisor ) mpi_limb_t rlimb; rlimb = _gcry_mpih_mod_1( dividend->d, dividend->nlimbs, divisor ); - if( rlimb && dividend->sign ) + if ( rlimb && dividend->sign ) rlimb = divisor - rlimb; - if( rem ) { + if ( rem ) { rem->d[0] = rlimb; rem->nlimbs = rlimb? 1:0; } @@ -95,19 +95,19 @@ _gcry_mpi_fdiv_qr( gcry_mpi_t quot, gcry_mpi_t rem, gcry_mpi_t dividend, gcry_mp int divisor_sign = divisor->sign; gcry_mpi_t temp_divisor = NULL; - if( quot == divisor || rem == divisor ) { + if ( quot == divisor || rem == divisor ) { temp_divisor = mpi_copy( divisor ); divisor = temp_divisor; } _gcry_mpi_tdiv_qr( quot, rem, dividend, divisor ); - if( (divisor_sign ^ dividend->sign) && rem->nlimbs ) { + if ( (divisor_sign ^ dividend->sign) && rem->nlimbs ) { gcry_mpi_sub_ui( quot, quot, 1 ); gcry_mpi_add( rem, rem, divisor); } - if( temp_divisor ) + if ( temp_divisor ) mpi_free(temp_divisor); } @@ -148,13 +148,13 @@ _gcry_mpi_tdiv_qr( gcry_mpi_t quot, gcry_mpi_t rem, gcry_mpi_t num, gcry_mpi_t d mpi_resize( rem, rsize); qsize = rsize - dsize; /* qsize cannot be bigger than this. */ - if( qsize <= 0 ) { - if( num != rem ) { + if ( qsize <= 0 ) { + if ( num != rem ) { rem->nlimbs = num->nlimbs; rem->sign = num->sign; MPN_COPY(rem->d, num->d, nsize); } - if( quot ) { + if ( quot ) { /* This needs to follow the assignment to rem, in case the * numerator and quotient are the same. */ quot->nlimbs = 0; @@ -163,7 +163,7 @@ _gcry_mpi_tdiv_qr( gcry_mpi_t quot, gcry_mpi_t rem, gcry_mpi_t num, gcry_mpi_t d return; } - if( quot ) + if ( quot ) mpi_resize( quot, qsize); /* Read pointers here, when reallocation is finished. */ @@ -172,9 +172,9 @@ _gcry_mpi_tdiv_qr( gcry_mpi_t quot, gcry_mpi_t rem, gcry_mpi_t num, gcry_mpi_t d rp = rem->d; /* Optimize division by a single-limb divisor. */ - if( dsize == 1 ) { + if ( dsize == 1 ) { mpi_limb_t rlimb; - if( quot ) { + if ( quot ) { qp = quot->d; rlimb = _gcry_mpih_divmod_1( qp, np, nsize, dp[0] ); qsize -= qp[qsize - 1] == 0; @@ -191,7 +191,7 @@ _gcry_mpi_tdiv_qr( gcry_mpi_t quot, gcry_mpi_t rem, gcry_mpi_t num, gcry_mpi_t d } - if( quot ) { + if ( quot ) { qp = quot->d; /* Make sure QP and NP point to different objects. Otherwise the * numerator would be gradually overwritten by the quotient limbs. */ @@ -211,7 +211,7 @@ _gcry_mpi_tdiv_qr( gcry_mpi_t quot, gcry_mpi_t rem, gcry_mpi_t num, gcry_mpi_t d * shifting it NORMALIZATION_STEPS bits to the left. Also shift the * numerator the same number of steps (to keep the quotient the same!). */ - if( normalization_steps ) { + if ( normalization_steps ) { mpi_ptr_t tp; mpi_limb_t nlimb; @@ -227,7 +227,7 @@ _gcry_mpi_tdiv_qr( gcry_mpi_t quot, gcry_mpi_t rem, gcry_mpi_t num, gcry_mpi_t d * significant word. Move the shifted numerator in the remainder * meanwhile. */ nlimb = _gcry_mpih_lshift(rp, np, nsize, normalization_steps); - if( nlimb ) { + if ( nlimb ) { rp[nsize] = nlimb; rsize = nsize + 1; } @@ -237,7 +237,7 @@ _gcry_mpi_tdiv_qr( gcry_mpi_t quot, gcry_mpi_t rem, gcry_mpi_t num, gcry_mpi_t d else { /* The denominator is already normalized, as required. Copy it to * temporary space if it overlaps with the quotient or remainder. */ - if( dp == rp || (quot && (dp == qp))) { + if ( dp == rp || (quot && (dp == qp))) { mpi_ptr_t tp; marker_nlimbs[markidx] = dsize; @@ -248,7 +248,7 @@ _gcry_mpi_tdiv_qr( gcry_mpi_t quot, gcry_mpi_t rem, gcry_mpi_t num, gcry_mpi_t d } /* Move the numerator to the remainder. */ - if( rp != np ) + if ( rp != np ) MPN_COPY(rp, np, nsize); rsize = nsize; @@ -256,7 +256,7 @@ _gcry_mpi_tdiv_qr( gcry_mpi_t quot, gcry_mpi_t rem, gcry_mpi_t num, gcry_mpi_t d q_limb = _gcry_mpih_divrem( qp, 0, rp, rsize, dp, dsize ); - if( quot ) { + if ( quot ) { qsize = rsize - dsize; if(q_limb) { qp[qsize] = q_limb; @@ -270,7 +270,7 @@ _gcry_mpi_tdiv_qr( gcry_mpi_t quot, gcry_mpi_t rem, gcry_mpi_t num, gcry_mpi_t d rsize = dsize; MPN_NORMALIZE (rp, rsize); - if( normalization_steps && rsize ) { + if ( normalization_steps && rsize ) { _gcry_mpih_rshift(rp, rp, rsize, normalization_steps); rsize -= rp[rsize - 1] == 0?1:0; } @@ -293,7 +293,7 @@ _gcry_mpi_tdiv_q_2exp( gcry_mpi_t w, gcry_mpi_t u, unsigned int count ) usize = u->nlimbs; limb_cnt = count / BITS_PER_MPI_LIMB; wsize = usize - limb_cnt; - if( limb_cnt >= usize ) + if ( limb_cnt >= usize ) w->nlimbs = 0; else { mpi_ptr_t wp; @@ -304,7 +304,7 @@ _gcry_mpi_tdiv_q_2exp( gcry_mpi_t w, gcry_mpi_t u, unsigned int count ) up = u->d; count %= BITS_PER_MPI_LIMB; - if( count ) { + if ( count ) { _gcry_mpih_rshift( wp, up + limb_cnt, wsize, count ); wsize -= !wp[wsize - 1]; } diff --git a/plugins/MirOTR/libgcrypt-1.4.6/mpi/mpi-inline.h b/plugins/MirOTR/libgcrypt-1.4.6/mpi/mpi-inline.h index 88d9f56c41..fb43951b1d 100644 --- a/plugins/MirOTR/libgcrypt-1.4.6/mpi/mpi-inline.h +++ b/plugins/MirOTR/libgcrypt-1.4.6/mpi/mpi-inline.h @@ -41,20 +41,20 @@ _gcry_mpih_add_1( mpi_ptr_t res_ptr, mpi_ptr_t s1_ptr, x = *s1_ptr++; s2_limb += x; *res_ptr++ = s2_limb; - if( s2_limb < x ) { /* sum is less than the left operand: handle carry */ + if ( s2_limb < x ) { /* sum is less than the left operand: handle carry */ while( --s1_size ) { x = *s1_ptr++ + 1; /* add carry */ *res_ptr++ = x; /* and store */ - if( x ) /* not 0 (no overflow): we can stop */ + if ( x ) /* not 0 (no overflow): we can stop */ goto leave; } return 1; /* return carry (size of s1 to small) */ } leave: - if( res_ptr != s1_ptr ) { /* not the same variable */ + if ( res_ptr != s1_ptr ) { /* not the same variable */ mpi_size_t i; /* copy the rest */ - for( i=0; i < s1_size-1; i++ ) + for ( i=0; i < s1_size-1; i++ ) res_ptr[i] = s1_ptr[i]; } return 0; /* no carry */ @@ -68,10 +68,10 @@ _gcry_mpih_add(mpi_ptr_t res_ptr, mpi_ptr_t s1_ptr, mpi_size_t s1_size, { mpi_limb_t cy = 0; - if( s2_size ) + if ( s2_size ) cy = _gcry_mpih_add_n( res_ptr, s1_ptr, s2_ptr, s2_size ); - if( s1_size - s2_size ) + if ( s1_size - s2_size ) cy = _gcry_mpih_add_1( res_ptr + s2_size, s1_ptr + s2_size, s1_size - s2_size, cy); return cy; @@ -87,20 +87,20 @@ _gcry_mpih_sub_1(mpi_ptr_t res_ptr, mpi_ptr_t s1_ptr, x = *s1_ptr++; s2_limb = x - s2_limb; *res_ptr++ = s2_limb; - if( s2_limb > x ) { + if ( s2_limb > x ) { while( --s1_size ) { x = *s1_ptr++; *res_ptr++ = x - 1; - if( x ) + if ( x ) goto leave; } return 1; } leave: - if( res_ptr != s1_ptr ) { + if ( res_ptr != s1_ptr ) { mpi_size_t i; - for( i=0; i < s1_size-1; i++ ) + for ( i=0; i < s1_size-1; i++ ) res_ptr[i] = s1_ptr[i]; } return 0; @@ -114,10 +114,10 @@ _gcry_mpih_sub( mpi_ptr_t res_ptr, mpi_ptr_t s1_ptr, mpi_size_t s1_size, { mpi_limb_t cy = 0; - if( s2_size ) + if ( s2_size ) cy = _gcry_mpih_sub_n(res_ptr, s1_ptr, s2_ptr, s2_size); - if( s1_size - s2_size ) + if ( s1_size - s2_size ) cy = _gcry_mpih_sub_1(res_ptr + s2_size, s1_ptr + s2_size, s1_size - s2_size, cy); return cy; @@ -135,10 +135,10 @@ _gcry_mpih_cmp( mpi_ptr_t op1_ptr, mpi_ptr_t op2_ptr, mpi_size_t size ) mpi_size_t i; mpi_limb_t op1_word, op2_word; - for( i = size - 1; i >= 0 ; i--) { + for ( i = size - 1; i >= 0 ; i--) { op1_word = op1_ptr[i]; op2_word = op2_ptr[i]; - if( op1_word != op2_word ) + if ( op1_word != op2_word ) goto diff; } return 0; diff --git a/plugins/MirOTR/libgcrypt-1.4.6/mpi/mpi-internal.h b/plugins/MirOTR/libgcrypt-1.4.6/mpi/mpi-internal.h index f9c1f9d4db..c560e5691f 100644 --- a/plugins/MirOTR/libgcrypt-1.4.6/mpi/mpi-internal.h +++ b/plugins/MirOTR/libgcrypt-1.4.6/mpi/mpi-internal.h @@ -76,7 +76,7 @@ typedef int mpi_size_t; /* (must be a signed type) */ #define MAX(h,i) ((h) > (i) ? (h) : (i)) #define RESIZE_IF_NEEDED(a,b) \ do { \ - if( (a)->alloced < (b) ) \ + if ( (a)->alloced < (b) ) \ mpi_resize((a), (b)); \ } while(0) @@ -84,21 +84,21 @@ typedef int mpi_size_t; /* (must be a signed type) */ #define MPN_COPY( d, s, n) \ do { \ mpi_size_t _i; \ - for( _i = 0; _i < (n); _i++ ) \ + for ( _i = 0; _i < (n); _i++ ) \ (d)[_i] = (s)[_i]; \ } while(0) #define MPN_COPY_INCR( d, s, n) \ do { \ mpi_size_t _i; \ - for( _i = 0; _i < (n); _i++ ) \ + for ( _i = 0; _i < (n); _i++ ) \ (d)[_i] = (d)[_i]; \ } while (0) #define MPN_COPY_DECR( d, s, n ) \ do { \ mpi_size_t _i; \ - for( _i = (n)-1; _i >= 0; _i--) \ + for ( _i = (n)-1; _i >= 0; _i--) \ (d)[_i] = (s)[_i]; \ } while(0) @@ -106,14 +106,14 @@ typedef int mpi_size_t; /* (must be a signed type) */ #define MPN_ZERO(d, n) \ do { \ int _i; \ - for( _i = 0; _i < (n); _i++ ) \ + for ( _i = 0; _i < (n); _i++ ) \ (d)[_i] = 0; \ } while (0) #define MPN_NORMALIZE(d, n) \ do { \ while( (n) > 0 ) { \ - if( (d)[(n)-1] ) \ + if ( (d)[(n)-1] ) \ break; \ (n)--; \ } \ @@ -121,8 +121,8 @@ typedef int mpi_size_t; /* (must be a signed type) */ #define MPN_NORMALIZE_NOT_ZERO(d, n) \ do { \ - for(;;) { \ - if( (d)[(n)-1] ) \ + for (;;) { \ + if ( (d)[(n)-1] ) \ break; \ (n)--; \ } \ @@ -130,7 +130,7 @@ typedef int mpi_size_t; /* (must be a signed type) */ #define MPN_MUL_N_RECURSE(prodp, up, vp, size, tspace) \ do { \ - if( (size) < KARATSUBA_THRESHOLD ) \ + if ( (size) < KARATSUBA_THRESHOLD ) \ mul_n_basecase (prodp, up, vp, size); \ else \ mul_n (prodp, up, vp, size, tspace); \ @@ -151,15 +151,15 @@ typedef int mpi_size_t; /* (must be a signed type) */ _q += (nh); /* DI is 2**BITS_PER_MPI_LIMB too small */ \ umul_ppmm (_xh, _xl, _q, (d)); \ sub_ddmmss (_xh, _r, (nh), (nl), _xh, _xl); \ - if( _xh ) { \ + if ( _xh ) { \ sub_ddmmss (_xh, _r, _xh, _r, 0, (d)); \ _q++; \ - if( _xh) { \ + if ( _xh) { \ sub_ddmmss (_xh, _r, _xh, _r, 0, (d)); \ _q++; \ } \ } \ - if( _r >= (d) ) { \ + if ( _r >= (d) ) { \ _r -= (d); \ _q++; \ } \ diff --git a/plugins/MirOTR/libgcrypt-1.4.6/mpi/mpi-inv.c b/plugins/MirOTR/libgcrypt-1.4.6/mpi/mpi-inv.c index 5d269466e0..530f8fa4ff 100644 --- a/plugins/MirOTR/libgcrypt-1.4.6/mpi/mpi-inv.c +++ b/plugins/MirOTR/libgcrypt-1.4.6/mpi/mpi-inv.c @@ -98,7 +98,7 @@ gcry_mpi_invm( gcry_mpi_t x, gcry_mpi_t a, gcry_mpi_t n ) v1 = mpi_copy(v); /* !-- used as const 1 */ v2 = mpi_alloc( mpi_get_nlimbs(u) ); mpi_sub( v2, u1, u ); v3 = mpi_copy(v); - if( mpi_test_bit(u, 0) ) { /* u is odd */ + if ( mpi_test_bit(u, 0) ) { /* u is odd */ t1 = mpi_alloc_set_ui(0); t2 = mpi_alloc_set_ui(1); t2->sign = 1; t3 = mpi_copy(v); t3->sign = !t3->sign; @@ -111,7 +111,7 @@ gcry_mpi_invm( gcry_mpi_t x, gcry_mpi_t a, gcry_mpi_t n ) } do { do { - if( mpi_test_bit(t1, 0) || mpi_test_bit(t2, 0) ) { /* one is odd */ + if ( mpi_test_bit(t1, 0) || mpi_test_bit(t2, 0) ) { /* one is odd */ mpi_add(t1, t1, v); mpi_sub(t2, t2, u); } @@ -122,7 +122,7 @@ gcry_mpi_invm( gcry_mpi_t x, gcry_mpi_t a, gcry_mpi_t n ) ; } while( !mpi_test_bit( t3, 0 ) ); /* while t3 is even */ - if( !t3->sign ) { + if ( !t3->sign ) { mpi_set(u1, t1); mpi_set(u2, t2); mpi_set(u3, t3); @@ -139,7 +139,7 @@ gcry_mpi_invm( gcry_mpi_t x, gcry_mpi_t a, gcry_mpi_t n ) mpi_sub(t1, u1, v1); mpi_sub(t2, u2, v2); mpi_sub(t3, u3, v3); - if( t1->sign ) { + if ( t1->sign ) { mpi_add(t1, t1, v); mpi_sub(t2, t2, u); } @@ -175,18 +175,18 @@ gcry_mpi_invm( gcry_mpi_t x, gcry_mpi_t a, gcry_mpi_t n ) odd = mpi_test_bit(v,0); u1 = mpi_alloc_set_ui(1); - if( !odd ) + if ( !odd ) u2 = mpi_alloc_set_ui(0); u3 = mpi_copy(u); v1 = mpi_copy(v); - if( !odd ) { + if ( !odd ) { v2 = mpi_alloc( mpi_get_nlimbs(u) ); mpi_sub( v2, u1, u ); /* U is used as const 1 */ } v3 = mpi_copy(v); - if( mpi_test_bit(u, 0) ) { /* u is odd */ + if ( mpi_test_bit(u, 0) ) { /* u is odd */ t1 = mpi_alloc_set_ui(0); - if( !odd ) { + if ( !odd ) { t2 = mpi_alloc_set_ui(1); t2->sign = 1; } t3 = mpi_copy(v); t3->sign = !t3->sign; @@ -194,14 +194,14 @@ gcry_mpi_invm( gcry_mpi_t x, gcry_mpi_t a, gcry_mpi_t n ) } else { t1 = mpi_alloc_set_ui(1); - if( !odd ) + if ( !odd ) t2 = mpi_alloc_set_ui(0); t3 = mpi_copy(u); } do { do { - if( !odd ) { - if( mpi_test_bit(t1, 0) || mpi_test_bit(t2, 0) ) { /* one is odd */ + if ( !odd ) { + if ( mpi_test_bit(t1, 0) || mpi_test_bit(t2, 0) ) { /* one is odd */ mpi_add(t1, t1, v); mpi_sub(t2, t2, u); } @@ -210,7 +210,7 @@ gcry_mpi_invm( gcry_mpi_t x, gcry_mpi_t a, gcry_mpi_t n ) mpi_rshift(t3, t3, 1); } else { - if( mpi_test_bit(t1, 0) ) + if ( mpi_test_bit(t1, 0) ) mpi_add(t1, t1, v); mpi_rshift(t1, t1, 1); mpi_rshift(t3, t3, 1); @@ -219,16 +219,16 @@ gcry_mpi_invm( gcry_mpi_t x, gcry_mpi_t a, gcry_mpi_t n ) ; } while( !mpi_test_bit( t3, 0 ) ); /* while t3 is even */ - if( !t3->sign ) { + if ( !t3->sign ) { mpi_set(u1, t1); - if( !odd ) + if ( !odd ) mpi_set(u2, t2); mpi_set(u3, t3); } else { mpi_sub(v1, v, t1); sign = u->sign; u->sign = !u->sign; - if( !odd ) + if ( !odd ) mpi_sub(v2, u, t2); u->sign = sign; sign = t3->sign; t3->sign = !t3->sign; @@ -236,12 +236,12 @@ gcry_mpi_invm( gcry_mpi_t x, gcry_mpi_t a, gcry_mpi_t n ) t3->sign = sign; } mpi_sub(t1, u1, v1); - if( !odd ) + if ( !odd ) mpi_sub(t2, u2, v2); mpi_sub(t3, u3, v3); - if( t1->sign ) { + if ( t1->sign ) { mpi_add(t1, t1, v); - if( !odd ) + if ( !odd ) mpi_sub(t2, t2, u); } } while( mpi_cmp_ui( t3, 0 ) ); /* while t3 != 0 */ @@ -251,7 +251,7 @@ gcry_mpi_invm( gcry_mpi_t x, gcry_mpi_t a, gcry_mpi_t n ) mpi_free(u1); mpi_free(v1); mpi_free(t1); - if( !odd ) { + if ( !odd ) { mpi_free(u2); mpi_free(v2); mpi_free(t2); diff --git a/plugins/MirOTR/libgcrypt-1.4.6/mpi/mpi-mpow.c b/plugins/MirOTR/libgcrypt-1.4.6/mpi/mpi-mpow.c index 131c5b67b2..33b9d393c5 100644 --- a/plugins/MirOTR/libgcrypt-1.4.6/mpi/mpi-mpow.c +++ b/plugins/MirOTR/libgcrypt-1.4.6/mpi/mpi-mpow.c @@ -52,7 +52,7 @@ build_index( gcry_mpi_t *exparray, int k, int i, int t ) bitno = t-i; for(j=k-1; j >= 0; j-- ) { idx <<= 1; - if( mpi_test_bit( exparray[j], bitno ) ) + if ( mpi_test_bit( exparray[j], bitno ) ) idx |= 1; } /*log_debug("t=%d i=%d idx=%d\n", t, i, idx );*/ @@ -81,7 +81,7 @@ _gcry_mpi_mulpowm( gcry_mpi_t res, gcry_mpi_t *basearray, gcry_mpi_t *exparray, for(t=0, i=0; (tmp=exparray[i]); i++ ) { /*log_mpidump("exp: ", tmp );*/ j = mpi_get_nbits(tmp); - if( j > t ) + if ( j > t ) t = j; } /*log_mpidump("mod: ", m );*/ @@ -101,20 +101,20 @@ _gcry_mpi_mulpowm( gcry_mpi_t res, gcry_mpi_t *basearray, gcry_mpi_t *exparray, barrett_r1, barrett_r2 ); idx = build_index( exparray, k, i, t ); gcry_assert (idx >= 0 && idx < (1<<k)); - if( !G[idx] ) { - if( !idx ) + if ( !G[idx] ) { + if ( !idx ) G[0] = mpi_alloc_set_ui( 1 ); else { for(j=0; j < k; j++ ) { - if( (idx & (1<<j) ) ) { - if( !G[idx] ) + if ( (idx & (1<<j) ) ) { + if ( !G[idx] ) G[idx] = mpi_copy( basearray[j] ); else barrett_mulm( G[idx], G[idx], basearray[j], m, barrett_y, barrett_k, barrett_r1, barrett_r2 ); } } - if( !G[idx] ) + if ( !G[idx] ) G[idx] = mpi_alloc(0); } } @@ -140,7 +140,7 @@ static void barrett_mulm( gcry_mpi_t w, gcry_mpi_t u, gcry_mpi_t v, gcry_mpi_t m, gcry_mpi_t y, int k, gcry_mpi_t r1, gcry_mpi_t r2 ) { mpi_mul(w, u, v); - if( calc_barrett( w, w, m, y, k, r1, r2 ) ) + if ( calc_barrett( w, w, m, y, k, r1, r2 ) ) mpi_fdiv_r( w, w, m ); } @@ -178,7 +178,7 @@ calc_barrett( gcry_mpi_t r, gcry_mpi_t x, gcry_mpi_t m, gcry_mpi_t y, int k, gcr int xx = k > 3 ? k-3:0; mpi_normalize( x ); - if( mpi_get_nlimbs(x) > 2*k ) + if ( mpi_get_nlimbs(x) > 2*k ) return 1; /* can't do it */ /* 1. q1 = floor( x / b^k-1) @@ -197,14 +197,14 @@ calc_barrett( gcry_mpi_t r, gcry_mpi_t x, gcry_mpi_t m, gcry_mpi_t y, int k, gcr * 3. if r < 0 then r = r + b^k+1 */ mpi_set( r1, x ); - if( r1->nlimbs > k+1 ) /* quick modulo operation */ + if ( r1->nlimbs > k+1 ) /* quick modulo operation */ r1->nlimbs = k+1; mpi_mul( r2, r2, m ); - if( r2->nlimbs > k+1 ) /* quick modulo operation */ + if ( r2->nlimbs > k+1 ) /* quick modulo operation */ r2->nlimbs = k+1; mpi_sub( r, r1, r2 ); - if( mpi_is_neg( r ) ) { + if ( mpi_is_neg( r ) ) { gcry_mpi_t tmp; tmp = mpi_alloc( k + 2 ); diff --git a/plugins/MirOTR/libgcrypt-1.4.6/mpi/mpi-mul.c b/plugins/MirOTR/libgcrypt-1.4.6/mpi/mpi-mul.c index 25aeaa0a2c..7ad9dd594b 100644 --- a/plugins/MirOTR/libgcrypt-1.4.6/mpi/mpi-mul.c +++ b/plugins/MirOTR/libgcrypt-1.4.6/mpi/mpi-mul.c @@ -41,19 +41,19 @@ gcry_mpi_mul_ui( gcry_mpi_t prod, gcry_mpi_t mult, unsigned long small_mult ) size = mult->nlimbs; sign = mult->sign; - if( !size || !small_mult ) { + if ( !size || !small_mult ) { prod->nlimbs = 0; prod->sign = 0; return; } prod_size = size + 1; - if( prod->alloced < prod_size ) + if ( prod->alloced < prod_size ) mpi_resize( prod, prod_size ); prod_ptr = prod->d; cy = _gcry_mpih_mul_1( prod_ptr, mult->d, size, (mpi_limb_t)small_mult ); - if( cy ) + if ( cy ) prod_ptr[size++] = cy; prod->nlimbs = size; prod->sign = sign; @@ -71,7 +71,7 @@ gcry_mpi_mul_2exp( gcry_mpi_t w, gcry_mpi_t u, unsigned long cnt) usize = u->nlimbs; usign = u->sign; - if( !usize ) { + if ( !usize ) { w->nlimbs = 0; w->sign = 0; return; @@ -79,16 +79,16 @@ gcry_mpi_mul_2exp( gcry_mpi_t w, gcry_mpi_t u, unsigned long cnt) limb_cnt = cnt / BITS_PER_MPI_LIMB; wsize = usize + limb_cnt + 1; - if( w->alloced < wsize ) + if ( w->alloced < wsize ) mpi_resize(w, wsize ); wp = w->d; wsize = usize + limb_cnt; wsign = usign; cnt %= BITS_PER_MPI_LIMB; - if( cnt ) { + if ( cnt ) { wlimb = _gcry_mpih_lshift( wp + limb_cnt, u->d, usize, cnt ); - if( wlimb ) { + if ( wlimb ) { wp[wsize] = wlimb; wsize++; } @@ -117,7 +117,7 @@ gcry_mpi_mul( gcry_mpi_t w, gcry_mpi_t u, gcry_mpi_t v) mpi_ptr_t tmp_limb=NULL; unsigned int tmp_limb_nlimbs = 0; - if( u->nlimbs < v->nlimbs ) { /* Swap U and V. */ + if ( u->nlimbs < v->nlimbs ) { /* Swap U and V. */ usize = v->nlimbs; usign = v->sign; usecure = mpi_is_secure(v); @@ -150,8 +150,8 @@ gcry_mpi_mul( gcry_mpi_t w, gcry_mpi_t u, gcry_mpi_t v) assign_wp = 2; /* mark it as 2 so that we can later copy it back to * mormal memory */ } - else if( w->alloced < wsize ) { - if( wp == up || wp == vp ) { + else if ( w->alloced < wsize ) { + if ( wp == up || wp == vp ) { wp = mpi_alloc_limb_space( wsize, mpi_is_secure(w) ); assign_wp = 1; } @@ -161,17 +161,17 @@ gcry_mpi_mul( gcry_mpi_t w, gcry_mpi_t u, gcry_mpi_t v) } } else { /* Make U and V not overlap with W. */ - if( wp == up ) { + if ( wp == up ) { /* W and U are identical. Allocate temporary space for U. */ tmp_limb_nlimbs = usize; up = tmp_limb = mpi_alloc_limb_space( usize, usecure ); /* Is V identical too? Keep it identical with U. */ - if( wp == vp ) + if ( wp == vp ) vp = up; /* Copy to the temporary space. */ MPN_COPY( up, wp, usize ); } - else if( wp == vp ) { + else if ( wp == vp ) { /* W and V are identical. Allocate temporary space for V. */ tmp_limb_nlimbs = vsize; vp = tmp_limb = mpi_alloc_limb_space( vsize, vsecure ); @@ -180,14 +180,14 @@ gcry_mpi_mul( gcry_mpi_t w, gcry_mpi_t u, gcry_mpi_t v) } } - if( !vsize ) + if ( !vsize ) wsize = 0; else { cy = _gcry_mpih_mul( wp, up, usize, vp, vsize ); wsize -= cy? 0:1; } - if( assign_wp ) { + if ( assign_wp ) { if (assign_wp == 2) { /* copy the temp wp from secure memory back to normal memory */ mpi_ptr_t tmp_wp = mpi_alloc_limb_space (wsize, 0); @@ -199,7 +199,7 @@ gcry_mpi_mul( gcry_mpi_t w, gcry_mpi_t u, gcry_mpi_t v) } w->nlimbs = wsize; w->sign = sign_product; - if( tmp_limb ) + if ( tmp_limb ) _gcry_mpi_free_limb_space (tmp_limb, tmp_limb_nlimbs); } diff --git a/plugins/MirOTR/libgcrypt-1.4.6/mpi/mpi-pow.c b/plugins/MirOTR/libgcrypt-1.4.6/mpi/mpi-pow.c index ca7ead0285..23e9f8eae1 100644 --- a/plugins/MirOTR/libgcrypt-1.4.6/mpi/mpi-pow.c +++ b/plugins/MirOTR/libgcrypt-1.4.6/mpi/mpi-pow.c @@ -234,7 +234,7 @@ gcry_mpi_powm (gcry_mpi_t res, if ( (mpi_limb_signed_t)e < 0 ) { /*mpih_mul( xp, rp, rsize, bp, bsize );*/ - if( bsize < KARATSUBA_THRESHOLD ) + if ( bsize < KARATSUBA_THRESHOLD ) _gcry_mpih_mul ( xp, rp, rsize, bp, bsize ); else _gcry_mpih_mul_karatsuba_case (xp, rp, rsize, bp, bsize, diff --git a/plugins/MirOTR/libgcrypt-1.4.6/mpi/mpi-scan.c b/plugins/MirOTR/libgcrypt-1.4.6/mpi/mpi-scan.c index 90699cdd69..e06d990150 100644 --- a/plugins/MirOTR/libgcrypt-1.4.6/mpi/mpi-scan.c +++ b/plugins/MirOTR/libgcrypt-1.4.6/mpi/mpi-scan.c @@ -42,8 +42,8 @@ _gcry_mpi_getbyte( gcry_mpi_t a, unsigned idx ) ap = a->d; for(n=0,i=0; i < a->nlimbs; i++ ) { limb = ap[i]; - for( j=0; j < BYTES_PER_MPI_LIMB; j++, n++ ) - if( n == idx ) + for ( j=0; j < BYTES_PER_MPI_LIMB; j++, n++ ) + if ( n == idx ) return (limb >> j*8) & 0xff; } return -1; @@ -65,38 +65,38 @@ _gcry_mpi_putbyte( gcry_mpi_t a, unsigned idx, int xc ) ap = a->d; for(n=0,i=0; i < a->alloced; i++ ) { limb = ap[i]; - for( j=0; j < BYTES_PER_MPI_LIMB; j++, n++ ) - if( n == idx ) { + for ( j=0; j < BYTES_PER_MPI_LIMB; j++, n++ ) + if ( n == idx ) { #if BYTES_PER_MPI_LIMB == 4 - if( j == 0 ) + if ( j == 0 ) limb = (limb & 0xffffff00) | c; - else if( j == 1 ) + else if ( j == 1 ) limb = (limb & 0xffff00ff) | (c<<8); - else if( j == 2 ) + else if ( j == 2 ) limb = (limb & 0xff00ffff) | (c<<16); else limb = (limb & 0x00ffffff) | (c<<24); #elif BYTES_PER_MPI_LIMB == 8 - if( j == 0 ) + if ( j == 0 ) limb = (limb & 0xffffffffffffff00) | c; - else if( j == 1 ) + else if ( j == 1 ) limb = (limb & 0xffffffffffff00ff) | (c<<8); - else if( j == 2 ) + else if ( j == 2 ) limb = (limb & 0xffffffffff00ffff) | (c<<16); - else if( j == 3 ) + else if ( j == 3 ) limb = (limb & 0xffffffff00ffffff) | (c<<24); - else if( j == 4 ) + else if ( j == 4 ) limb = (limb & 0xffffff00ffffffff) | (c<<32); - else if( j == 5 ) + else if ( j == 5 ) limb = (limb & 0xffff00ffffffffff) | (c<<40); - else if( j == 6 ) + else if ( j == 6 ) limb = (limb & 0xff00ffffffffffff) | (c<<48); else limb = (limb & 0x00ffffffffffffff) | (c<<56); #else #error please enhance this function, its ugly - i know. #endif - if( a->nlimbs <= i ) + if ( a->nlimbs <= i ) a->nlimbs = i+1; ap[i] = limb; return; @@ -115,7 +115,7 @@ _gcry_mpi_trailing_zeros( gcry_mpi_t a ) unsigned n, count = 0; for(n=0; n < a->nlimbs; n++ ) { - if( a->d[n] ) { + if ( a->d[n] ) { unsigned nn; mpi_limb_t alimb = a->d[n]; diff --git a/plugins/MirOTR/libgcrypt-1.4.6/mpi/mpicoder.c b/plugins/MirOTR/libgcrypt-1.4.6/mpi/mpicoder.c index 8f0c76f144..63e589438c 100644 --- a/plugins/MirOTR/libgcrypt-1.4.6/mpi/mpicoder.c +++ b/plugins/MirOTR/libgcrypt-1.4.6/mpi/mpicoder.c @@ -46,7 +46,7 @@ mpi_read_from_buffer (const unsigned char *buffer, unsigned *ret_nread, /* log_debug ("mpi too large (%u bits)\n", nbits); */ goto leave; } - else if( !nbits ) + else if ( !nbits ) { /* log_debug ("an mpi of size 0 is not allowed\n"); */ goto leave; @@ -160,9 +160,9 @@ mpi_fromstr (gcry_mpi_t val, const char *str) c <<= 4; if ( c2 >= '0' && c2 <= '9' ) c |= c2 - '0'; - else if( c2 >= 'a' && c2 <= 'f' ) + else if ( c2 >= 'a' && c2 <= 'f' ) c |= c2 - 'a' + 10; - else if( c2 >= 'A' && c2 <= 'F' ) + else if ( c2 >= 'A' && c2 <= 'F' ) c |= c2 - 'A' + 10; else { @@ -601,7 +601,7 @@ gcry_mpi_print (enum gcry_mpi_format format, unsigned int n = (nbits + 7)/8; /* The PGP format can only handle unsigned integers. */ - if( a->sign ) + if ( a->sign ) return gcry_error (GPG_ERR_INV_ARG); if (buffer && n+2 > len) diff --git a/plugins/MirOTR/libgcrypt-1.4.6/mpi/mpih-div.c b/plugins/MirOTR/libgcrypt-1.4.6/mpi/mpih-div.c index e41e205e1d..f151b8b17b 100644 --- a/plugins/MirOTR/libgcrypt-1.4.6/mpi/mpih-div.c +++ b/plugins/MirOTR/libgcrypt-1.4.6/mpi/mpih-div.c @@ -51,7 +51,7 @@ _gcry_mpih_mod_1(mpi_ptr_t dividend_ptr, mpi_size_t dividend_size, int dummy; /* Botch: Should this be handled at all? Rely on callers? */ - if( !dividend_size ) + if ( !dividend_size ) return 0; /* If multiplication is much faster than division, and the @@ -62,12 +62,12 @@ _gcry_mpih_mod_1(mpi_ptr_t dividend_ptr, mpi_size_t dividend_size, * Does it ever help to use udiv_qrnnd_preinv? * && Does what we save compensate for the inversion overhead? */ - if( UDIV_TIME > (2 * UMUL_TIME + 6) + if ( UDIV_TIME > (2 * UMUL_TIME + 6) && (UDIV_TIME - (2 * UMUL_TIME + 6)) * dividend_size > UDIV_TIME ) { int normalization_steps; count_leading_zeros( normalization_steps, divisor_limb ); - if( normalization_steps ) { + if ( normalization_steps ) { mpi_limb_t divisor_limb_inverted; divisor_limb <<= normalization_steps; @@ -78,7 +78,7 @@ _gcry_mpih_mod_1(mpi_ptr_t dividend_ptr, mpi_size_t dividend_size, * * Special case for DIVISOR_LIMB == 100...000. */ - if( !(divisor_limb << 1) ) + if ( !(divisor_limb << 1) ) divisor_limb_inverted = ~(mpi_limb_t)0; else udiv_qrnnd(divisor_limb_inverted, dummy, @@ -93,7 +93,7 @@ _gcry_mpih_mod_1(mpi_ptr_t dividend_ptr, mpi_size_t dividend_size, * | (dividend_ptr[dividend_size - 2] >> ...))) * ...one division less... */ - for( i = dividend_size - 2; i >= 0; i--) { + for ( i = dividend_size - 2; i >= 0; i--) { n0 = dividend_ptr[i]; UDIV_QRNND_PREINV(dummy, r, r, ((n1 << normalization_steps) @@ -115,7 +115,7 @@ _gcry_mpih_mod_1(mpi_ptr_t dividend_ptr, mpi_size_t dividend_size, * * Special case for DIVISOR_LIMB == 100...000. */ - if( !(divisor_limb << 1) ) + if ( !(divisor_limb << 1) ) divisor_limb_inverted = ~(mpi_limb_t)0; else udiv_qrnnd(divisor_limb_inverted, dummy, @@ -124,12 +124,12 @@ _gcry_mpih_mod_1(mpi_ptr_t dividend_ptr, mpi_size_t dividend_size, i = dividend_size - 1; r = dividend_ptr[i]; - if( r >= divisor_limb ) + if ( r >= divisor_limb ) r = 0; else i--; - for( ; i >= 0; i--) { + for ( ; i >= 0; i--) { n0 = dividend_ptr[i]; UDIV_QRNND_PREINV(dummy, r, r, n0, divisor_limb, divisor_limb_inverted); @@ -138,11 +138,11 @@ _gcry_mpih_mod_1(mpi_ptr_t dividend_ptr, mpi_size_t dividend_size, } } else { - if( UDIV_NEEDS_NORMALIZATION ) { + if ( UDIV_NEEDS_NORMALIZATION ) { int normalization_steps; count_leading_zeros(normalization_steps, divisor_limb); - if( normalization_steps ) { + if ( normalization_steps ) { divisor_limb <<= normalization_steps; n1 = dividend_ptr[dividend_size - 1]; @@ -178,7 +178,7 @@ _gcry_mpih_mod_1(mpi_ptr_t dividend_ptr, mpi_size_t dividend_size, else i--; - for(; i >= 0; i--) { + for (; i >= 0; i--) { n0 = dividend_ptr[i]; udiv_qrnnd (dummy, r, r, n0, divisor_limb); } @@ -225,17 +225,17 @@ _gcry_mpih_divrem( mpi_ptr_t qp, mpi_size_t qextra_limbs, d = dp[0]; n1 = np[nsize - 1]; - if( n1 >= d ) { + if ( n1 >= d ) { n1 -= d; most_significant_q_limb = 1; } qp += qextra_limbs; - for( i = nsize - 2; i >= 0; i--) + for ( i = nsize - 2; i >= 0; i--) udiv_qrnnd( qp[i], n1, n1, np[i], d ); qp -= qextra_limbs; - for( i = qextra_limbs - 1; i >= 0; i-- ) + for ( i = qextra_limbs - 1; i >= 0; i-- ) udiv_qrnnd (qp[i], n1, n1, 0, d); np[0] = n1; @@ -254,28 +254,28 @@ _gcry_mpih_divrem( mpi_ptr_t qp, mpi_size_t qextra_limbs, n1 = np[1]; n0 = np[0]; - if( n1 >= d1 && (n1 > d1 || n0 >= d0) ) { + if ( n1 >= d1 && (n1 > d1 || n0 >= d0) ) { sub_ddmmss (n1, n0, n1, n0, d1, d0); most_significant_q_limb = 1; } - for( i = qextra_limbs + nsize - 2 - 1; i >= 0; i-- ) { + for ( i = qextra_limbs + nsize - 2 - 1; i >= 0; i-- ) { mpi_limb_t q; mpi_limb_t r; - if( i >= qextra_limbs ) + if ( i >= qextra_limbs ) np--; else np[0] = 0; - if( n1 == d1 ) { + if ( n1 == d1 ) { /* Q should be either 111..111 or 111..110. Need special * treatment of this rare case as normal division would * give overflow. */ q = ~(mpi_limb_t)0; r = n0 + d1; - if( r < d1 ) { /* Carry in the addition? */ + if ( r < d1 ) { /* Carry in the addition? */ add_ssaaaa( n1, n0, r - d0, np[0], 0, d0 ); qp[i] = q; continue; @@ -290,12 +290,12 @@ _gcry_mpih_divrem( mpi_ptr_t qp, mpi_size_t qextra_limbs, n2 = np[0]; q_test: - if( n1 > r || (n1 == r && n0 > n2) ) { + if ( n1 > r || (n1 == r && n0 > n2) ) { /* The estimated Q was too large. */ q--; sub_ddmmss (n1, n0, n1, n0, 0, d0); r += d1; - if( r >= d1 ) /* If not carry, test Q again. */ + if ( r >= d1 ) /* If not carry, test Q again. */ goto q_test; } @@ -317,7 +317,7 @@ _gcry_mpih_divrem( mpi_ptr_t qp, mpi_size_t qextra_limbs, d1 = dp[dsize - 2]; n0 = np[dsize - 1]; - if( n0 >= dX ) { + if ( n0 >= dX ) { if(n0 > dX || _gcry_mpih_cmp(np, dp, dsize - 1) >= 0 ) { _gcry_mpih_sub_n(np, np, dp, dsize); n0 = np[dsize - 1]; @@ -325,12 +325,12 @@ _gcry_mpih_divrem( mpi_ptr_t qp, mpi_size_t qextra_limbs, } } - for( i = qextra_limbs + nsize - dsize - 1; i >= 0; i--) { + for ( i = qextra_limbs + nsize - dsize - 1; i >= 0; i--) { mpi_limb_t q; mpi_limb_t n1, n2; mpi_limb_t cy_limb; - if( i >= qextra_limbs ) { + if ( i >= qextra_limbs ) { np--; n2 = np[dsize]; } @@ -340,7 +340,7 @@ _gcry_mpih_divrem( mpi_ptr_t qp, mpi_size_t qextra_limbs, np[0] = 0; } - if( n0 == dX ) { + if ( n0 == dX ) { /* This might over-estimate q, but it's probably not worth * the extra code here to find out. */ q = ~(mpi_limb_t)0; @@ -354,7 +354,7 @@ _gcry_mpih_divrem( mpi_ptr_t qp, mpi_size_t qextra_limbs, while( n1 > r || (n1 == r && n0 > np[dsize - 2])) { q--; r += dX; - if( r < dX ) /* I.e. "carry in previous addition?" */ + if ( r < dX ) /* I.e. "carry in previous addition?" */ break; n1 -= n0 < d1; n0 -= d1; @@ -366,7 +366,7 @@ _gcry_mpih_divrem( mpi_ptr_t qp, mpi_size_t qextra_limbs, * could make this loop make two iterations less. */ cy_limb = _gcry_mpih_submul_1(np, dp, dsize, q); - if( n2 != cy_limb ) { + if ( n2 != cy_limb ) { _gcry_mpih_add_n(np, np, dp, dsize); q--; } @@ -399,7 +399,7 @@ _gcry_mpih_divmod_1( mpi_ptr_t quot_ptr, mpi_limb_t n1, n0, r; int dummy; - if( !dividend_size ) + if ( !dividend_size ) return 0; /* If multiplication is much faster than division, and the @@ -410,12 +410,12 @@ _gcry_mpih_divmod_1( mpi_ptr_t quot_ptr, * Does it ever help to use udiv_qrnnd_preinv? * && Does what we save compensate for the inversion overhead? */ - if( UDIV_TIME > (2 * UMUL_TIME + 6) + if ( UDIV_TIME > (2 * UMUL_TIME + 6) && (UDIV_TIME - (2 * UMUL_TIME + 6)) * dividend_size > UDIV_TIME ) { int normalization_steps; count_leading_zeros( normalization_steps, divisor_limb ); - if( normalization_steps ) { + if ( normalization_steps ) { mpi_limb_t divisor_limb_inverted; divisor_limb <<= normalization_steps; @@ -425,7 +425,7 @@ _gcry_mpih_divmod_1( mpi_ptr_t quot_ptr, * most significant bit (with weight 2**N) implicit. */ /* Special case for DIVISOR_LIMB == 100...000. */ - if( !(divisor_limb << 1) ) + if ( !(divisor_limb << 1) ) divisor_limb_inverted = ~(mpi_limb_t)0; else udiv_qrnnd(divisor_limb_inverted, dummy, @@ -440,7 +440,7 @@ _gcry_mpih_divmod_1( mpi_ptr_t quot_ptr, * | (dividend_ptr[dividend_size - 2] >> ...))) * ...one division less... */ - for( i = dividend_size - 2; i >= 0; i--) { + for ( i = dividend_size - 2; i >= 0; i--) { n0 = dividend_ptr[i]; UDIV_QRNND_PREINV( quot_ptr[i + 1], r, r, ((n1 << normalization_steps) @@ -461,7 +461,7 @@ _gcry_mpih_divmod_1( mpi_ptr_t quot_ptr, * most significant bit (with weight 2**N) implicit. */ /* Special case for DIVISOR_LIMB == 100...000. */ - if( !(divisor_limb << 1) ) + if ( !(divisor_limb << 1) ) divisor_limb_inverted = ~(mpi_limb_t) 0; else udiv_qrnnd(divisor_limb_inverted, dummy, @@ -470,12 +470,12 @@ _gcry_mpih_divmod_1( mpi_ptr_t quot_ptr, i = dividend_size - 1; r = dividend_ptr[i]; - if( r >= divisor_limb ) + if ( r >= divisor_limb ) r = 0; else quot_ptr[i--] = 0; - for( ; i >= 0; i-- ) { + for ( ; i >= 0; i-- ) { n0 = dividend_ptr[i]; UDIV_QRNND_PREINV( quot_ptr[i], r, r, n0, divisor_limb, divisor_limb_inverted); @@ -488,7 +488,7 @@ _gcry_mpih_divmod_1( mpi_ptr_t quot_ptr, int normalization_steps; count_leading_zeros (normalization_steps, divisor_limb); - if( normalization_steps ) { + if ( normalization_steps ) { divisor_limb <<= normalization_steps; n1 = dividend_ptr[dividend_size - 1]; @@ -500,7 +500,7 @@ _gcry_mpih_divmod_1( mpi_ptr_t quot_ptr, * | (dividend_ptr[dividend_size - 2] >> ...))) * ...one division less... */ - for( i = dividend_size - 2; i >= 0; i--) { + for ( i = dividend_size - 2; i >= 0; i--) { n0 = dividend_ptr[i]; udiv_qrnnd (quot_ptr[i + 1], r, r, ((n1 << normalization_steps) @@ -524,7 +524,7 @@ _gcry_mpih_divmod_1( mpi_ptr_t quot_ptr, else quot_ptr[i--] = 0; - for(; i >= 0; i--) { + for (; i >= 0; i--) { n0 = dividend_ptr[i]; udiv_qrnnd( quot_ptr[i], r, r, n0, divisor_limb ); } diff --git a/plugins/MirOTR/libgcrypt-1.4.6/mpi/mpih-mul.c b/plugins/MirOTR/libgcrypt-1.4.6/mpi/mpih-mul.c index e1f6f58eb5..d412b693fd 100644 --- a/plugins/MirOTR/libgcrypt-1.4.6/mpi/mpih-mul.c +++ b/plugins/MirOTR/libgcrypt-1.4.6/mpi/mpih-mul.c @@ -35,7 +35,7 @@ #define MPN_MUL_N_RECURSE(prodp, up, vp, size, tspace) \ do { \ - if( (size) < KARATSUBA_THRESHOLD ) \ + if ( (size) < KARATSUBA_THRESHOLD ) \ mul_n_basecase (prodp, up, vp, size); \ else \ mul_n (prodp, up, vp, size, tspace); \ @@ -80,8 +80,8 @@ mul_n_basecase( mpi_ptr_t prodp, mpi_ptr_t up, /* Multiply by the first limb in V separately, as the result can be * stored (not added) to PROD. We also avoid a loop for zeroing. */ v_limb = vp[0]; - if( v_limb <= 1 ) { - if( v_limb == 1 ) + if ( v_limb <= 1 ) { + if ( v_limb == 1 ) MPN_COPY( prodp, up, size ); else MPN_ZERO( prodp, size ); @@ -95,11 +95,11 @@ mul_n_basecase( mpi_ptr_t prodp, mpi_ptr_t up, /* For each iteration in the outer loop, multiply one limb from * U with one limb from V, and add it to PROD. */ - for( i = 1; i < size; i++ ) { + for ( i = 1; i < size; i++ ) { v_limb = vp[i]; - if( v_limb <= 1 ) { + if ( v_limb <= 1 ) { cy = 0; - if( v_limb == 1 ) + if ( v_limb == 1 ) cy = _gcry_mpih_add_n(prodp, prodp, up, size); } else @@ -117,7 +117,7 @@ static void mul_n( mpi_ptr_t prodp, mpi_ptr_t up, mpi_ptr_t vp, mpi_size_t size, mpi_ptr_t tspace ) { - if( size & 1 ) { + if ( size & 1 ) { /* The size is odd, and the code below doesn't handle that. * Multiply the least significant (size - 1) limbs with a recursive * call, and handle the most significant limb of S1 and S2 @@ -167,7 +167,7 @@ mul_n( mpi_ptr_t prodp, mpi_ptr_t up, mpi_ptr_t vp, /* Product M. ________________ * |_(U1-U0)(V0-V1)_| */ - if( _gcry_mpih_cmp(up + hsize, up, hsize) >= 0 ) { + if ( _gcry_mpih_cmp(up + hsize, up, hsize) >= 0 ) { _gcry_mpih_sub_n(prodp, up + hsize, up, hsize); negflg = 0; } @@ -175,7 +175,7 @@ mul_n( mpi_ptr_t prodp, mpi_ptr_t up, mpi_ptr_t vp, _gcry_mpih_sub_n(prodp, up, up + hsize, hsize); negflg = 1; } - if( _gcry_mpih_cmp(vp + hsize, vp, hsize) >= 0 ) { + if ( _gcry_mpih_cmp(vp + hsize, vp, hsize) >= 0 ) { _gcry_mpih_sub_n(prodp + hsize, vp + hsize, vp, hsize); negflg ^= 1; } @@ -211,12 +211,12 @@ mul_n( mpi_ptr_t prodp, mpi_ptr_t up, mpi_ptr_t vp, /* Add/copy Product L (twice) */ cy += _gcry_mpih_add_n(prodp + hsize, prodp + hsize, tspace, size); - if( cy ) + if ( cy ) _gcry_mpih_add_1(prodp + hsize + size, prodp + hsize + size, hsize, cy); MPN_COPY(prodp, tspace, hsize); cy = _gcry_mpih_add_n(prodp + hsize, prodp + hsize, tspace + hsize, hsize); - if( cy ) + if ( cy ) _gcry_mpih_add_1(prodp + size, prodp + size, size, 1); } } @@ -232,8 +232,8 @@ _gcry_mpih_sqr_n_basecase( mpi_ptr_t prodp, mpi_ptr_t up, mpi_size_t size ) /* Multiply by the first limb in V separately, as the result can be * stored (not added) to PROD. We also avoid a loop for zeroing. */ v_limb = up[0]; - if( v_limb <= 1 ) { - if( v_limb == 1 ) + if ( v_limb <= 1 ) { + if ( v_limb == 1 ) MPN_COPY( prodp, up, size ); else MPN_ZERO(prodp, size); @@ -247,11 +247,11 @@ _gcry_mpih_sqr_n_basecase( mpi_ptr_t prodp, mpi_ptr_t up, mpi_size_t size ) /* For each iteration in the outer loop, multiply one limb from * U with one limb from V, and add it to PROD. */ - for( i=1; i < size; i++) { + for ( i=1; i < size; i++) { v_limb = up[i]; - if( v_limb <= 1 ) { + if ( v_limb <= 1 ) { cy_limb = 0; - if( v_limb == 1 ) + if ( v_limb == 1 ) cy_limb = _gcry_mpih_add_n(prodp, prodp, up, size); } else @@ -267,7 +267,7 @@ void _gcry_mpih_sqr_n( mpi_ptr_t prodp, mpi_ptr_t up, mpi_size_t size, mpi_ptr_t tspace) { - if( size & 1 ) { + if ( size & 1 ) { /* The size is odd, and the code below doesn't handle that. * Multiply the least significant (size - 1) limbs with a recursive * call, and handle the most significant limb of S1 and S2 @@ -302,7 +302,7 @@ _gcry_mpih_sqr_n( mpi_ptr_t prodp, /* Product M. ________________ * |_(U1-U0)(U0-U1)_| */ - if( _gcry_mpih_cmp( up + hsize, up, hsize) >= 0 ) + if ( _gcry_mpih_cmp( up + hsize, up, hsize) >= 0 ) _gcry_mpih_sub_n( prodp, up + hsize, up, hsize); else _gcry_mpih_sub_n (prodp, up, up + hsize, hsize); @@ -329,13 +329,13 @@ _gcry_mpih_sqr_n( mpi_ptr_t prodp, /* Add/copy Product L (twice). */ cy += _gcry_mpih_add_n (prodp + hsize, prodp + hsize, tspace, size); - if( cy ) + if ( cy ) _gcry_mpih_add_1(prodp + hsize + size, prodp + hsize + size, hsize, cy); MPN_COPY(prodp, tspace, hsize); cy = _gcry_mpih_add_n (prodp + hsize, prodp + hsize, tspace + hsize, hsize); - if( cy ) + if ( cy ) _gcry_mpih_add_1 (prodp + size, prodp + size, size, 1); } } @@ -348,8 +348,8 @@ _gcry_mpih_mul_n( mpi_ptr_t prodp, { int secure; - if( up == vp ) { - if( size < KARATSUBA_THRESHOLD ) + if ( up == vp ) { + if ( size < KARATSUBA_THRESHOLD ) _gcry_mpih_sqr_n_basecase( prodp, up, size ); else { mpi_ptr_t tspace; @@ -360,7 +360,7 @@ _gcry_mpih_mul_n( mpi_ptr_t prodp, } } else { - if( size < KARATSUBA_THRESHOLD ) + if ( size < KARATSUBA_THRESHOLD ) mul_n_basecase( prodp, up, vp, size ); else { mpi_ptr_t tspace; @@ -382,8 +382,8 @@ _gcry_mpih_mul_karatsuba_case( mpi_ptr_t prodp, { mpi_limb_t cy; - if( !ctx->tspace || ctx->tspace_size < vsize ) { - if( ctx->tspace ) + if ( !ctx->tspace || ctx->tspace_size < vsize ) { + if ( ctx->tspace ) _gcry_mpi_free_limb_space( ctx->tspace, ctx->tspace_nlimbs ); ctx->tspace_nlimbs = 2 * vsize; ctx->tspace = mpi_alloc_limb_space( 2 * vsize, @@ -397,9 +397,9 @@ _gcry_mpih_mul_karatsuba_case( mpi_ptr_t prodp, prodp += vsize; up += vsize; usize -= vsize; - if( usize >= vsize ) { - if( !ctx->tp || ctx->tp_size < vsize ) { - if( ctx->tp ) + if ( usize >= vsize ) { + if ( !ctx->tp || ctx->tp_size < vsize ) { + if ( ctx->tp ) _gcry_mpi_free_limb_space( ctx->tp, ctx->tp_nlimbs ); ctx->tp_nlimbs = 2 * vsize; ctx->tp = mpi_alloc_limb_space( 2 * vsize, gcry_is_secure( up ) @@ -417,12 +417,12 @@ _gcry_mpih_mul_karatsuba_case( mpi_ptr_t prodp, } while( usize >= vsize ); } - if( usize ) { - if( usize < KARATSUBA_THRESHOLD ) { + if ( usize ) { + if ( usize < KARATSUBA_THRESHOLD ) { _gcry_mpih_mul( ctx->tspace, vp, vsize, up, usize ); } else { - if( !ctx->next ) { + if ( !ctx->next ) { ctx->next = gcry_xcalloc( 1, sizeof *ctx ); } _gcry_mpih_mul_karatsuba_case( ctx->tspace, @@ -442,15 +442,15 @@ _gcry_mpih_release_karatsuba_ctx( struct karatsuba_ctx *ctx ) { struct karatsuba_ctx *ctx2; - if( ctx->tp ) + if ( ctx->tp ) _gcry_mpi_free_limb_space( ctx->tp, ctx->tp_nlimbs ); - if( ctx->tspace ) + if ( ctx->tspace ) _gcry_mpi_free_limb_space( ctx->tspace, ctx->tspace_nlimbs ); - for( ctx=ctx->next; ctx; ctx = ctx2 ) { + for ( ctx=ctx->next; ctx; ctx = ctx2 ) { ctx2 = ctx->next; - if( ctx->tp ) + if ( ctx->tp ) _gcry_mpi_free_limb_space( ctx->tp, ctx->tp_nlimbs ); - if( ctx->tspace ) + if ( ctx->tspace ) _gcry_mpi_free_limb_space( ctx->tspace, ctx->tspace_nlimbs ); gcry_free( ctx ); } @@ -479,18 +479,18 @@ _gcry_mpih_mul( mpi_ptr_t prodp, mpi_ptr_t up, mpi_size_t usize, mpi_limb_t cy; struct karatsuba_ctx ctx; - if( vsize < KARATSUBA_THRESHOLD ) { + if ( vsize < KARATSUBA_THRESHOLD ) { mpi_size_t i; mpi_limb_t v_limb; - if( !vsize ) + if ( !vsize ) return 0; /* Multiply by the first limb in V separately, as the result can be * stored (not added) to PROD. We also avoid a loop for zeroing. */ v_limb = vp[0]; - if( v_limb <= 1 ) { - if( v_limb == 1 ) + if ( v_limb <= 1 ) { + if ( v_limb == 1 ) MPN_COPY( prodp, up, usize ); else MPN_ZERO( prodp, usize ); @@ -504,11 +504,11 @@ _gcry_mpih_mul( mpi_ptr_t prodp, mpi_ptr_t up, mpi_size_t usize, /* For each iteration in the outer loop, multiply one limb from * U with one limb from V, and add it to PROD. */ - for( i = 1; i < vsize; i++ ) { + for ( i = 1; i < vsize; i++ ) { v_limb = vp[i]; - if( v_limb <= 1 ) { + if ( v_limb <= 1 ) { cy = 0; - if( v_limb == 1 ) + if ( v_limb == 1 ) cy = _gcry_mpih_add_n(prodp, prodp, up, usize); } else diff --git a/plugins/MirOTR/libgcrypt-1.4.6/mpi/mpiutil.c b/plugins/MirOTR/libgcrypt-1.4.6/mpi/mpiutil.c index 4dc5211360..dcff1e8a0a 100644 --- a/plugins/MirOTR/libgcrypt-1.4.6/mpi/mpiutil.c +++ b/plugins/MirOTR/libgcrypt-1.4.6/mpi/mpiutil.c @@ -211,7 +211,7 @@ gcry_mpi_set_opaque( gcry_mpi_t a, void *p, unsigned int nbits ) if (!a) a = mpi_alloc(0); - if( a->flags & 4 ) + if ( a->flags & 4 ) gcry_free( a->d ); else _gcry_mpi_free_limb_space (a->d, a->alloced); @@ -228,9 +228,9 @@ gcry_mpi_set_opaque( gcry_mpi_t a, void *p, unsigned int nbits ) void * gcry_mpi_get_opaque( gcry_mpi_t a, unsigned int *nbits ) { - if( !(a->flags & 4) ) + if ( !(a->flags & 4) ) log_bug("mpi_get_opaque on normal mpi\n"); - if( nbits ) + if ( nbits ) *nbits = a->sign; return a->d; } @@ -246,13 +246,13 @@ gcry_mpi_copy( gcry_mpi_t a ) int i; gcry_mpi_t b; - if( a && (a->flags & 4) ) { + if ( a && (a->flags & 4) ) { void *p = gcry_is_secure(a->d)? gcry_xmalloc_secure( (a->sign+7)/8 ) : gcry_xmalloc( (a->sign+7)/8 ); memcpy( p, a->d, (a->sign+7)/8 ); b = gcry_mpi_set_opaque( NULL, p, a->sign ); } - else if( a ) { + else if ( a ) { b = mpi_is_secure(a)? mpi_alloc_secure( a->nlimbs ) : mpi_alloc( a->nlimbs ); b->nlimbs = a->nlimbs; @@ -277,14 +277,14 @@ _gcry_mpi_alloc_like( gcry_mpi_t a ) { gcry_mpi_t b; - if( a && (a->flags & 4) ) { + if ( a && (a->flags & 4) ) { int n = (a->sign+7)/8; void *p = gcry_is_secure(a->d)? gcry_malloc_secure( n ) : gcry_malloc( n ); memcpy( p, a->d, n ); b = gcry_mpi_set_opaque( NULL, p, a->sign ); } - else if( a ) { + else if ( a ) { b = mpi_is_secure(a)? mpi_alloc_secure( a->nlimbs ) : mpi_alloc( a->nlimbs ); b->nlimbs = 0; diff --git a/plugins/MirOTR/libgcrypt-1.4.6/random/random-csprng.c b/plugins/MirOTR/libgcrypt-1.4.6/random/random-csprng.c index 6ab868ae37..16fe9db998 100644 --- a/plugins/MirOTR/libgcrypt-1.4.6/random/random-csprng.c +++ b/plugins/MirOTR/libgcrypt-1.4.6/random/random-csprng.c @@ -747,7 +747,7 @@ read_seed_file (void) #else fd = open( seed_file_name, O_RDONLY ); #endif - if( fd == -1 && errno == ENOENT) + if ( fd == -1 && errno == ENOENT) { allow_seed_file_update = 1; return 0; @@ -972,7 +972,7 @@ read_pool (byte *buffer, size_t length, int level) needed = length - pool_balance; if (needed < POOLSIZE/2) needed = POOLSIZE/2; - else if( needed > POOLSIZE ) + else if ( needed > POOLSIZE ) BUG (); read_random_source (RANDOM_ORIGIN_EXTRAPOLL, needed, GCRY_VERY_STRONG_RANDOM); @@ -1183,14 +1183,14 @@ do_fast_random_poll (void) #elif HAVE_GETTIMEOFDAY { struct timeval tv; - if( gettimeofday( &tv, NULL ) ) + if ( gettimeofday( &tv, NULL ) ) BUG(); add_randomness( &tv.tv_sec, sizeof(tv.tv_sec), RANDOM_ORIGIN_FASTPOLL ); add_randomness( &tv.tv_usec, sizeof(tv.tv_usec), RANDOM_ORIGIN_FASTPOLL ); } #elif HAVE_CLOCK_GETTIME { struct timespec tv; - if( clock_gettime( CLOCK_REALTIME, &tv ) == -1 ) + if ( clock_gettime( CLOCK_REALTIME, &tv ) == -1 ) BUG(); add_randomness( &tv.tv_sec, sizeof(tv.tv_sec), RANDOM_ORIGIN_FASTPOLL ); add_randomness( &tv.tv_nsec, sizeof(tv.tv_nsec), RANDOM_ORIGIN_FASTPOLL ); diff --git a/plugins/MirOTR/libgcrypt-1.4.6/random/rndegd.c b/plugins/MirOTR/libgcrypt-1.4.6/random/rndegd.c index 63a5e0f162..ba82a52616 100644 --- a/plugins/MirOTR/libgcrypt-1.4.6/random/rndegd.c +++ b/plugins/MirOTR/libgcrypt-1.4.6/random/rndegd.c @@ -58,7 +58,7 @@ my_make_filename (const char *first_part, const char *second_part) n += strlen (second_part) + 1; home = NULL; - if( *first_part == '~' && first_part[1] == '/' + if ( *first_part == '~' && first_part[1] == '/' && (home = getenv("HOME")) && *home ) n += strlen(home); @@ -83,9 +83,9 @@ do_write( int fd, void *buf, size_t nbytes ) while( nleft > 0 ) { nwritten = write( fd, buf, nleft); - if( nwritten < 0 ) + if ( nwritten < 0 ) { - if( errno == EINTR ) + if ( errno == EINTR ) continue; return -1; } @@ -107,9 +107,9 @@ do_read( int fd, void *buf, size_t nbytes ) n = read(fd, (char*)buf + nread, nbytes ); } while( n == -1 && errno == EINTR ); - if( n == -1) + if ( n == -1) return nread? nread:-1; - if( n == 0) + if ( n == 0) return -1; nread += n; nbytes -= n; @@ -221,9 +221,9 @@ _gcry_rndegd_gather_random (void (*add)(const void*, size_t, int nbytes; int do_restart = 0; - if( !length ) + if ( !length ) return 0; - if( !level ) + if ( !level ) return 0; restart: @@ -236,20 +236,20 @@ _gcry_rndegd_gather_random (void (*add)(const void*, size_t, /* First time we do it with a non blocking request */ buffer[0] = 1; /* non blocking */ buffer[1] = nbytes; - if( do_write( fd, buffer, 2 ) == -1 ) + if ( do_write( fd, buffer, 2 ) == -1 ) log_fatal("can't write to the EGD: %s\n", strerror(errno) ); n = do_read( fd, buffer, 1 ); - if( n == -1 ) + if ( n == -1 ) { log_error("read error on EGD: %s\n", strerror(errno)); do_restart = 1; goto restart; } n = buffer[0]; - if( n ) + if ( n ) { n = do_read( fd, buffer, n ); - if( n == -1 ) + if ( n == -1 ) { log_error("read error on EGD: %s\n", strerror(errno)); do_restart = 1; @@ -259,7 +259,7 @@ _gcry_rndegd_gather_random (void (*add)(const void*, size_t, length -= n; } - if( length ) + if ( length ) { log_info ( _("Please wait, entropy is being gathered. Do some work if it would\n" @@ -272,10 +272,10 @@ _gcry_rndegd_gather_random (void (*add)(const void*, size_t, buffer[0] = 2; /* blocking */ buffer[1] = nbytes; - if( do_write( fd, buffer, 2 ) == -1 ) + if ( do_write( fd, buffer, 2 ) == -1 ) log_fatal("can't write to the EGD: %s\n", strerror(errno) ); n = do_read( fd, buffer, nbytes ); - if( n == -1 ) + if ( n == -1 ) { log_error("read error on EGD: %s\n", strerror(errno)); do_restart = 1; diff --git a/plugins/MirOTR/libgcrypt-1.4.6/random/rndlinux.c b/plugins/MirOTR/libgcrypt-1.4.6/random/rndlinux.c index 574ef6dcc0..aca72011ea 100644 --- a/plugins/MirOTR/libgcrypt-1.4.6/random/rndlinux.c +++ b/plugins/MirOTR/libgcrypt-1.4.6/random/rndlinux.c @@ -74,9 +74,9 @@ open_device ( const char *name ) struct stat sb; - if( fstat( fd, &sb ) ) + if ( fstat( fd, &sb ) ) log_fatal("stat() off %s failed: %s\n", name, strerror(errno) ); - if( (!S_ISCHR(sb.st_mode)) && (!S_ISFIFO(sb.st_mode)) ) + if ( (!S_ISCHR(sb.st_mode)) && (!S_ISFIFO(sb.st_mode)) ) log_fatal("invalid random device!\n" ); */ return fd; @@ -108,13 +108,13 @@ _gcry_rndlinux_gather_random (void (*add)(const void*, size_t, /* Open the requested device. */ if (level >= 2) { - if( fd_random == -1 ) + if ( fd_random == -1 ) fd_random = open_device ( NAME_OF_DEV_RANDOM ); fd = fd_random; } else { - if( fd_urandom == -1 ) + if ( fd_urandom == -1 ) fd_urandom = open_device ( NAME_OF_DEV_URANDOM ); fd = fd_urandom; } @@ -130,16 +130,16 @@ _gcry_rndlinux_gather_random (void (*add)(const void*, size_t, FD_SET(fd, &rfds); tv.tv_sec = 3; tv.tv_usec = 0; - if( !(rc=select(fd+1, &rfds, NULL, NULL, &tv)) ) + if ( !(rc=select(fd+1, &rfds, NULL, NULL, &tv)) ) { - if( !warn ) + if ( !warn ) { _gcry_random_progress ("need_entropy", 'X', 0, (int)length); warn = 1; } continue; } - else if( rc == -1 ) + else if ( rc == -1 ) { log_error ("select() error: %s\n", strerror(errno)); continue; @@ -149,14 +149,14 @@ _gcry_rndlinux_gather_random (void (*add)(const void*, size_t, { int nbytes = length < sizeof(buffer)? length : sizeof(buffer); n = read(fd, buffer, nbytes ); - if( n >= 0 && n > nbytes ) + if ( n >= 0 && n > nbytes ) { log_error("bogus read from random device (n=%d)\n", n ); n = nbytes; } } while( n == -1 && errno == EINTR ); - if( n == -1 ) + if ( n == -1 ) log_fatal("read error on random device: %s\n", strerror(errno)); (*add)( buffer, n, origin ); length -= n; diff --git a/plugins/MirOTR/libgcrypt-1.4.6/random/rndunix.c b/plugins/MirOTR/libgcrypt-1.4.6/random/rndunix.c index 1faf9abc0e..8f5d30a9ac 100644 --- a/plugins/MirOTR/libgcrypt-1.4.6/random/rndunix.c +++ b/plugins/MirOTR/libgcrypt-1.4.6/random/rndunix.c @@ -529,7 +529,7 @@ slow_poll(FILE *dbgfp, int dbgall, size_t *nbytes ) /* Since popen() is a fairly heavy function, we check to see whether * the executable exists before we try to run it */ if (access(dataSources[i].path, X_OK)) { - if( dbgfp && dbgall ) + if ( dbgfp && dbgall ) fprintf(dbgfp, "%s not present%s\n", dataSources[i].path, dataSources[i].hasAlternative ? ", has alternatives" : ""); @@ -555,7 +555,7 @@ slow_poll(FILE *dbgfp, int dbgall, size_t *nbytes ) /* If there are alternatives for this command, don't try and * execute them */ while (dataSources[i].hasAlternative) { - if( dbgfp && dbgall ) + if ( dbgfp && dbgall ) fprintf(dbgfp, "Skipping %s\n", dataSources[i + 1].path); i++; } @@ -584,7 +584,7 @@ slow_poll(FILE *dbgfp, int dbgall, size_t *nbytes ) /* One of the sources has data available, read it into the buffer */ for (i = 0; dataSources[i].path != NULL; i++) { - if( dataSources[i].pipe && FD_ISSET(dataSources[i].pipeFD, &fds)) { + if ( dataSources[i].pipe && FD_ISSET(dataSources[i].pipeFD, &fds)) { size_t noBytes; if ((noBytes = fread(gather_buffer + bufPos, 1, @@ -603,14 +603,14 @@ slow_poll(FILE *dbgfp, int dbgall, size_t *nbytes ) total = dataSources[i].length / dataSources[i].usefulness; } - if( dbgfp ) + if ( dbgfp ) fprintf(dbgfp, "%s %s contributed %d bytes, " "usefulness = %d\n", dataSources[i].path, (dataSources[i].arg != NULL) ? dataSources[i].arg : "", dataSources[i].length, total); - if( dataSources[i].length ) + if ( dataSources[i].length ) usefulness += total; } dataSources[i].pipe = NULL; @@ -661,7 +661,7 @@ slow_poll(FILE *dbgfp, int dbgall, size_t *nbytes ) } } - if( dbgfp ) { + if ( dbgfp ) { fprintf(dbgfp, "Got %d bytes, usefulness = %d\n", bufPos, usefulness); fflush(dbgfp); } @@ -681,9 +681,9 @@ start_gatherer( int pipefd ) { const char *s = getenv("GNUPG_RNDUNIX_DBG"); - if( s ) { + if ( s ) { dbgfp = (*s=='-' && !s[1])? stdout : fopen(s, "a"); - if( !dbgfp ) + if ( !dbgfp ) log_info("can't open debug file `%s': %s\n", s, strerror(errno) ); else @@ -694,7 +694,7 @@ start_gatherer( int pipefd ) /* close all files but the ones we need */ { int nmax, n1, n2, i; #ifdef _SC_OPEN_MAX - if( (nmax=sysconf( _SC_OPEN_MAX )) < 0 ) { + if ( (nmax=sysconf( _SC_OPEN_MAX )) < 0 ) { #ifdef _POSIX_OPEN_MAX nmax = _POSIX_OPEN_MAX; #else @@ -707,7 +707,7 @@ start_gatherer( int pipefd ) n1 = fileno( stderr ); n2 = dbgfp? fileno( dbgfp ) : -1; for(i=0; i < nmax; i++ ) { - if( i != n1 && i != n2 && i != pipefd ) + if ( i != n1 && i != n2 && i != pipefd ) close(i); } errno = 0; @@ -717,7 +717,7 @@ start_gatherer( int pipefd ) /* Set up the buffer. Not ethat we use a plain standard malloc here. */ gather_buffer_size = GATHER_BUFSIZE; gather_buffer = malloc( gather_buffer_size ); - if( !gather_buffer ) { + if ( !gather_buffer ) { log_error("out of core while allocating the gatherer buffer\n"); exit(2); } @@ -738,7 +738,7 @@ start_gatherer( int pipefd ) fclose(stderr); /* Arrghh!! It's Stuart code!! */ - for(;;) { + for (;;) { GATHER_MSG msg; size_t nbytes; const char *p; @@ -752,20 +752,20 @@ start_gatherer( int pipefd ) p += msg.ndata; while( write( pipefd, &msg, sizeof(msg) ) != sizeof(msg) ) { - if( errno == EINTR ) + if ( errno == EINTR ) continue; - if( errno == EAGAIN ) { + if ( errno == EAGAIN ) { struct timeval tv; tv.tv_sec = 0; tv.tv_usec = 50000; select(0, NULL, NULL, NULL, &tv); continue; } - if( errno == EPIPE ) /* parent has exited, so give up */ + if ( errno == EPIPE ) /* parent has exited, so give up */ exit(0); /* we can't do very much here because stderr is closed */ - if( dbgfp ) + if ( dbgfp ) fprintf(dbgfp, "gatherer can't write to pipe: %s\n", strerror(errno) ); /* we start a new poll to give the system some time */ @@ -789,7 +789,7 @@ read_a_msg( int fd, GATHER_MSG *msg ) do { n = read(fd, buffer, length ); } while( n == -1 && errno == EINTR ); - if( n == -1 ) + if ( n == -1 ) return -1; buffer += n; length -= n; @@ -813,24 +813,24 @@ _gcry_rndunix_gather_random (void (*add)(const void*, size_t, GATHER_MSG msg; size_t n; - if( !level ) + if ( !level ) return 0; - if( !gatherer_pid ) { + if ( !gatherer_pid ) { /* Make sure we are not setuid. */ if ( getuid() != geteuid() ) BUG(); /* time to start the gatherer process */ - if( pipe( pipedes ) ) { + if ( pipe( pipedes ) ) { log_error("pipe() failed: %s\n", strerror(errno)); return -1; } gatherer_pid = fork(); - if( gatherer_pid == -1 ) { + if ( gatherer_pid == -1 ) { log_error("can't for gatherer process: %s\n", strerror(errno)); return -1; } - if( !gatherer_pid ) { + if ( !gatherer_pid ) { start_gatherer( pipedes[1] ); /* oops, can't happen */ return -1; @@ -842,23 +842,23 @@ _gcry_rndunix_gather_random (void (*add)(const void*, size_t, int goodness; ulong subtract; - if( read_a_msg( pipedes[0], &msg ) ) { + if ( read_a_msg( pipedes[0], &msg ) ) { log_error("reading from gatherer pipe failed: %s\n", strerror(errno)); return -1; } - if( level > 1 ) { - if( msg.usefulness > 30 ) + if ( level > 1 ) { + if ( msg.usefulness > 30 ) goodness = 100; else if ( msg.usefulness ) goodness = msg.usefulness * 100 / 30; else goodness = 0; } - else if( level ) { - if( msg.usefulness > 15 ) + else if ( level ) { + if ( msg.usefulness > 15 ) goodness = 100; else if ( msg.usefulness ) goodness = msg.usefulness * 100 / 15; @@ -869,7 +869,7 @@ _gcry_rndunix_gather_random (void (*add)(const void*, size_t, goodness = 100; /* goodness of level 0 is always 100 % */ n = msg.ndata; - if( n > length ) + if ( n > length ) n = length; (*add)( msg.data, n, origin ); diff --git a/plugins/MirOTR/libgcrypt-1.4.6/src/gcrypt.h b/plugins/MirOTR/libgcrypt-1.4.6/src/gcrypt.h index 08112a7610..9e624d3572 100644 --- a/plugins/MirOTR/libgcrypt-1.4.6/src/gcrypt.h +++ b/plugins/MirOTR/libgcrypt-1.4.6/src/gcrypt.h @@ -1199,7 +1199,7 @@ void gcry_md_debug (gcry_md_hd_t hd, const char *suffix); #define gcry_md_putc(h,c) \ do { \ gcry_md_hd_t h__ = (h); \ - if( (h__)->bufpos == (h__)->bufsize ) \ + if ( (h__)->bufpos == (h__)->bufsize ) \ gcry_md_write( (h__), NULL, 0 ); \ (h__)->buf[(h__)->bufpos++] = (c) & 0xff; \ } while(0) diff --git a/plugins/MirOTR/libgcrypt-1.4.6/src/gcryptrnd.c b/plugins/MirOTR/libgcrypt-1.4.6/src/gcryptrnd.c index e15fecaf35..8aa3568837 100644 --- a/plugins/MirOTR/libgcrypt-1.4.6/src/gcryptrnd.c +++ b/plugins/MirOTR/libgcrypt-1.4.6/src/gcryptrnd.c @@ -202,7 +202,7 @@ disable_core_dumps (void) if (getrlimit (RLIMIT_CORE, &limit)) limit.rlim_max = 0; limit.rlim_cur = 0; - if( !setrlimit (RLIMIT_CORE, &limit) ) + if ( !setrlimit (RLIMIT_CORE, &limit) ) return 0; if (errno != EINVAL && errno != ENOSYS) logit (LOG_ERR, "can't disable core dumps: %s\n", strerror (errno)); diff --git a/plugins/MirOTR/libgcrypt-1.4.6/src/global.c b/plugins/MirOTR/libgcrypt-1.4.6/src/global.c index a69513e7d5..7c73f14a99 100644 --- a/plugins/MirOTR/libgcrypt-1.4.6/src/global.c +++ b/plugins/MirOTR/libgcrypt-1.4.6/src/global.c @@ -167,7 +167,7 @@ parse_version_number( const char *s, int *number ) { int val = 0; - if( *s == '0' && isdigit(s[1]) ) + if ( *s == '0' && isdigit(s[1]) ) return NULL; /* leading zeros are not allowed */ for ( ; isdigit(*s); s++ ) { val *= 10; @@ -190,15 +190,15 @@ static const char * parse_version_string( const char *s, int *major, int *minor, int *micro ) { s = parse_version_number( s, major ); - if( !s || *s != '.' ) + if ( !s || *s != '.' ) return NULL; s++; s = parse_version_number( s, minor ); - if( !s || *s != '.' ) + if ( !s || *s != '.' ) return NULL; s++; s = parse_version_number( s, micro ); - if( !s ) + if ( !s ) return NULL; return s; /* patchlevel */ } @@ -788,7 +788,7 @@ _gcry_check_heap( const void *a ) /* FIXME: implement this*/ #if 0 - if( some_handler ) + if ( some_handler ) some_handler(a) else _gcry_private_check_heap(a) diff --git a/plugins/MirOTR/libgcrypt-1.4.6/src/misc.c b/plugins/MirOTR/libgcrypt-1.4.6/src/misc.c index fcad8d4e3b..0146c61273 100644 --- a/plugins/MirOTR/libgcrypt-1.4.6/src/misc.c +++ b/plugins/MirOTR/libgcrypt-1.4.6/src/misc.c @@ -48,7 +48,7 @@ gcry_set_gettext_handler( const char *(*f)(const char*) ) const char * _gcry_gettext( const char *key ) { - if( user_gettext_handler ) + if ( user_gettext_handler ) return user_gettext_handler( key ); /* FIXME: switch the domain to gnupg and restore later */ return key; diff --git a/plugins/MirOTR/libgcrypt-1.4.6/src/missing-string.c b/plugins/MirOTR/libgcrypt-1.4.6/src/missing-string.c index a5e56c3f76..c5f4c83f70 100644 --- a/plugins/MirOTR/libgcrypt-1.4.6/src/missing-string.c +++ b/plugins/MirOTR/libgcrypt-1.4.6/src/missing-string.c @@ -45,8 +45,8 @@ stpcpy(char *a,const char *b) int strcasecmp( const char *a, const char *b ) { - for( ; *a && *b; a++, b++ ) { - if( *a != *b && toupper(*a) != toupper(*b) ) + for ( ; *a && *b; a++, b++ ) { + if ( *a != *b && toupper(*a) != toupper(*b) ) break; } return *(const byte*)a - *(const byte*)b; diff --git a/plugins/MirOTR/libgcrypt-1.4.6/src/sexp.c b/plugins/MirOTR/libgcrypt-1.4.6/src/sexp.c index e11f86ec0a..865e7d7a88 100644 --- a/plugins/MirOTR/libgcrypt-1.4.6/src/sexp.c +++ b/plugins/MirOTR/libgcrypt-1.4.6/src/sexp.c @@ -84,9 +84,9 @@ dump_mpi( gcry_mpi_t a ) char buffer[1000];
size_t n = 1000;
- if( !a )
+ if ( !a )
fputs("[no MPI]", stderr );
- else if( gcry_mpi_print( GCRYMPI_FMT_HEX, buffer, &n, a ) )
+ else if ( gcry_mpi_print( GCRYMPI_FMT_HEX, buffer, &n, a ) )
fputs("[MPI too large to print]", stderr );
else
fputs( buffer, stderr );
@@ -100,17 +100,17 @@ dump_string (const byte *p, size_t n, int delim ) {
if ((*p & 0x80) || iscntrl( *p ) || *p == delim )
{
- if( *p == '\n' )
+ if ( *p == '\n' )
log_printf ("\\n");
- else if( *p == '\r' )
+ else if ( *p == '\r' )
log_printf ("\\r");
- else if( *p == '\f' )
+ else if ( *p == '\f' )
log_printf ("\\f");
- else if( *p == '\v' )
+ else if ( *p == '\v' )
log_printf ("\\v");
- else if( *p == '\b' )
+ else if ( *p == '\b' )
log_printf ("\\b");
- else if( !*p )
+ else if ( !*p )
log_printf ("\\0");
else
log_printf ("\\x%02x", *p );
@@ -145,7 +145,7 @@ gcry_sexp_dump (const gcry_sexp_t a) indent++;
break;
case ST_CLOSE:
- if( indent )
+ if ( indent )
indent--;
log_printf ("%*s[close]\n", 2*indent, "");
break;
@@ -831,19 +831,19 @@ hextobyte( const byte *s ) {
int c=0;
- if( *s >= '0' && *s <= '9' )
+ if ( *s >= '0' && *s <= '9' )
c = 16 * (*s - '0');
- else if( *s >= 'A' && *s <= 'F' )
+ else if ( *s >= 'A' && *s <= 'F' )
c = 16 * (10 + *s - 'A');
- else if( *s >= 'a' && *s <= 'f' ) {
+ else if ( *s >= 'a' && *s <= 'f' ) {
c = 16 * (10 + *s - 'a');
}
s++;
- if( *s >= '0' && *s <= '9' )
+ if ( *s >= '0' && *s <= '9' )
c += *s - '0';
- else if( *s >= 'A' && *s <= 'F' )
+ else if ( *s >= 'A' && *s <= 'F' )
c += 10 + *s - 'A';
- else if( *s >= 'a' && *s <= 'f' ) {
+ else if ( *s >= 'a' && *s <= 'f' ) {
c += 10 + *s - 'a';
}
return c;
@@ -942,7 +942,7 @@ unquote_string (const char *string, size_t length, unsigned char *buf) }
esc = 0;
}
- else if( *s == '\\' )
+ else if ( *s == '\\' )
esc = 1;
else
*d++ = *s;
diff --git a/plugins/MirOTR/libgcrypt-1.4.6/src/stdmem.c b/plugins/MirOTR/libgcrypt-1.4.6/src/stdmem.c index bb8adeabec..14a7691563 100644 --- a/plugins/MirOTR/libgcrypt-1.4.6/src/stdmem.c +++ b/plugins/MirOTR/libgcrypt-1.4.6/src/stdmem.c @@ -160,7 +160,7 @@ _gcry_private_realloc ( void *a, size_t n ) len = p[-4]; len |= p[-3] << 8; len |= p[-2] << 16; - if( len >= n ) /* We don't shrink for now. */ + if ( len >= n ) /* We don't shrink for now. */ return a; if (p[-1] == MAGIC_SEC_BYTE) b = _gcry_private_malloc_secure(n); diff --git a/plugins/MirOTR/libgpg-error-1.9/src/w32-gettext.c b/plugins/MirOTR/libgpg-error-1.9/src/w32-gettext.c index da07a25695..f1c74fedc9 100644 --- a/plugins/MirOTR/libgpg-error-1.9/src/w32-gettext.c +++ b/plugins/MirOTR/libgpg-error-1.9/src/w32-gettext.c @@ -1467,7 +1467,7 @@ _gpg_w32_bindtextdomain (const char *domainname, const char *dirname) } strcpy (item->name, domainname); item->dname = jnlib_malloc (strlen (dirname) +1); - if(!item->dname) + if (!item->dname) { jnlib_free (item); jnlib_free (fname); diff --git a/plugins/MirOTR/libotr-3.2.0/src/proto.c b/plugins/MirOTR/libotr-3.2.0/src/proto.c index 9f76455a9f..75782d6a63 100644 --- a/plugins/MirOTR/libotr-3.2.0/src/proto.c +++ b/plugins/MirOTR/libotr-3.2.0/src/proto.c @@ -259,7 +259,7 @@ unsigned int otrl_proto_query_bestversion(const char *querymsg, ++otrtag; } if (*otrtag == 'v') { - for(++otrtag; *otrtag && *otrtag != '?'; ++otrtag) { + for (++otrtag; *otrtag && *otrtag != '?'; ++otrtag) { switch(*otrtag) { case '2': query_versions |= (1<<1); @@ -840,7 +840,7 @@ gcry_error_t otrl_proto_fragment_create(int mms, int fragment_count, int headerlen = 19; /* Should vary by number of msgs */ char **fragmentarray = malloc(fragment_count * sizeof(char*)); - if(!fragmentarray) return gcry_error(GPG_ERR_ENOMEM); + if (!fragmentarray) return gcry_error(GPG_ERR_ENOMEM); /* * Find the next message fragment and store it in the array. @@ -855,7 +855,7 @@ gcry_error_t otrl_proto_fragment_create(int mms, int fragment_count, fragdatalen = mms - headerlen; } fragdata = malloc(fragdatalen + 1); - if(!fragdata) { + if (!fragdata) { for (i=0; i<curfrag-1; free(fragmentarray[i++])) {} free(fragmentarray); return gcry_error(GPG_ERR_ENOMEM); @@ -864,7 +864,7 @@ gcry_error_t otrl_proto_fragment_create(int mms, int fragment_count, fragdata[fragdatalen] = 0; fragmentmsg = malloc(fragdatalen+headerlen+1); - if(!fragmentmsg) { + if (!fragmentmsg) { for (i=0; i<curfrag-1; free(fragmentarray[i++])) {} free(fragmentarray); free(fragdata); diff --git a/plugins/MirOTR/libotr-3.2.0/toolkit/aes.c b/plugins/MirOTR/libotr-3.2.0/toolkit/aes.c index 24b9b56084..44bb67597f 100644 --- a/plugins/MirOTR/libotr-3.2.0/toolkit/aes.c +++ b/plugins/MirOTR/libotr-3.2.0/toolkit/aes.c @@ -74,7 +74,7 @@ void aes_gen_tables( void ) /* compute pow and log tables over GF(2^8) */ - for( i = 0, x = 1; i < 256; i++, x ^= XTIME( x ) ) + for ( i = 0, x = 1; i < 256; i++, x ^= XTIME( x ) ) { pow[i] = x; log[x] = i; @@ -82,7 +82,7 @@ void aes_gen_tables( void ) /* calculate the round constants */ - for( i = 0, x = 1; i < 10; i++, x = XTIME( x ) ) + for ( i = 0, x = 1; i < 10; i++, x = XTIME( x ) ) { RCON[i] = (uint32) x << 24; } @@ -92,7 +92,7 @@ void aes_gen_tables( void ) FSb[0x00] = 0x63; RSb[0x63] = 0x00; - for( i = 1; i < 256; i++ ) + for ( i = 1; i < 256; i++ ) { x = pow[255 - log[i]]; @@ -108,7 +108,7 @@ void aes_gen_tables( void ) /* generate the forward and reverse tables */ - for( i = 0; i < 256; i++ ) + for ( i = 0; i < 256; i++ ) { x = (unsigned char) FSb[i]; y = XTIME( x ); @@ -441,7 +441,7 @@ int aes_set_key( aes_context *ctx, uint8 *key, int nbits ) int i; uint32 *RK, *SK; - if( do_init ) + if ( do_init ) { aes_gen_tables(); @@ -458,7 +458,7 @@ int aes_set_key( aes_context *ctx, uint8 *key, int nbits ) RK = ctx->erk; - for( i = 0; i < (nbits >> 5); i++ ) + for ( i = 0; i < (nbits >> 5); i++ ) { GET_UINT32( RK[i], key, i * 4 ); } @@ -469,7 +469,7 @@ int aes_set_key( aes_context *ctx, uint8 *key, int nbits ) { case 128: - for( i = 0; i < 10; i++, RK += 4 ) + for ( i = 0; i < 10; i++, RK += 4 ) { RK[4] = RK[0] ^ RCON[i] ^ ( FSb[ (uint8) ( RK[3] >> 16 ) ] << 24 ) ^ @@ -485,7 +485,7 @@ int aes_set_key( aes_context *ctx, uint8 *key, int nbits ) case 192: - for( i = 0; i < 8; i++, RK += 6 ) + for ( i = 0; i < 8; i++, RK += 6 ) { RK[6] = RK[0] ^ RCON[i] ^ ( FSb[ (uint8) ( RK[5] >> 16 ) ] << 24 ) ^ @@ -503,7 +503,7 @@ int aes_set_key( aes_context *ctx, uint8 *key, int nbits ) case 256: - for( i = 0; i < 7; i++, RK += 8 ) + for ( i = 0; i < 7; i++, RK += 8 ) { RK[8] = RK[0] ^ RCON[i] ^ ( FSb[ (uint8) ( RK[7] >> 16 ) ] << 24 ) ^ @@ -530,9 +530,9 @@ int aes_set_key( aes_context *ctx, uint8 *key, int nbits ) /* setup decryption round keys */ - if( KT_init ) + if ( KT_init ) { - for( i = 0; i < 256; i++ ) + for ( i = 0; i < 256; i++ ) { KT0[i] = RT0[ FSb[i] ]; KT1[i] = RT1[ FSb[i] ]; @@ -550,7 +550,7 @@ int aes_set_key( aes_context *ctx, uint8 *key, int nbits ) *SK++ = *RK++; *SK++ = *RK++; - for( i = 1; i < ctx->nr; i++ ) + for ( i = 1; i < ctx->nr; i++ ) { RK -= 8; @@ -633,13 +633,13 @@ void aes_encrypt( aes_context *ctx, uint8 input[16], uint8 output[16] ) AES_FROUND( X0, X1, X2, X3, Y0, Y1, Y2, Y3 ); /* round 8 */ AES_FROUND( Y0, Y1, Y2, Y3, X0, X1, X2, X3 ); /* round 9 */ - if( ctx->nr > 10 ) + if ( ctx->nr > 10 ) { AES_FROUND( X0, X1, X2, X3, Y0, Y1, Y2, Y3 ); /* round 10 */ AES_FROUND( Y0, Y1, Y2, Y3, X0, X1, X2, X3 ); /* round 11 */ } - if( ctx->nr > 12 ) + if ( ctx->nr > 12 ) { AES_FROUND( X0, X1, X2, X3, Y0, Y1, Y2, Y3 ); /* round 12 */ AES_FROUND( Y0, Y1, Y2, Y3, X0, X1, X2, X3 ); /* round 13 */ @@ -723,13 +723,13 @@ void aes_decrypt( aes_context *ctx, uint8 input[16], uint8 output[16] ) AES_RROUND( X0, X1, X2, X3, Y0, Y1, Y2, Y3 ); /* round 8 */ AES_RROUND( Y0, Y1, Y2, Y3, X0, X1, X2, X3 ); /* round 9 */ - if( ctx->nr > 10 ) + if ( ctx->nr > 10 ) { AES_RROUND( X0, X1, X2, X3, Y0, Y1, Y2, Y3 ); /* round 10 */ AES_RROUND( Y0, Y1, Y2, Y3, X0, X1, X2, X3 ); /* round 11 */ } - if( ctx->nr > 12 ) + if ( ctx->nr > 12 ) { AES_RROUND( X0, X1, X2, X3, Y0, Y1, Y2, Y3 ); /* round 12 */ AES_RROUND( Y0, Y1, Y2, Y3, X0, X1, X2, X3 ); /* round 13 */ @@ -802,14 +802,14 @@ int main( void ) unsigned char buf[16]; unsigned char key[32]; - for( m = 0; m < 2; m++ ) + for ( m = 0; m < 2; m++ ) { printf( "\n Rijndael Monte Carlo Test (ECB mode) - " ); - if( m == 0 ) printf( "encryption\n\n" ); - if( m == 1 ) printf( "decryption\n\n" ); + if ( m == 0 ) printf( "encryption\n\n" ); + if ( m == 1 ) printf( "decryption\n\n" ); - for( n = 0; n < 3; n++ ) + for ( n = 0; n < 3; n++ ) { printf( " Test %d, key size = %3d bits: ", n + 1, 128 + n * 64 ); @@ -819,34 +819,34 @@ int main( void ) memset( buf, 0, 16 ); memset( key, 0, 16 + n * 8 ); - for( i = 0; i < 400; i++ ) + for ( i = 0; i < 400; i++ ) { aes_set_key( &ctx, key, 128 + n * 64 ); - for( j = 0; j < 9999; j++ ) + for ( j = 0; j < 9999; j++ ) { - if( m == 0 ) aes_encrypt( &ctx, buf, buf ); - if( m == 1 ) aes_decrypt( &ctx, buf, buf ); + if ( m == 0 ) aes_encrypt( &ctx, buf, buf ); + if ( m == 1 ) aes_decrypt( &ctx, buf, buf ); } - if( n > 0 ) + if ( n > 0 ) { - for( j = 0; j < (n << 3); j++ ) + for ( j = 0; j < (n << 3); j++ ) { key[j] ^= buf[j + 16 - (n << 3)]; } } - if( m == 0 ) aes_encrypt( &ctx, buf, buf ); - if( m == 1 ) aes_decrypt( &ctx, buf, buf ); + if ( m == 0 ) aes_encrypt( &ctx, buf, buf ); + if ( m == 1 ) aes_decrypt( &ctx, buf, buf ); - for( j = 0; j < 16; j++ ) + for ( j = 0; j < 16; j++ ) { key[j + (n << 3)] ^= buf[j]; } } - if( ( m == 0 && memcmp( buf, AES_enc_test[n], 16 ) != 0 ) || + if ( ( m == 0 && memcmp( buf, AES_enc_test[n], 16 ) != 0 ) || ( m == 1 && memcmp( buf, AES_dec_test[n], 16 ) != 0 ) ) { printf( "failed!\n" ); |