• Skip to content
  • Skip to link menu
Trinity API Reference
  • Trinity API Reference
  • kio/kssl
 

kio/kssl

  • kio
  • kssl
ksslutils.cc
1 /* This file is part of the KDE project
2  *
3  * Copyright (C) 2000,2001 George Staikos <staikos@kde.org>
4  *
5  * This library is free software; you can redistribute it and/or
6  * modify it under the terms of the GNU Library General Public
7  * License as published by the Free Software Foundation; either
8  * version 2 of the License, or (at your option) any later version.
9  *
10  * This library is distributed in the hope that it will be useful,
11  * but WITHOUT ANY WARRANTY; without even the implied warranty of
12  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
13  * Library General Public License for more details.
14  *
15  * You should have received a copy of the GNU Library General Public License
16  * along with this library; see the file COPYING.LIB. If not, write to
17  * the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
18  * Boston, MA 02110-1301, USA.
19  */
20 
21 
22 #include "ksslutils.h"
23 
24 #include <tqstring.h>
25 #include <kglobal.h>
26 #include <klocale.h>
27 #include <tqdatetime.h>
28 
29 #include "kopenssl.h"
30 
31 #ifdef KSSL_HAVE_SSL
32 // This code is mostly taken from OpenSSL v0.9.5a
33 // by Eric Young
34 TQDateTime ASN1_UTCTIME_QDateTime(ASN1_UTCTIME *tm, int *isGmt) {
35 TQDateTime qdt;
36 char *v;
37 int gmt=0;
38 int gentime=0;
39 int yoffset=0;
40 int yearbase=1900;
41 int i;
42 int y=0,M=0,d=0,h=0,m=0,s=0;
43 TQDate qdate;
44 TQTime qtime;
45 
46  i = tm->length;
47  v = (char *)tm->data;
48  if ((i == 15) || (i == 21)) {
49  gentime=1;
50  yoffset=2;
51  yearbase=0;
52  }
53  if (i < 10) goto auq_err;
54  if (v[i-1] == 'Z') gmt=1;
55  for (i=0; i<10+yoffset; i++)
56  if ((v[i] > '9') || (v[i] < '0')) goto auq_err;
57  y = (v[0+yoffset]-'0')*10+(v[1+yoffset]-'0');
58  if (gentime)
59  y += (v[0]-'0')*1000+(v[1]-'0')*100;
60  if (y < 50) y+=100;
61  M = (v[2+yoffset]-'0')*10+(v[3+yoffset]-'0');
62  if ((M > 12) || (M < 1)) goto auq_err;
63  d = (v[4+yoffset]-'0')*10+(v[5+yoffset]-'0');
64  h = (v[6+yoffset]-'0')*10+(v[7+yoffset]-'0');
65  m = (v[8+yoffset]-'0')*10+(v[9+yoffset]-'0');
66  if ( (v[10+yoffset] >= '0') && (v[10+yoffset] <= '9') &&
67  (v[11+yoffset] >= '0') && (v[11+yoffset] <= '9'))
68  s = (v[10+yoffset]-'0')*10+(v[11+yoffset]-'0');
69 
70  // localize the date and display it.
71  qdate.setYMD(y+yearbase, M, d);
72  qtime.setHMS(h,m,s);
73  qdt.setDate(qdate); qdt.setTime(qtime);
74  auq_err:
75  if (isGmt) *isGmt = gmt;
76 return qdt;
77 }
78 
79 
80 TQString ASN1_UTCTIME_QString(ASN1_UTCTIME *tm) {
81  TQString qstr;
82  int gmt;
83  TQDateTime qdt = ASN1_UTCTIME_QDateTime(tm, &gmt);
84 
85  qstr = KGlobal::locale()->formatDateTime(qdt, false, true);
86  if (gmt) {
87  qstr += " ";
88  qstr += i18n("GMT");
89  }
90  return qstr;
91 }
92 
93 
94 TQString ASN1_INTEGER_QString(ASN1_INTEGER *aint) {
95  char *rep = KOSSL::self()->i2s_ASN1_INTEGER(NULL, aint);
96  TQString yy = rep;
97  KOSSL::self()->CRYPTO_free(rep);
98  return yy;
99 }
100 
101 
102 #endif
103 

kio/kssl

Skip menu "kio/kssl"
  • Main Page
  • Alphabetical List
  • Class List
  • File List
  • Class Members
  • Related Pages

kio/kssl

Skip menu "kio/kssl"
  • arts
  • dcop
  • dnssd
  • interfaces
  •     interface
  •     library
  •   kspeech
  •   ktexteditor
  • kabc
  • kate
  • kcmshell
  • kdecore
  • kded
  • kdefx
  • kdeprint
  • kdesu
  • kdeui
  • kdoctools
  • khtml
  • kimgio
  • kinit
  • kio
  •   bookmarks
  •   httpfilter
  •   kfile
  •   kio
  •   kioexec
  •   kpasswdserver
  •   kssl
  • kioslave
  •   http
  • kjs
  • kmdi
  •   kmdi
  • knewstuff
  • kparts
  • krandr
  • kresources
  • kspell2
  • kunittest
  • kutils
  • kwallet
  • libkmid
  • libkscreensaver
Generated for kio/kssl by doxygen 1.8.8
This website is maintained by Timothy Pearson.
KDE® and the K Desktop Environment® logo are registered trademarks of KDE e.V. |