From aa4df24aebd091fa9f3a8076b2da4a5c55f3d2c2 Mon Sep 17 00:00:00 2001 From: Christian Date: Wed, 7 Feb 2007 19:03:34 +0100 Subject: [PATCH] * fix version number in exported *.xca template * fix import of older XCA templates * Add templates for CA, client and server --- changelog | 2 ++ lib/pki_temp.cpp | 53 +++++++++++++++++++++++------------------- lib/pki_temp.h | 1 - misc/CA.xca | Bin 0 -> 72 bytes misc/HTTPS_client.xca | Bin 0 -> 72 bytes misc/HTTPS_server.xca | Bin 0 -> 72 bytes misc/Makefile | 2 +- misc/xca.nsi | 2 ++ 8 files changed, 34 insertions(+), 26 deletions(-) create mode 100644 misc/CA.xca create mode 100644 misc/HTTPS_client.xca create mode 100644 misc/HTTPS_server.xca diff --git a/changelog b/changelog index 6fd24962..e8c47d2d 100644 --- a/changelog +++ b/changelog @@ -1,3 +1,5 @@ + * fix version number in exported *.xca template + * fix import of older XCA templates * add support for predefined templates as there was in 0.5.1 * fix cmdline import of crypto items * add undelete feature for deleted items diff --git a/lib/pki_temp.cpp b/lib/pki_temp.cpp index 036239e8..5629ac79 100644 --- a/lib/pki_temp.cpp +++ b/lib/pki_temp.cpp @@ -230,7 +230,7 @@ void pki_temp::writeTemp(QString fname) } p = toData(&size); db::intToData(&p1, size); - db::intToData(&p1, version); + db::intToData(&p1, dataVersion); fwrite(buf, 2*sizeof(int), 1, fp); fwrite(p, 1, size, fp); OPENSSL_free(p); @@ -239,7 +239,8 @@ void pki_temp::writeTemp(QString fname) void pki_temp::loadTemp(QString fname) { - int size, s; + int size, s, version; + bool oldimport; unsigned char *p, buf[2*sizeof(int)]; const unsigned char *p1 = buf; FILE *fp = fopen(CCHAR(fname),"r"); @@ -248,19 +249,35 @@ void pki_temp::loadTemp(QString fname) return; } if (fread(buf, 2*sizeof(int), 1, fp) != 1) - openssl_error(tr("Template file content error")); + openssl_error(tr("Template file content error (too small)")); size = db::intFromData(&p1); version = db::intFromData(&p1); - if (size > 65535 || size <0) - openssl_error(tr("Template file content error")); - - p = (unsigned char *)OPENSSL_malloc(size); - if ((s=fread(p, 1, size, fp)) != size) { - OPENSSL_free(p); - openssl_error(tr("Template file content error")); + if (size > 65535 || size <0) { + fseek(fp, sizeof(int), SEEK_SET); + p1 = buf; + size = intFromData(&p1); + if (size > 65535 || size <0) { + fclose(fp); + openssl_error(tr("Template file content error (bad size)")); + } + oldimport = true; + } else { + oldimport = false; + } + p = (unsigned char *)OPENSSL_malloc(size); + if (p) { + if ((s=fread(p, 1, size, fp)) != size) { + OPENSSL_free(p); + fclose(fp); + openssl_error(tr("Template file content error (bad length)")); + } + } + if (oldimport) { + oldFromData(p, size); + } else { + fromData(p, size, version); } - fromData(p, size, version); OPENSSL_free(p); setIntName(rmslashdot(fname)); @@ -291,7 +308,6 @@ int pki_temp::dataSize() nsCaPolicyUrl.length() + nsSslServerName.length() + 12 ) * sizeof(char); - //printf("Size of template = %d\n", s); return s; } @@ -302,13 +318,6 @@ bool pki_temp::compare(pki_base *ref) // are stored in the database ... return false; } -QString pki_temp::type2Text(int type) -{ - QString typec[]={tr("Empty"), tr("CA"), tr("Client"), tr("Server")}; - if (type >= 0 && type < 4) - type = 0; - return typec[type]; -} QVariant pki_temp::column_data(int col) { @@ -329,12 +338,11 @@ QVariant pki_temp::getIcon() void pki_temp::oldFromData(unsigned char *p, int size ) { const unsigned char *p1 = p; - int type; + int type, version; bool dummy; version=intFromData(&p1); type=intFromData(&p1); - destination = type2Text(type); if (version == 1) { ca = 2; bool mca = intFromData(&p1); @@ -388,8 +396,5 @@ void pki_temp::oldFromData(unsigned char *p, int size ) if (p1-p != size) { openssl_error("Wrong Size"); } - - //set version to 3 - version = 3; } diff --git a/lib/pki_temp.h b/lib/pki_temp.h index 3c85a606..a9836db4 100644 --- a/lib/pki_temp.h +++ b/lib/pki_temp.h @@ -86,7 +86,6 @@ class pki_temp: public pki_base void writeTemp(QString fname); QVariant column_data(int col); QVariant getIcon(); - QString type2Text(int type); }; #endif diff --git a/misc/CA.xca b/misc/CA.xca new file mode 100644 index 0000000000000000000000000000000000000000..718a04102a7c44a9a73968a05de5a5d825781ed7 GIT binary patch literal 72 zcmZQzU~phyU|?ckWB?&30i?OWq6`cPKpF%JfVd(#Q6V|Cs3bEjGdZy&6(kG<1|R|e DrhEr6 literal 0 HcmV?d00001 diff --git a/misc/HTTPS_client.xca b/misc/HTTPS_client.xca new file mode 100644 index 0000000000000000000000000000000000000000..afbc19d513059247b0f6d1283ec485e4ae910d2a GIT binary patch literal 72 zcmZQzU~phyU|?ckWB?%$3k(=@Av6Oolx79e70HPT$*DypnQ58Hi6yB}83Pav0G}WR A)&Kwi literal 0 HcmV?d00001 diff --git a/misc/HTTPS_server.xca b/misc/HTTPS_server.xca new file mode 100644 index 0000000000000000000000000000000000000000..5b91338a27d7d2a5d6428aa41f0ff70e3bda7be4 GIT binary patch literal 72 zcmZQzU~phyU|?ckWB?%$3k(=@Av6O!lm>}cBqu5)rxulDre!84mZU;u3_vsho!JJ> literal 0 HcmV?d00001 diff --git a/misc/Makefile b/misc/Makefile index 5780a575..335e40b5 100644 --- a/misc/Makefile +++ b/misc/Makefile @@ -4,7 +4,7 @@ all: install: install -m 755 -d $(destdir)$(prefix)/share/xca/ \ $(destdir)$(prefix)/share/applications - install -m 644 *.txt $(destdir)$(prefix)/share/xca + install -m 644 *.txt *.xca $(destdir)$(prefix)/share/xca install -m 644 xca.desktop $(destdir)$(prefix)/share/applications app: diff --git a/misc/xca.nsi b/misc/xca.nsi index 84110ee5..70fb874d 100755 --- a/misc/xca.nsi +++ b/misc/xca.nsi @@ -64,6 +64,7 @@ Section "xca (required)" SecMain File "misc\eku.txt" File "misc\oids.txt" File "misc\aia.txt" + File "misc\*.xca" File /nonfatal "lang\*.qm" File "doc\*.html" File "${BDIR}\mingwm10.dll" @@ -142,6 +143,7 @@ Section "Uninstall" Delete $INSTDIR\key.ico Delete $INSTDIR\key.xpm Delete $INSTDIR\*.dll + Delete $INSTDIR\*.xca Delete $INSTDIR\*.txt Delete $INSTDIR\*.qm Delete $INSTDIR\*.html