char *RoleGr(FILE *consc,char *compound_name, char *role, char *attributes, char *ex_context) /* Document a compound Split a comma separated list, with head we can use it for context or for conceptual RoleGr(fp, "compound name", "hasrole unique identifier", "hasttr part1,hasttr part2", "naming unique identity") */ { char *sp, word[255]; Gr(consc,compound_name,a_hasrole,role,ex_context); if ((sp = attributes)) { while (*sp != '\0') { if (*sp == ',') { sp++; continue; } word[0] = '\0'; sscanf(sp,"%250[^,]",word); sp += strlen(word); Gr(consc,compound_name,a_hasattr,word,ALL_CONTEXTS); } } return compound_name; }
char *EventClue(FILE *fp,char *who,char *what, time_t whentime, char *where, char *how, char *why,char *icontext) { static char event[CGN_BUFSIZE]; char attr[CGN_BUFSIZE]; char *when; // Normal regular events do not depend on time, and should not record an irrelevant timestamp // Anomalies do depend on time and timestamp may be significant if (whentime > 0) { when = TimeGr(fp,whentime); } else { when = "repeated event"; } snprintf(event,CGN_BUFSIZE,"%s saw %s %s location %s %s cause %s",who,what,when,where,how,why); snprintf(attr,CGN_BUFSIZE,"%s,%s,%s,%s,%s",who,what,when,how,why); RoleGr(fp,event,"event",attr,icontext); RoleGr(fp,who,"who","",icontext); RoleGr(fp,what,"what","",icontext); RoleGr(fp,how,"how","",icontext); RoleGr(fp,why,"why","",icontext); Gr(fp,what,a_related_to,why,icontext); return event; }
char *AcceptPromiseGr(FILE *fp,char *R, char *S, char *body) { char sender[CGN_BUFSIZE], receiver[CGN_BUFSIZE],attr[CGN_BUFSIZE]; static char promisehub[CGN_BUFSIZE]; snprintf(receiver,CGN_BUFSIZE,"promiser %s",R); snprintf(sender,CGN_BUFSIZE,"promisee %s",S); snprintf(promisehub,CGN_BUFSIZE,"%s promises to accept %s to %s",receiver,body,sender); snprintf(attr,CGN_BUFSIZE,"%s,promise body -%s,%s",sender,body,receiver); RoleGr(fp,promisehub,"use-accept promise",attr,"promise keeping"); Gr(fp,receiver,a_depends,promisehub,"promise keeping"); Gr(fp,"use-accept promise",a_related_to,"client pull methods","promise keeping"); return promisehub; }
char *GivePromiseGr(FILE *fp,char *S, char *R, char *body) { char sender[CGN_BUFSIZE], receiver[CGN_BUFSIZE],attr[CGN_BUFSIZE]; static char promisehub[CGN_BUFSIZE]; snprintf(sender,CGN_BUFSIZE,"promiser %s",S); snprintf(receiver,CGN_BUFSIZE,"promisee %s",R); snprintf(promisehub,CGN_BUFSIZE,"%s promises to give %s to %s",sender,body,receiver); snprintf(attr,CGN_BUFSIZE,"%s,promise body +%s,%s",sender,body,receiver); RoleGr(fp,promisehub,"give-provide promise",attr,"promise keeping"); Gr(fp,sender,a_depends,promisehub,"promise keeping"); Gr(fp,promisehub,a_depends,sender,"promise keeping"); return promisehub; }
char *ContextGr(FILE *consc,char *compound_name) /* Document a compound Split a space separated list, with head we can use it for context or for conceptual - treat them as epitopes for fuzzy matching by set overlap. Only type 4 associations. */ { char *sp, word[255]; if ((sp = compound_name)) { while (*sp != '\0') { if (*sp == ' ') { sp++; continue; } word[0] = '\0'; sscanf(sp,"%250s",word); sp += strlen(word); Gr(consc,compound_name,a_contains,word,ALL_CONTEXTS); } } return compound_name; }
char *ClientInstanceGr(FILE *fp,char *servicename,char *clientname,char *where) { static char hub[CGN_BUFSIZE]; snprintf(hub,CGN_BUFSIZE,"%s %s",SClientInstance(servicename,clientname),where); RoleGr(fp,hub,SClientInstance(servicename,clientname),where,"service relationship instance"); Gr(fp,hub,a_uses,SService(servicename),"service relationship"); return hub; }
char *ServerInstanceGr(FILE *fp,char *servicename, unsigned int portnumber,char *servername,char *where) { static char hub[CGN_BUFSIZE]; ServiceGr(fp,servicename,portnumber); snprintf(hub,CGN_BUFSIZE,"%s %s",SServerInstance(servicename,servername),where); RoleGr(fp,hub,SServerInstance(servicename,servername),where,"service relationship instance"); Gr(fp,SService(servicename),a_providedby,hub,"service relationship"); return hub; }
char *ExceptionGr(FILE *fp,char *origin,char *logmessage) // 2016-08-13T15:00:01.906160+02:00 linux-e2vo /usr/sbin/cron[23039]: pam_unix(crond:session): session opened for user root by (uid=0) // When where who what (new who) // Why = (lifecycle state change, exception, ...) { Gr(fp,origin,a_related_to,logmessage,"???? TBD"); return NULL; }
char *ImpositionGr(FILE *fp,char *S, char *R, char *body) { char sender[CGN_BUFSIZE], receiver[CGN_BUFSIZE],attr[CGN_BUFSIZE]; char *acceptance; static char promisehub[CGN_BUFSIZE]; snprintf(sender,CGN_BUFSIZE,"imposer %s",S); snprintf(receiver,CGN_BUFSIZE,"imposee %s",R); snprintf(promisehub,CGN_BUFSIZE,"%s imposes body %s onto %s",sender,body,receiver); snprintf(attr,CGN_BUFSIZE,"%s,imposition body %s,%s",sender,body,receiver); RoleGr(fp,promisehub,"imposition",attr,"promise keeping"); Gr(fp,"imposition",a_related_to,"client push methods","promise keeping"); // Imposition only affects if there is an accept promise if ((acceptance = AcceptPromiseGr(fp,R,S,body))) { Gr(fp,promisehub,a_depends,acceptance,"promise keeping"); Gr(fp,promisehub,a_depends,sender,"promise keeping"); } return promisehub; }
void localizerGVG::propagate(double Vm, double Wm, double dt) { Matrix3d Fr; Fr<<1, 0, -Vm*dt*sin(oldYaw), 0, 1, Vm*dt*cos(oldYaw), 0, 0, 1; MatrixXd Gr(3,2); Gr<< -dt*cos(oldYaw), 0, -dt*sin(oldYaw), 0, 0, -dt; P.block(0,0,3,3)=Fr*P.block(0,0,3,3)*Fr.transpose()+Gr*Qr*Gr.transpose(); CF=Fr*CF; normalizeCovariance(); }
// Fonction de déchiffrement void Gr_1(u16 *state, const u16 *wk, const u16 *rk) { u16 wk_1[4]; u16 rk_1[2*NBROUND]; u16 i; wk_1[0] = wk[2]; wk_1[1] = wk[3]; wk_1[2] = wk[0]; wk_1[3] = wk[1]; for(i=0; i<NBROUND; i++) { rk_1[2*i] = rk[2*NBROUND - 2*i - 2 + (i%2)]; rk_1[2*i+1] = rk[2*NBROUND - 2*i -1 - (i%2)]; } Gr(state,wk_1,rk_1); return; }
int main(int argc, char* argv[]) { // ************ Déclarations ************ u16 text[4]={0xcdef,0x89ab,0x4567,0x0123}; u16 k128[8] = {0x0011, 0x2233, 0x4455, 0x6677, 0x8899, 0xaabb, 0xccdd, 0xeeff}; u16 wk[4]; u16 rk[2*NBROUND]; START_ENCRYPT(); // **************************************** // Test clé 128 bits // **************************************** wKS_128(k128,wk); rKS_128(k128,rk); // ************ Vérification chiffrement ************ Gr(text, wk, rk); #ifdef PRINT uart1_init(); printf("Verification avec la cle de 128 bits \n\nLe chiffrement donne : \n"); printf("5ec42cea 657b89ff\n"); ps(text); #endif // ************ Controle du déchiffrement ************ START_DECRYPT(); wKS_128(k128,wk); rKS_128(k128,rk); Gr_1(text, wk, rk); #ifdef PRINT printf("Controle du dechiffrement : \n\n"); ps(text); #endif END_EXPE(); return 0; }
int main(int argc, char* argv[]) { // ************ Déclarations ************ u16 text[4]={0xcdef,0x89ab,0x4567,0x0123}; u16 k80[5] = {0x0011, 0x2233, 0x4455, 0x6677, 0x8899}; u16 wk[4]; u16 rk[2*NBROUND]; // **************************************** // Test clé 80 bits // **************************************** START_ENCRYPT(); wKS_80(k80,wk); rKS_80(k80,rk); // ************ Vérification chiffrement ************ Gr(text, wk, rk); #ifdef PRINT printf("Verification avec la cle de 80 bits \n\nLe chiffrement donne : \n"); printf("8d2b ff99 35f8 4056\n"); ps(text); #endif // ************ Controle du déchiffrement ************ START_DECRYPT(); wKS_80(k80,wk); rKS_80(k80,rk); Gr_1(text, wk, rk); #ifdef PRINT printf("Controle du dechiffrement : \n\n"); ps(text); #endif END_EXPE(); return 0; }
char *ServiceGr(FILE *fp,char *servicename, unsigned int portnumber) { static char name[CGN_BUFSIZE]; char port[CGN_BUFSIZE]; snprintf(name,CGN_BUFSIZE,"%s on port %d",SService(servicename), portnumber); // service ftp RoleGr(fp,name,SService(servicename),IPPort(portnumber),"service relationship"); Gr(fp,SService(servicename),a_hasrole,"service","service relationship"); Gr(fp,SService(servicename),a_hasfunction,servicename,"service relationship"); snprintf(port,CGN_BUFSIZE,"%d",portnumber); RoleGr(fp,IPPort(portnumber),"ip portnumber",port,"service relationship"); // ancillary notes Gr(fp,SServer(servicename),a_hasrole,"server","service relationship"); Gr(fp,SClient(servicename),a_hasrole,"client","service relationship"); Gr(fp,SClient(servicename),a_depends,SServer(servicename),"service relationship"); // service => client depends on server Gr(fp,SClient(servicename),a_uses,name,"service relationship"); return name; }
char *WhereGr(FILE *fp,char *address, char *uqhn, char *domain, char *ipv4, char *ipv6) { // This model of "where?" is based on IP addresses and portnumbers, for cloud services // alternative models for "other worlds" can be added... static char where[CGN_BUFSIZE] = {0}; char attr[CGN_BUFSIZE]; if (domain == NULL || strlen(domain) == 0) { domain = "unknown domain"; } if (ipv6 && strlen(ipv6) > 0) { snprintf(where,CGN_BUFSIZE,"host location %s.%s IPv4 %s ipv6 %s",uqhn,domain,ipv4,ipv6); } else { snprintf(where,CGN_BUFSIZE,"host location %s.%s IPv4 %s",uqhn,domain,ipv4); } if (address && strlen(address) > 0) { snprintf(attr,CGN_BUFSIZE,"%s,%s,%s,%s,address %s",Hostname(uqhn),Domain(domain),IPv4(ipv4),IPv6(ipv6),address); } else { snprintf(attr,CGN_BUFSIZE,"%s,%s,%s,%s",Hostname(uqhn),Domain(domain),IPv4(ipv4),IPv6(ipv6)); } RoleGr(fp,where,"where",attr, "host location identification"); RoleGr(fp,Domain(domain),"dns domain name",domain,"host location identification"); char *hostname = Hostname(uqhn); RoleGr(fp,hostname,"hostname",uqhn,"host location identification"); Gr(fp,where,a_alias,hostname,"host location identification"); // Alias for quick association Gr(fp,Domain(domain),a_contains,hostname,"host location identification"); char *identity = HostID(uqhn); Gr(fp,hostname,a_alias,identity,"host location identification"); RoleGr(fp,IPv4(ipv4),"ipv4 address", ipv4,"host location identification"); Gr(fp,where,a_alias,IPv4(ipv4),"host location identification"); // Alias for quick association Gr(fp,Domain(domain),a_contains,IPv4(ipv4),"host location identification"); Gr(fp,IPv4(ipv4),a_alias,HostID(ipv4),"host location identification"); if (ipv6 && strlen(ipv6) > 0) { RoleGr(fp,IPv6(ipv6),"ipv6 address", ipv6,"host location identification"); Gr(fp,where,a_alias,IPv6(ipv6),"host location identification"); // Alias for quick association Gr(fp,Domain(domain),a_contains,IPv6(ipv6),"host location identification"); identity = HostID(ipv6); Gr(fp,IPv6(ipv6),a_alias,identity,"host location identification"); Gr(fp,hostname,a_alias,IPv6(ipv6),"host location identification"); } if (address && address > 0) { char addressx[CGN_BUFSIZE]; snprintf(addressx,CGN_BUFSIZE,"description address %s",address); RoleGr(fp,addressx,"description address",address,"host location identification"); Gr(fp,Domain(domain),a_origin,addressx,"host location identification"); Gr(fp,"description address",a_related_to,"street address","host location identification"); } Gr(fp,hostname,a_alias,IPv4(ipv4),"host location identification"); return where; }
void InitialGr(FILE *fp) { // Basic axioms about causation (upstream/downstream principle) ContextGr(fp,"service relationship"); ContextGr(fp,"system diagnostics"); ContextGr(fp,"lifecycle state change"); ContextGr(fp,"software exception"); ContextGr(fp,"promise keeping"); ContextGr(fp,"host location identification"); Gr(fp,"client measurement anomaly",a_caused_by,"client software exception","system diagnostics"); Gr(fp,"client measurement anomaly",a_caused_by,"server software exception","system diagnostics"); Gr(fp,"server measurement anomaly",a_caused_by,"server software exception","system diagnostics"); Gr(fp,"measurement anomaly",a_caused_by,"software exception","system diagnostics"); Gr(fp,"resource contention",a_caused_by,"resource limit","system diagnostics"); Gr(fp,"increasing queue length",a_caused_by,"resource contention","system diagnostics"); Gr(fp,"system performance slow",a_caused_by,"increasing queue length","system diagnostics"); Gr(fp,"system performance slow",a_related_to,"system performance latency","system diagnostics"); Gr(fp,"system performance latency",a_caused_by,"resource contention","system diagnostics"); Gr(fp,"system performance latency",a_caused_by,"increasing queue length","system diagnostics"); Gr(fp,"system performance latency",a_caused_by,"server unavailability","system diagnostics"); Gr(fp,"server unavailability",a_caused_by,"software crash","system diagnostics"); Gr(fp,"server unavailability",a_caused_by,"system performance slow","system diagnostics"); }