source: branches/2.2/security/classes/funcoes_auxiliares.php @ 3984

Revision 3984, 74.6 KB checked in by rafaelraymundo, 13 years ago (diff)

Ticket #1738 - Corrige falha no login com certificado digital.

Line 
1<?php
2//  Conjunto de funcoes de apoio as Classes de tratamento do certificado digital.
3
4                function pega_path($chaves,$linha)
5                {
6                        if(!is_array($chaves) || !$linha)
7                                {
8                                        return false;
9                                }
10                        $ret = false;
11                        foreach($chaves as $chave)
12                                {
13                                        if(substr($linha,0,strlen($chave)) == $chave)
14                                                {
15                                                        $c = '';
16                                                        if(strpos($linha,'\'') > 0)
17                                                                {
18                                                                        $c = "'";
19                                                                }
20                                                        if(strpos($linha,'"') > 0)
21                                                                {
22                                                                        $c = '"';
23                                                                }
24                                                        if(!$c)
25                                                                {
26                                                                        break;
27                                                                }
28                                                        $data = explode($c,$linha);
29                                                        $ret = $data[1];
30                                                        break;
31                                                }
32                                }
33                        return $ret;
34                }
35
36        function ler_certificados_CAS($path,$flag=false)
37            {
38                // Ler o arquivo contendo certificados das Cas.
39                // Retorna array com os certificados formato PEM ...
40                $retorno = array();
41                if($flag === false)
42                    {
43                        if(!file_exists($path))
44                            {
45                                return $retorno;
46                            }
47                        $dados_do_arquivo = file_get_contents($path);
48                    }
49                 else
50                     {
51                        $dados_do_arquivo = $path;
52                     }
53                $inicio = '-----BEGIN CERTIFICATE-----';
54                $fim = '-----END CERTIFICATE-----';
55                $aux1 = explode($inicio,$dados_do_arquivo);
56                foreach($aux1 as $aux2)
57                    {
58                        if($aux2)
59                            {
60                                    $aux3 = explode($fim,$aux2);
61                                    $retorno[] =$inicio . $aux3[0] . $fim;
62                            }
63                    }
64                return $retorno;
65            }
66
67        function gera_xml_com_dados_do_certificado($dados)
68                {
69                    // Recebe array com dados de um certificado e gera o xml com estes dados.
70                    // As chaves formam os tags e os dados  o conteudo do tag ....
71                    $aux_xml = "<certificado>";
72                    if(is_array($dados))
73                        {
74                            foreach($dados as $K => $valor)
75                                    {
76                                        $aux_x = substr($K,0,1);
77                                        if(is_numeric($aux_x)) $K = 'oid-' . $K;
78                                        $K = trim($K);
79                                        if(!is_array($valor))
80                                            {
81                                                $aux_xml .= '<' . $K . '>'.$valor.'</' . $K . '>';
82                                            }
83                                        else
84                                            {
85                                                $aux_xml .= '<' . $K . '>';
86                                                foreach($valor as $KX => $valorx)
87                                                        {
88                                                            //$KX = trim($KX);
89                                                            if(is_int($KX))  $KX = 'D' . $KX;
90                                                            $KX = trim($KX);
91                                                            $aux_xml .= '<' . $KX . '>'.$valorx.'</' . $KX . '>';
92                                                        }
93                                                $aux_xml .= '</' . $K . '>';
94                                            }
95                                    }
96                        }
97                    $aux_xml .= "</certificado>";
98                    return  $aux_xml;
99                }
100
101
102        function data_hora ($valor)
103        {
104                $year  = substr($valor, 0, 2);
105                $month = substr($valor, 2, 2);
106                $day   = substr($valor, 4, 2);
107                $hour  = substr($valor, 6, 2);
108                $min   = substr($valor, 8, 2);
109                $sec   = substr($valor, 10, 2);
110                return gmdate('YmdHis',gmmktime($hour, $min, $sec, $month, $day, $year));
111        }
112
113
114        function gera_nome_arquivo_temporario($tab_arqs)
115        {
116                //include('Verifica_Certificado_conf.php');
117                if(!is_dir($GLOBALS['dirtemp']))
118                {
119                        #Se nao existe uma area de trabalho aborta a funcao..
120                        return false;
121                }
122                $lista = array('A','B','C','D','E','F','G','H','I','J','K','L','M','N','O','P','Q','R','S','T','U','V','W','X','Y','Z');
123                $N = $lista[rand(0,count($lista)-1)].date('U').$lista[rand(0,count($lista)-1)].RAND(12345,9999999999).$lista[rand(0,count($lista)-1)].$lista[rand(0,count($lista)-1)].RAND(12345,9999999999).'.tmp';
124                $aux = $GLOBALS['dirtemp'].'/'.$N;;
125                array_push($tab_arqs ,$aux);
126                return  $aux;
127        }
128
129
130        function grava_arquivo($arquivo,$dados)
131        {
132                $ret = file_put_contents($arquivo,$dados);
133                if(!$ret)
134                {
135                        return false;
136                }
137                else
138                        return $ret;
139        }
140
141
142        function deleta_arquivos_temporarios($tab_arqs)
143        {
144                foreach($tab_arqs as $arquivo )
145                        {
146                                if(file_exists($arquivo))
147                                        {
148                                                unlink($arquivo);
149                                        }
150                        }
151        }
152
153        function troca_espaco_por_mais($pem_data)
154        {
155            $begin = "CERTIFICATE-----";
156            $end   = "-----END";
157            $aux = substr($pem_data, strpos($pem_data, $begin)+strlen($begin));
158            $aux = substr($aux, 0, strpos($aux, $end));
159            $aux = strtr($aux,' ','+');
160            $aux = '-----BEGIN CERTIFICATE-----'.$aux.'-----END CERTIFICATE-----';
161            return $aux;
162        }
163        function verificaopenssl()
164        {
165                if(extension_loaded('openssl'))
166                {
167                        return true;
168                }
169                else
170                        return false;
171        }
172
173
174        function print_hex($value)
175        {
176                $tab_val = array('0','1','2','3','4','5','6','7','8','9','A','B','C','D','E','F');
177                for($A=0;$A<strlen($value);$A++)
178                        {
179                                $aux_parte_numerica =ord(substr($value,$A,1)) % 16;
180                                $aux_parte_zona = (ord(substr($value,$A,1)) - $aux_parte_numerica) / 16;
181                                $parte_numerica = $tab_val[$aux_parte_numerica];
182                                $parte_zona = $tab_val[$aux_parte_zona];
183                                $hex .=  $parte_zona.$parte_numerica;
184                        }
185                        return $hex;
186        }
187
188
189        function get_length($len,$bytes,$data)
190        {
191                $len = ord($data[1]);
192                $bytes = 0;
193                # Testa se tamanho menor/igual a 127 bytes..
194                # Neste caso $len  ja he o tamanho do conteudo
195                if ($len & 0x80)
196                        {
197                                # Testa se tamanho indefinido (nao deve ocorrer em uma codificação DER.
198                                if($len == chr(0x80))
199                                        {
200                                                # Tamanho indefinido, limitado por 0x0000h
201                                                $len = strpos($data,chr(0x00).chr(0x00));
202                                                $bytes = 0;
203                                        }
204                                else
205                                        {
206                                                # he tamanho definido. diz quantos bytes formam o tamanho....
207                                                $bytes = $len & 0x0f;
208                                                $len = 0;
209                                                for ($i = 0; $i < $bytes; $i++)
210                                                        {
211                                                                $len = ($len << 8) | ord($data[$i + 2]);
212                                                        }
213                                        }
214                        }
215        }
216
217        function xBase128($ab,$q,$flag )
218        {
219                $abc = $ab;
220                if( $q > 127 )
221                        {
222                                $abc = xBase128($abc, floor($q / 128), 0 );
223                        }
224                $q = $q % 128;
225                if( $flag)
226                        {
227                                $abc[] = $q;
228                        }
229                else
230                        {
231                                $abc[] = 0x80 | $q;
232                        }
233                return $abc;
234        }
235
236
237
238        function OIDtoHex($oid)
239        {
240                $abBinary = array();
241                $partes = explode('.',$oid);
242                $n = 0;
243                $b = 0;
244                for($n = 0; $n < count($partes); $n++)
245                {
246                        if($n==0)
247                                {
248                                        $b = 40 * $partes[$n];
249                                }
250                        elseif($n==1)
251                                {
252                                        $b +=  $partes[$n];
253                                        $abBinary[] = $b;
254                                }
255                        else
256                                {
257                                        $abBinary = xBase128($abBinary, $partes[$n], 1 );
258                                }
259                }
260                $value =chr(0x06) . chr(count($abBinary));
261                foreach($abBinary as $item)
262                {
263                        $value .= chr($item);
264                }
265                return $value;
266        }
267
268
269
270        function Crl_parseASN($data,$context_especific = false)
271        {
272        // Tabela de OIDs .
273                $_oids = array(
274                        '2.5.4.3' => 'CN',
275                        '2.5.4.4' => 'Surname',
276                        '2.5.4.6' => 'C',
277                        '2.5.4.7' => 'Cidade',
278                        '2.5.4.8' => 'Estatdo',
279                        '2.5.4.9' => 'StreetAddress',
280                        '2.5.4.10' => 'O',
281                        '2.5.4.11' => 'OU',
282                        '2.5.4.12' => 'Title',
283                        '2.5.4.20' => 'TelephoneNumber',
284                        '2.5.4.42' => 'GivenName',
285                        '2.5.29.14' => 'id-ce-subjectKeyIdentifier',
286                        '2.5.29.15' => 'id-ce-keyUsage',
287                        '2.5.29.17' => 'id-ce-subjectAltName',
288                        '2.5.29.19' => 'id-ce-basicConstraints',
289                        '2.5.29.20' => 'id-ce-cRLNumber',
290                        '2.5.29.31' => 'id-ce-CRLDistributionPoints',
291                        '2.5.29.32' => 'id-ce-certificatePolicies',
292                        '2.5.29.35' => 'id-ce-authorityKeyIdentifier',
293                        '2.5.29.37' => 'id-ce-extKeyUsage',
294                        '1.2.840.113549.1.9.1' => 'Email',
295                        '1.2.840.113549.1.1.1' => 'RSAEncryption',
296                        '1.2.840.113549.1.1.2' => 'md2WithRSAEncryption',
297                        '1.2.840.113549.1.1.4' => 'md5withRSAEncryption',
298                        '1.2.840.113549.1.1.5' => 'SHA-1WithRSAEncryption',
299                        '1.2.840.10040.4.3' => 'id-dsa-with-sha-1',
300                        '1.3.6.1.5.5.7.3.2' => 'id_kp_clientAuth',
301                        '1.3.6.1.5.5.7.3.4' => 'id_kp_securityemail',
302                        '1.3.6.1.5.5.7.2.1' => 'id_certificatePolicies',
303                        '2.16.840.1.113730.1.1' => 'netscape-cert-type',
304                        '2.16.840.1.113730.1.2' => 'netscape-base-url',
305                        '2.16.840.1.113730.1.3' => 'netscape-revocation-url',
306                        '2.16.840.1.113730.1.4' => 'netscape-ca-revocation-url',
307                        '2.16.840.1.113730.1.7' => 'netscape-cert-renewal-url',
308                        '2.16.840.1.113730.1.8' => 'netscape-ca-policy-url',
309                        '2.16.840.1.113730.1.12' => 'netscape-ssl-server-name',
310                        '2.16.840.1.113730.1.13' => 'netscape-comment',
311                        '2.16.76.1.2.1' => 'A1',
312                        '2.16.76.1.2.3' => 'A3',
313                        '2.16.76.1.2.1.16' => 'Certification Practice Statement pointer',
314                        '2.16.76.1.3.1' => 'Dados do cert parte 1',
315                        '2.16.76.1.3.5' => 'Dados do cert parte 2',
316                        '2.16.76.1.3.6' => 'Dados do cert parte 3',
317                        '0.9.2342.19200300.100.1.25' => ' domainComponent',
318                        '1.2.36.68980861.1.1.10' => ' Signet pilot',
319                        '1.2.36.68980861.1.1.11' => ' Signet intraNet',
320                        '1.2.36.68980861.1.1.2' => ' Signet personal',
321                        '1.2.36.68980861.1.1.20' => ' Signet securityPolicy',
322                        '1.2.36.68980861.1.1.3' => ' Signet business',
323                        '1.2.36.68980861.1.1.4' => ' Signet legal',
324                        '1.2.36.75878867.1.100.1.1' => ' Certificates Australia policyIdentifier',
325                        '1.2.752.34.1' => ' seis-cp',
326                        '1.2.752.34.1.1' => ' SEIS certificatePolicy-s10',
327                        '1.2.752.34.2' => ' SEIS pe',
328                        '1.2.752.34.3' => ' SEIS at',
329                        '1.2.752.34.3.1' => ' SEIS at-personalIdentifier',
330                        '1.2.840.10040.2.1' => ' holdinstruction-none',
331                        '1.2.840.10040.2.2' => ' holdinstruction-callissuer',
332                        '1.2.840.10040.2.3' => ' holdinstruction-reject',
333                        '1.2.840.10040.4.1' => ' dsa',
334                        '1.2.840.10040.4.3' => ' dsaWithSha1',
335                        '1.2.840.10045.1' => ' fieldType',
336                        '1.2.840.10045.1.1' => ' prime-field',
337                        '1.2.840.10045.1.2' => ' characteristic-two-field',
338                        '1.2.840.10045.1.2.1' => ' ecPublicKey',
339                        '1.2.840.10045.1.2.3' => ' characteristic-two-basis',
340                        '1.2.840.10045.1.2.3.1' => ' onBasis',
341                        '1.2.840.10045.1.2.3.2' => ' tpBasis',
342                        '1.2.840.10045.1.2.3.3' => ' ppBasis',
343                        '1.2.840.10045.2' => ' publicKeyType',
344                        '1.2.840.10045.2.1' => ' ecPublicKey',
345                        '1.2.840.10046.2.1' => ' dhPublicNumber',
346                        '1.2.840.113533.7' => ' nsn',
347                        '1.2.840.113533.7.65' => ' nsn-ce',
348                        '1.2.840.113533.7.65.0' => ' entrustVersInfo',
349                        '1.2.840.113533.7.66' => ' nsn-alg',
350                        '1.2.840.113533.7.66.10' => ' cast5CBC',
351                        '1.2.840.113533.7.66.11' => ' cast5MAC',
352                        '1.2.840.113533.7.66.12' => ' pbeWithMD5AndCAST5-CBC',
353                        '1.2.840.113533.7.66.13' => ' passwordBasedMac',
354                        '1.2.840.113533.7.66.3' => ' cast3CBC',
355                        '1.2.840.113533.7.67' => ' nsn-oc',
356                        '1.2.840.113533.7.67.0' => ' entrustUser',
357                        '1.2.840.113533.7.68' => ' nsn-at',
358                        '1.2.840.113533.7.68.0' => ' entrustCAInfo',
359                        '1.2.840.113533.7.68.10' => ' attributeCertificate',
360                        '1.2.840.113549.1.1' => ' pkcs-1',
361                        '1.2.840.113549.1.1.1' => ' rsaEncryption',
362                        '1.2.840.113549.1.1.2' => ' md2withRSAEncryption',
363                        '1.2.840.113549.1.1.3' => ' md4withRSAEncryption',
364                        '1.2.840.113549.1.1.4' => ' md5withRSAEncryption',
365                        '1.2.840.113549.1.1.5' => ' sha1withRSAEncryption',
366                        '1.2.840.113549.1.1.6' => ' rsaOAEPEncryptionSET',
367                        '1.2.840.113549.1.9.16.2.11' => 'SMIMEEncryptionKeyPreference',
368                        '1.2.840.113549.1.12' => ' pkcs-12',
369                        '1.2.840.113549.1.12.1' => ' pkcs-12-PbeIds',
370                        '1.2.840.113549.1.12.1.1' => ' pbeWithSHAAnd128BitRC4',
371                        '1.2.840.113549.1.12.1.2' => ' pbeWithSHAAnd40BitRC4',
372                        '1.2.840.113549.1.12.1.3' => ' pbeWithSHAAnd3-KeyTripleDES-CBC',
373                        '1.2.840.113549.1.12.1.4' => ' pbeWithSHAAnd2-KeyTripleDES-CBC',
374                        '1.2.840.113549.1.12.1.5' => ' pbeWithSHAAnd128BitRC2-CBC',
375                        '1.2.840.113549.1.12.1.6' => ' pbeWithSHAAnd40BitRC2-CBC',
376                        '1.2.840.113549.1.12.10' => ' pkcs-12Version1',
377                        '1.2.840.113549.1.12.10.1' => ' pkcs-12BadIds',
378                        '1.2.840.113549.1.12.10.1.1' => ' pkcs-12-keyBag',
379                        '1.2.840.113549.1.12.10.1.2' => ' pkcs-12-pkcs-8ShroudedKeyBag',
380                        '1.2.840.113549.1.12.10.1.3' => ' pkcs-12-certBag',
381                        '1.2.840.113549.1.12.10.1.4' => ' pkcs-12-crlBag',
382                        '1.2.840.113549.1.12.10.1.5' => ' pkcs-12-secretBag',
383                        '1.2.840.113549.1.12.10.1.6' => ' pkcs-12-safeContentsBag',
384                        '1.2.840.113549.1.12.2' => ' pkcs-12-ESPVKID',
385                        '1.2.840.113549.1.12.2.1' => ' pkcs-12-PKCS8KeyShrouding',
386                        '1.2.840.113549.1.12.3' => ' pkcs-12-BagIds',
387                        '1.2.840.113549.1.12.3.1' => ' pkcs-12-keyBagId',
388                        '1.2.840.113549.1.12.3.2' => ' pkcs-12-certAndCRLBagId',
389                        '1.2.840.113549.1.12.3.3' => ' pkcs-12-secretBagId',
390                        '1.2.840.113549.1.12.3.4' => ' pkcs-12-safeContentsId',
391                        '1.2.840.113549.1.12.3.5' => ' pkcs-12-pkcs-8ShroudedKeyBagId',
392                        '1.2.840.113549.1.12.4' => ' pkcs-12-CertBagID',
393                        '1.2.840.113549.1.12.4.1' => ' pkcs-12-X509CertCRLBagID',
394                        '1.2.840.113549.1.12.4.2' => ' pkcs-12-SDSICertBagID',
395                        '1.2.840.113549.1.12.5' => ' pkcs-12-OID',
396                        '1.2.840.113549.1.12.5.1' => ' pkcs-12-PBEID',
397                        '1.2.840.113549.1.12.5.1.1' => ' pkcs-12-PBEWithSha1And128BitRC4',
398                        '1.2.840.113549.1.12.5.1.2' => ' pkcs-12-PBEWithSha1And40BitRC4',
399                        '1.2.840.113549.1.12.5.1.3' => ' pkcs-12-PBEWithSha1AndTripleDESCBC',
400                        '1.2.840.113549.1.12.5.1.4' => ' pkcs-12-PBEWithSha1And128BitRC2CBC',
401                        '1.2.840.113549.1.12.5.1.5' => ' pkcs-12-PBEWithSha1And40BitRC2CBC',
402                        '1.2.840.113549.1.12.5.1.6' => ' pkcs-12-PBEWithSha1AndRC4',
403                        '1.2.840.113549.1.12.5.1.7' => ' pkcs-12-PBEWithSha1AndRC2CBC',
404                        '1.2.840.113549.1.12.5.2' => ' pkcs-12-EnvelopingID',
405                        '1.2.840.113549.1.12.5.2.1' => ' pkcs-12-RSAEncryptionWith128BitRC4',
406                        '1.2.840.113549.1.12.5.2.2' => ' pkcs-12-RSAEncryptionWith40BitRC4',
407                        '1.2.840.113549.1.12.5.2.3' => ' pkcs-12-RSAEncryptionWithTripleDES',
408                        '1.2.840.113549.1.12.5.3' => ' pkcs-12-SignatureID',
409                        '1.2.840.113549.1.12.5.3.1' => ' pkcs-12-RSASignatureWithSHA1Digest',
410                        '1.2.840.113549.1.3' => ' pkcs-3',
411                        '1.2.840.113549.1.3.1' => ' dhKeyAgreement',
412                        '1.2.840.113549.1.5' => ' pkcs-5',
413                        '1.2.840.113549.1.5.1' => ' pbeWithMD2AndDES-CBC',
414                        '1.2.840.113549.1.5.10' => ' pbeWithSHAAndDES-CBC',
415                        '1.2.840.113549.1.5.3' => ' pbeWithMD5AndDES-CBC',
416                        '1.2.840.113549.1.5.4' => ' pbeWithMD2AndRC2-CBC',
417                        '1.2.840.113549.1.5.6' => ' pbeWithMD5AndRC2-CBC',
418                        '1.2.840.113549.1.5.9' => ' pbeWithMD5AndXOR',
419                        '1.2.840.113549.1.7' => ' pkcs-7',
420                        '1.2.840.113549.1.7.1' => ' data',
421                        '1.2.840.113549.1.7.2' => ' signedData',
422                        '1.2.840.113549.1.7.3' => ' envelopedData',
423                        '1.2.840.113549.1.7.4' => ' signedAndEnvelopedData',
424                        '1.2.840.113549.1.7.5' => ' digestData',
425                        '1.2.840.113549.1.7.6' => ' encryptedData',
426                        '1.2.840.113549.1.7.7' => ' dataWithAttributes',
427                        '1.2.840.113549.1.7.8' => ' encryptedPrivateKeyInfo',
428                        '1.2.840.113549.1.9' => ' pkcs-9',
429                        '1.2.840.113549.1.9.1' => ' emailAddress',
430                        '1.2.840.113549.1.9.10' => ' issuerAndSerialNumber',
431                        '1.2.840.113549.1.9.11' => ' passwordCheck',
432                        '1.2.840.113549.1.9.12' => ' publicKey',
433                        '1.2.840.113549.1.9.13' => ' signingDescription',
434                        '1.2.840.113549.1.9.14' => ' extensionReq',
435                        '1.2.840.113549.1.9.15' => ' sMIMECapabilities',
436                        '1.2.840.113549.1.9.15.1' => ' preferSignedData',
437                        '1.2.840.113549.1.9.15.2' => ' canNotDecryptAny',
438                        '1.2.840.113549.1.9.15.3' => ' receiptRequest',
439                        '1.2.840.113549.1.9.15.4' => ' receipt',
440                        '1.2.840.113549.1.9.15.5' => ' contentHints',
441                        '1.2.840.113549.1.9.15.6' => ' mlExpansionHistory',
442                        '1.2.840.113549.1.9.16' => ' id-sMIME',
443                        '1.2.840.113549.1.9.16.0' => ' id-mod',
444                        '1.2.840.113549.1.9.16.0.1' => ' id-mod-cms',
445                        '1.2.840.113549.1.9.16.0.2' => ' id-mod-ess',
446                        '1.2.840.113549.1.9.16.1' => ' id-ct',
447                        '1.2.840.113549.1.9.16.1.1' => ' id-ct-receipt',
448                        '1.2.840.113549.1.9.16.2' => ' id-aa',
449                        '1.2.840.113549.1.9.16.2.1' => ' id-aa-receiptRequest',
450                        '1.2.840.113549.1.9.16.2.2' => ' id-aa-securityLabel',
451                        '1.2.840.113549.1.9.16.2.3' => ' id-aa-mlExpandHistory',
452                        '1.2.840.113549.1.9.16.2.4' => ' id-aa-contentHint',
453                        '1.2.840.113549.1.9.2' => ' unstructuredName',
454                        '1.2.840.113549.1.9.20' => ' friendlyName',
455                        '1.2.840.113549.1.9.21' => ' localKeyID',
456                        '1.2.840.113549.1.9.22' => ' certTypes',
457                        '1.2.840.113549.1.9.22.1' => ' x509Certificate',
458                        '1.2.840.113549.1.9.22.2' => ' sdsiCertificate',
459                        '1.2.840.113549.1.9.23' => ' crlTypes',
460                        '1.2.840.113549.1.9.23.1' => ' x509Crl',
461                        '1.2.840.113549.1.9.3' => ' contentType',
462                        '1.2.840.113549.1.9.4' => ' messageDigest',
463                        '1.2.840.113549.1.9.5' => ' signingTime',
464                        '1.2.840.113549.1.9.6' => ' countersignature',
465                        '1.2.840.113549.1.9.7' => ' challengePassword',
466                        '1.2.840.113549.1.9.8' => ' unstructuredAddress',
467                        '1.2.840.113549.1.9.9' => ' extendedCertificateAttributes',
468                        '1.2.840.113549.2' => ' digestAlgorithm',
469                        '1.2.840.113549.2.2' => ' md2',
470                        '1.2.840.113549.2.4' => ' md4',
471                        '1.2.840.113549.2.5' => ' md5',
472                        '1.2.840.113549.3' => ' encryptionAlgorithm',
473                        '1.2.840.113549.3.10' => ' desCDMF',
474                        '1.2.840.113549.3.2' => ' rc2CBC',
475                        '1.2.840.113549.3.3' => ' rc2ECB',
476                        '1.2.840.113549.3.4' => ' rc4',
477                        '1.2.840.113549.3.5' => ' rc4WithMAC',
478                        '1.2.840.113549.3.6' => ' DESX-CBC',
479                        '1.2.840.113549.3.7' => ' DES-EDE3-CBC',
480                        '1.2.840.113549.3.8' => ' RC5CBC',
481                        '1.2.840.113549.3.9' => ' RC5-CBCPad',
482                        '1.2.840.113556.4.3' => ' microsoftExcel',
483                        '1.2.840.113556.4.4' => ' titledWithOID',
484                        '1.2.840.113556.4.5' => ' microsoftPowerPoint',
485                        '1.3.133.16.840.9.84' => ' x9-84',
486                        '1.3.133.16.840.9.84.0' => ' x9-84-Module',
487                        '1.3.133.16.840.9.84.0.1' => ' x9-84-Biometrics',
488                        '1.3.133.16.840.9.84.0.2' => ' x9-84-CMS',
489                        '1.3.133.16.840.9.84.0.3' => ' x9-84-Identifiers',
490                        '1.3.133.16.840.9.84.1' => ' biometric',
491                        '1.3.133.16.840.9.84.1.0' => ' id-unknown-Type',
492                        '1.3.133.16.840.9.84.1.1' => ' id-body-Odor',
493                        '1.3.133.16.840.9.84.1.10' => ' id-palm',
494                        '1.3.133.16.840.9.84.1.11' => ' id-retina',
495                        '1.3.133.16.840.9.84.1.12' => ' id-signature',
496                        '1.3.133.16.840.9.84.1.13' => ' id-speech-Pattern',
497                        '1.3.133.16.840.9.84.1.14' => ' id-thermal-Image',
498                        '1.3.133.16.840.9.84.1.15' => ' id-vein-Pattern',
499                        '1.3.133.16.840.9.84.1.16' => ' id-thermal-Face-Image',
500                        '1.3.133.16.840.9.84.1.17' => ' id-thermal-Hand-Image',
501                        '1.3.133.16.840.9.84.1.18' => ' id-lip-Movement',
502                        '1.3.133.16.840.9.84.1.19' => ' id-gait',
503                        '1.3.133.16.840.9.84.1.2' => ' id-dna',
504                        '1.3.133.16.840.9.84.1.3' => ' id-ear-Shape',
505                        '1.3.133.16.840.9.84.1.4' => ' id-facial-Features',
506                        '1.3.133.16.840.9.84.1.5' => ' id-finger-Image',
507                        '1.3.133.16.840.9.84.1.6' => ' id-finger-Geometry',
508                        '1.3.133.16.840.9.84.1.7' => ' id-hand-Geometry',
509                        '1.3.133.16.840.9.84.1.8' => ' id-iris-Features',
510                        '1.3.133.16.840.9.84.1.9' => ' id-keystroke-Dynamics',
511                        '1.3.133.16.840.9.84.2' => ' processing-algorithm',
512                        '1.3.133.16.840.9.84.3' => ' matching-method',
513                        '1.3.133.16.840.9.84.4' => ' format-Owner',
514                        '1.3.133.16.840.9.84.4.0' => ' cbeff-Owner',
515                        '1.3.133.16.840.9.84.4.1' => ' ibia-Owner',
516                        '1.3.133.16.840.9.84.4.1.1' => ' id-ibia-SAFLINK',
517                        '1.3.133.16.840.9.84.4.1.10' => ' id-ibia-SecuGen',
518                        '1.3.133.16.840.9.84.4.1.11' => ' id-ibia-PreciseBiometric',
519                        '1.3.133.16.840.9.84.4.1.12' => ' id-ibia-Identix',
520                        '1.3.133.16.840.9.84.4.1.13' => ' id-ibia-DERMALOG',
521                        '1.3.133.16.840.9.84.4.1.14' => ' id-ibia-LOGICO',
522                        '1.3.133.16.840.9.84.4.1.15' => ' id-ibia-NIST',
523                        '1.3.133.16.840.9.84.4.1.16' => ' id-ibia-A3Vision',
524                        '1.3.133.16.840.9.84.4.1.17' => ' id-ibia-NEC',
525                        '1.3.133.16.840.9.84.4.1.18' => ' id-ibia-STMicroelectronics',
526                        '1.3.133.16.840.9.84.4.1.2' => ' id-ibia-Bioscrypt',
527                        '1.3.133.16.840.9.84.4.1.3' => ' id-ibia-Visionics',
528                        '1.3.133.16.840.9.84.4.1.4' => ' id-ibia-InfineonTechnologiesAG',
529                        '1.3.133.16.840.9.84.4.1.5' => ' id-ibia-IridianTechnologies',
530                        '1.3.133.16.840.9.84.4.1.6' => ' id-ibia-Veridicom',
531                        '1.3.133.16.840.9.84.4.1.7' => ' id-ibia-CyberSIGN',
532                        '1.3.133.16.840.9.84.4.1.8' => ' id-ibia-eCryp.',
533                        '1.3.133.16.840.9.84.4.1.9' => ' id-ibia-FingerprintCardsAB',
534                        '1.3.133.16.840.9.84.4.2' => ' x9-Owner',
535                        '1.3.14.2.26.5' => ' sha',
536                        '1.3.14.3.2.1.1' => ' rsa',
537                        '1.3.14.3.2.10' => ' desMAC',
538                        '1.3.14.3.2.11' => ' rsaSignature',
539                        '1.3.14.3.2.12' => ' dsa',
540                        '1.3.14.3.2.13' => ' dsaWithSHA',
541                        '1.3.14.3.2.14' => ' mdc2WithRSASignature',
542                        '1.3.14.3.2.15' => ' shaWithRSASignature',
543                        '1.3.14.3.2.16' => ' dhWithCommonModulus',
544                        '1.3.14.3.2.17' => ' desEDE',
545                        '1.3.14.3.2.18' => ' sha',
546                        '1.3.14.3.2.19' => ' mdc-2',
547                        '1.3.14.3.2.2' => ' md4WitRSA',
548                        '1.3.14.3.2.2.1' => ' sqmod-N',
549                        '1.3.14.3.2.20' => ' dsaCommon',
550                        '1.3.14.3.2.21' => ' dsaCommonWithSHA',
551                        '1.3.14.3.2.22' => ' rsaKeyTransport',
552                        '1.3.14.3.2.23' => ' keyed-hash-seal',
553                        '1.3.14.3.2.24' => ' md2WithRSASignature',
554                        '1.3.14.3.2.25' => ' md5WithRSASignature',
555                        '1.3.14.3.2.26' => ' sha1',
556                        '1.3.14.3.2.27' => ' dsaWithSHA1',
557                        '1.3.14.3.2.28' => ' dsaWithCommonSHA1',
558                        '1.3.14.3.2.29' => ' sha-1WithRSAEncryption',
559                        '1.3.14.3.2.3' => ' md5WithRSA',
560                        '1.3.14.3.2.3.1' => ' sqmod-NwithRSA',
561                        '1.3.14.3.2.4' => ' md4WithRSAEncryption',
562                        '1.3.14.3.2.6' => ' desECB',
563                        '1.3.14.3.2.7' => ' desCBC',
564                        '1.3.14.3.2.8' => ' desOFB',
565                        '1.3.14.3.2.9' => ' desCFB',
566                        '1.3.14.3.3.1' => ' simple-strong-auth-mechanism',
567                        '1.3.14.7.2.1.1' => ' ElGamal',
568                        '1.3.14.7.2.3.1' => ' md2WithRSA',
569                        '1.3.14.7.2.3.2' => ' md2WithElGamal',
570                        '1.3.36.3' => ' algorithm',
571                        '1.3.36.3.1' => ' encryptionAlgorithm',
572                        '1.3.36.3.1.1' => ' des',
573                        '1.3.36.3.1.1.1.1' => ' desECBPad',
574                        '1.3.36.3.1.1.1.1.1' => ' desECBPadISO',
575                        '1.3.36.3.1.1.2.1' => ' desCBCPad',
576                        '1.3.36.3.1.1.2.1.1' => ' desCBCPadISO',
577                        '1.3.36.3.1.2' => ' idea',
578                        '1.3.36.3.1.2.1' => ' ideaECB',
579                        '1.3.36.3.1.2.1.1' => ' ideaECBPad',
580                        '1.3.36.3.1.2.1.1.1' => ' ideaECBPadISO',
581                        '1.3.36.3.1.2.2' => ' ideaCBC',
582                        '1.3.36.3.1.2.2.1' => ' ideaCBCPad',
583                        '1.3.36.3.1.2.2.1.1' => ' ideaCBCPadISO',
584                        '1.3.36.3.1.2.3' => ' ideaOFB',
585                        '1.3.36.3.1.2.4' => ' ideaCFB',
586                        '1.3.36.3.1.3' => ' des-3',
587                        '1.3.36.3.1.3.1.1' => ' des-3ECBPad',
588                        '1.3.36.3.1.3.1.1.1' => ' des-3ECBPadISO',
589                        '1.3.36.3.1.3.2.1' => ' des-3CBCPad',
590                        '1.3.36.3.1.3.2.1.1' => ' des-3CBCPadISO',
591                        '1.3.36.3.2' => ' hashAlgorithm',
592                        '1.3.36.3.2.1' => ' ripemd160',
593                        '1.3.36.3.2.2' => ' ripemd128',
594                        '1.3.36.3.2.3' => ' ripemd256',
595                        '1.3.36.3.2.4' => ' mdc2singleLength',
596                        '1.3.36.3.2.5' => ' mdc2doubleLength',
597                        '1.3.36.3.3' => ' signatureAlgorithm',
598                        '1.3.36.3.3.1' => ' rsa',
599                        '1.3.36.3.3.1.1' => ' rsaMitSHA-1',
600                        '1.3.36.3.3.1.2' => ' rsaMitRIPEMD160',
601                        '1.3.36.3.3.2' => ' ellipticCurve',
602                        '1.3.36.3.4' => ' signatureScheme',
603                        '1.3.36.3.4.1' => ' iso9796-1',
604                        '1.3.36.3.4.2.1' => ' iso9796-2',
605                        '1.3.36.3.4.2.2' => ' iso9796-2rsa',
606                        '1.3.36.4' => ' attribute',
607                        '1.3.36.5' => ' policy',
608                        '1.3.36.6' => ' api',
609                        '1.3.36.6.1' => ' manufacturerSpecific',
610                        '1.3.36.6.2' => ' functionalitySpecific',
611                        '1.3.36.7' => ' api',
612                        '1.3.36.7.1' => ' keyAgreement',
613                        '1.3.36.7.2' => ' keyTransport',
614                        '1.3.6.1.4.1.2428.10.1.1' => ' UNINETT policyIdentifier',
615                        '1.3.6.1.4.1.2712.10' => ' ICE-TEL policyIdentifier',
616                        '1.3.6.1.4.1.3029.32.1' => ' cryptlibEnvelope',
617                        '1.3.6.1.4.1.3029.32.2' => ' cryptlibPrivateKey',
618                        '1.3.6.1.4.1.311' => ' Microsoft OID',
619                        '1.3.6.1.4.1.311.10' => ' Crypto 2.0',
620                        '1.3.6.1.4.1.311.10.1' => ' certTrustList',
621                        '1.3.6.1.4.1.311.10.1.1' => ' szOID_SORTED_CTL',
622                        '1.3.6.1.4.1.311.10.10' => ' Microsoft CMC OIDs',
623                        '1.3.6.1.4.1.311.10.10.1' => ' szOID_CMC_ADD_ATTRIBUTES',
624                        '1.3.6.1.4.1.311.10.11' => ' Microsoft certificate property OIDs',
625                        '1.3.6.1.4.1.311.10.11.1' => ' szOID_CERT_PROP_ID_PREFIX',
626                        '1.3.6.1.4.1.311.10.12' => ' CryptUI',
627                        '1.3.6.1.4.1.311.10.12.1' => ' szOID_ANY_APPLICATION_POLICY',
628                        '1.3.6.1.4.1.311.10.2' => ' nextUpdateLocation',
629                        '1.3.6.1.4.1.311.10.3.1' => ' certTrustListSigning',
630                        '1.3.6.1.4.1.311.10.3.10' => ' szOID_KP_QUALIFIED_SUBORDINATION',
631                        '1.3.6.1.4.1.311.10.3.11' => ' szOID_KP_KEY_RECOVERY',
632                        '1.3.6.1.4.1.311.10.3.12' => ' szOID_KP_DOCUMENT_SIGNING',
633                        '1.3.6.1.4.1.311.10.3.2' => ' timeStampSigning',
634                        '1.3.6.1.4.1.311.10.3.3' => ' serverGatedCrypto',
635                        '1.3.6.1.4.1.311.10.3.3.1' => ' szOID_SERIALIZED',
636                        '1.3.6.1.4.1.311.10.3.4' => ' encryptedFileSystem',
637                        '1.3.6.1.4.1.311.10.3.4.1' => ' szOID_EFS_RECOVERY',
638                        '1.3.6.1.4.1.311.10.3.5' => ' szOID_WHQL_CRYPTO',
639                        '1.3.6.1.4.1.311.10.3.6' => ' szOID_NT5_CRYPTO',
640                        '1.3.6.1.4.1.311.10.3.7' => ' szOID_OEM_WHQL_CRYPTO',
641                        '1.3.6.1.4.1.311.10.3.8' => ' szOID_EMBEDDED_NT_CRYPTO',
642                        '1.3.6.1.4.1.311.10.3.9' => ' szOID_ROOT_LIST_SIGNER',
643                        '1.3.6.1.4.1.311.10.4.1' => ' yesnoTrustAttr',
644                        '1.3.6.1.4.1.311.10.5.1' => ' szOID_DRM',
645                        '1.3.6.1.4.1.311.10.5.2' => ' szOID_DRM_INDIVIDUALIZATION',
646                        '1.3.6.1.4.1.311.10.6.1' => ' szOID_LICENSES',
647                        '1.3.6.1.4.1.311.10.6.2' => ' szOID_LICENSE_SERVER',
648                        '1.3.6.1.4.1.311.10.7' => ' szOID_MICROSOFT_RDN_PREFIX',
649                        '1.3.6.1.4.1.311.10.7.1' => ' szOID_KEYID_RDN',
650                        '1.3.6.1.4.1.311.10.8.1' => ' szOID_REMOVE_CERTIFICATE',
651                        '1.3.6.1.4.1.311.10.9.1' => ' szOID_CROSS_CERT_DIST_POINTS',
652                        '1.3.6.1.4.1.311.12' => ' Catalog',
653                        '1.3.6.1.4.1.311.12.1.1' => ' szOID_CATALOG_LIST',
654                        '1.3.6.1.4.1.311.12.1.2' => ' szOID_CATALOG_LIST_MEMBER',
655                        '1.3.6.1.4.1.311.12.2.1' => ' CAT_NAMEVALUE_OBJID',
656                        '1.3.6.1.4.1.311.12.2.2' => ' CAT_MEMBERINFO_OBJID',
657                        '1.3.6.1.4.1.311.13' => ' Microsoft PKCS10 OIDs',
658                        '1.3.6.1.4.1.311.13.1' => ' szOID_RENEWAL_CERTIFICATE',
659                        '1.3.6.1.4.1.311.13.2.1' => ' szOID_ENROLLMENT_NAME_VALUE_PAIR',
660                        '1.3.6.1.4.1.311.13.2.2' => ' szOID_ENROLLMENT_CSP_PROVIDER',
661                        '1.3.6.1.4.1.311.13.2.3' => ' OS Version',
662                        '1.3.6.1.4.1.311.15' => ' Microsoft Java',
663                        '1.3.6.1.4.1.311.16' => ' Microsoft Outlook/Exchange',
664                        '1.3.6.1.4.1.311.16.4' => ' Outlook Express',
665                        '1.3.6.1.4.1.311.17' => ' Microsoft PKCS12 attributes',
666                        '1.3.6.1.4.1.311.17.1' => ' szOID_LOCAL_MACHINE_KEYSET',
667                        '1.3.6.1.4.1.311.18' => ' Microsoft Hydra',
668                        '1.3.6.1.4.1.311.19' => ' Microsoft ISPU Test',
669                        '1.3.6.1.4.1.311.2' => ' Authenticode',
670                        '1.3.6.1.4.1.311.2.1.10' => ' spcAgencyInfo',
671                        '1.3.6.1.4.1.311.2.1.11' => ' spcStatementType',
672                        '1.3.6.1.4.1.311.2.1.12' => ' spcSpOpusInfo',
673                        '1.3.6.1.4.1.311.2.1.14' => ' certExtensions',
674                        '1.3.6.1.4.1.311.2.1.15' => ' spcPelmageData',
675                        '1.3.6.1.4.1.311.2.1.18' => ' SPC_RAW_FILE_DATA_OBJID',
676                        '1.3.6.1.4.1.311.2.1.19' => ' SPC_STRUCTURED_STORAGE_DATA_OBJID',
677                        '1.3.6.1.4.1.311.2.1.20' => ' spcLink',
678                        '1.3.6.1.4.1.311.2.1.21' => ' individualCodeSigning',
679                        '1.3.6.1.4.1.311.2.1.22' => ' commercialCodeSigning',
680                        '1.3.6.1.4.1.311.2.1.25' => ' spcLink',
681                        '1.3.6.1.4.1.311.2.1.26' => ' spcMinimalCriteriaInfo',
682                        '1.3.6.1.4.1.311.2.1.27' => ' spcFinancialCriteriaInfo',
683                        '1.3.6.1.4.1.311.2.1.28' => ' spcLink',
684                        '1.3.6.1.4.1.311.2.1.29' => ' SPC_HASH_INFO_OBJID',
685                        '1.3.6.1.4.1.311.2.1.30' => ' SPC_SIPINFO_OBJID',
686                        '1.3.6.1.4.1.311.2.1.4' => ' spcIndirectDataContext',
687                        '1.3.6.1.4.1.311.2.2' => ' CTL for Software Publishers Trusted CAs',
688                        '1.3.6.1.4.1.311.2.2.1' => ' szOID_TRUSTED_CODESIGNING_CA_LIST',
689                        '1.3.6.1.4.1.311.2.2.2' => ' szOID_TRUSTED_CLIENT_AUTH_CA_LIST',
690                        '1.3.6.1.4.1.311.2.2.3' => ' szOID_TRUSTED_SERVER_AUTH_CA_LIST',
691                        '1.3.6.1.4.1.311.20' => ' Microsoft Enrollment Infrastructure',
692                        '1.3.6.1.4.1.311.20.1' => ' szOID_AUTO_ENROLL_CTL_USAGE',
693                        '1.3.6.1.4.1.311.20.2' => ' szOID_ENROLL_CERTTYPE_EXTENSION',
694                        '1.3.6.1.4.1.311.20.2.1' => ' szOID_ENROLLMENT_AGENT',
695                        '1.3.6.1.4.1.311.20.2.2' => ' szOID_KP_SMARTCARD_LOGON',
696                        '1.3.6.1.4.1.311.20.2.3' => ' szOID_NT_PRINCIPAL_NAME',
697                        '1.3.6.1.4.1.311.20.3' => ' szOID_CERT_MANIFOLD',
698                        '1.3.6.1.4.1.311.21' => ' Microsoft CertSrv Infrastructure',
699                        '1.3.6.1.4.1.311.21.1' => ' szOID_CERTSRV_CA_VERSION',
700                        '1.3.6.1.4.1.311.21.20' => ' Client Information',
701                        '1.3.6.1.4.1.311.25' => ' Microsoft Directory Service',
702                        '1.3.6.1.4.1.311.25.1' => ' szOID_NTDS_REPLICATION',
703                        '1.3.6.1.4.1.311.3' => ' Time Stamping',
704                        '1.3.6.1.4.1.311.3.2.1' => ' SPC_TIME_STAMP_REQUEST_OBJID',
705                        '1.3.6.1.4.1.311.30' => ' IIS',
706                        '1.3.6.1.4.1.311.31' => ' Windows updates and service packs',
707                        '1.3.6.1.4.1.311.31.1' => ' szOID_PRODUCT_UPDATE',
708                        '1.3.6.1.4.1.311.4' => ' Permissions',
709                        '1.3.6.1.4.1.311.40' => ' Fonts',
710                        '1.3.6.1.4.1.311.41' => ' Microsoft Licensing and Registration',
711                        '1.3.6.1.4.1.311.42' => ' Microsoft Corporate PKI (ITG)',
712                        '1.3.6.1.4.1.311.88' => ' CAPICOM',
713                        '1.3.6.1.4.1.311.88.1' => ' szOID_CAPICOM_VERSION',
714                        '1.3.6.1.4.1.311.88.2' => ' szOID_CAPICOM_ATTRIBUTE',
715                        '1.3.6.1.4.1.311.88.2.1' => ' szOID_CAPICOM_DOCUMENT_NAME',
716                        '1.3.6.1.4.1.311.88.2.2' => ' szOID_CAPICOM_DOCUMENT_DESCRIPTION',
717                        '1.3.6.1.4.1.311.88.3' => ' szOID_CAPICOM_ENCRYPTED_DATA',
718                        '1.3.6.1.4.1.311.88.3.1' => ' szOID_CAPICOM_ENCRYPTED_CONTENT',
719                        '1.3.6.1.5.5.7' => ' pkix',
720                        '1.3.6.1.5.5.7.1' => ' privateExtension',
721                        '1.3.6.1.5.5.7.1.1' => ' authorityInfoAccess',
722                        '1.3.6.1.5.5.7.12.2' => ' CMC Data',
723                        '1.3.6.1.5.5.7.2' => ' policyQualifierIds',
724                        '1.3.6.1.5.5.7.2.1' => ' cps',
725                        '1.3.6.1.5.5.7.2.2' => ' unotice',
726                        '1.3.6.1.5.5.7.3' => ' keyPurpose',
727                        '1.3.6.1.5.5.7.3.1' => ' serverAuth',
728                        '1.3.6.1.5.5.7.3.2' => ' clientAuth',
729                        '1.3.6.1.5.5.7.3.3' => ' codeSigning',
730                        '1.3.6.1.5.5.7.3.4' => ' emailProtection',
731                        '1.3.6.1.5.5.7.3.5' => ' ipsecEndSystem',
732                        '1.3.6.1.5.5.7.3.6' => ' ipsecTunnel',
733                        '1.3.6.1.5.5.7.3.7' => ' ipsecUser',
734                        '1.3.6.1.5.5.7.3.8' => ' timeStamping',
735                        '1.3.6.1.5.5.7.4' => ' cmpInformationTypes',
736                        '1.3.6.1.5.5.7.4.1' => ' caProtEncCert',
737                        '1.3.6.1.5.5.7.4.2' => ' signKeyPairTypes',
738                        '1.3.6.1.5.5.7.4.3' => ' encKeyPairTypes',
739                        '1.3.6.1.5.5.7.4.4' => ' preferredSymmAlg',
740                        '1.3.6.1.5.5.7.4.5' => ' caKeyUpdateInfo',
741                        '1.3.6.1.5.5.7.4.6' => ' currentCRL',
742                        '1.3.6.1.5.5.7.48.1' => ' ocsp',
743                        '1.3.6.1.5.5.7.48.2' => ' caIssuers',
744                        '1.3.6.1.5.5.8.1.1' => ' HMAC-MD5',
745                        '1.3.6.1.5.5.8.1.2' => ' HMAC-SHA',
746                        '2.16.840.1.101.2.1.1.1' => ' sdnsSignatureAlgorithm',
747                        '2.16.840.1.101.2.1.1.10' => ' mosaicKeyManagementAlgorithm',
748                        '2.16.840.1.101.2.1.1.11' => ' sdnsKMandSigAlgorithm',
749                        '2.16.840.1.101.2.1.1.12' => ' mosaicKMandSigAlgorithm',
750                        '2.16.840.1.101.2.1.1.13' => ' SuiteASignatureAlgorithm',
751                        '2.16.840.1.101.2.1.1.14' => ' SuiteAConfidentialityAlgorithm',
752                        '2.16.840.1.101.2.1.1.15' => ' SuiteAIntegrityAlgorithm',
753                        '2.16.840.1.101.2.1.1.16' => ' SuiteATokenProtectionAlgorithm',
754                        '2.16.840.1.101.2.1.1.17' => ' SuiteAKeyManagementAlgorithm',
755                        '2.16.840.1.101.2.1.1.18' => ' SuiteAKMandSigAlgorithm',
756                        '2.16.840.1.101.2.1.1.19' => ' mosaicUpdatedSigAlgorithm',
757                        '2.16.840.1.101.2.1.1.2' => ' mosaicSignatureAlgorithm',
758                        '2.16.840.1.101.2.1.1.20' => ' mosaicKMandUpdSigAlgorithms',
759                        '2.16.840.1.101.2.1.1.21' => ' mosaicUpdatedIntegAlgorithm',
760                        '2.16.840.1.101.2.1.1.22' => ' mosaicKeyEncryptionAlgorithm',
761                        '2.16.840.1.101.2.1.1.3' => ' sdnsConfidentialityAlgorithm',
762                        '2.16.840.1.101.2.1.1.4' => ' mosaicConfidentialityAlgorithm',
763                        '2.16.840.1.101.2.1.1.5' => ' sdnsIntegrityAlgorithm',
764                        '2.16.840.1.101.2.1.1.6' => ' mosaicIntegrityAlgorithm',
765                        '2.16.840.1.101.2.1.1.7' => ' sdnsTokenProtectionAlgorithm',
766                        '2.16.840.1.101.2.1.1.8' => ' mosaicTokenProtectionAlgorithm',
767                        '2.16.840.1.101.2.1.1.9' => ' sdnsKeyManagementAlgorithm',
768                        '2.16.840.1.113730.1' => ' cert-extension',
769                        '2.16.840.1.113730.1.1' => ' netscape-cert-type',
770                        '2.16.840.1.113730.1.10' => ' EntityLogo',
771                        '2.16.840.1.113730.1.11' => ' UserPicture',
772                        '2.16.840.1.113730.1.12' => ' netscape-ssl-server-name',
773                        '2.16.840.1.113730.1.13' => ' netscape-comment',
774                        '2.16.840.1.113730.1.2' => ' netscape-base-url',
775                        '2.16.840.1.113730.1.3' => ' netscape-revocation-url',
776                        '2.16.840.1.113730.1.4' => ' netscape-ca-revocation-url',
777                        '2.16.840.1.113730.1.7' => ' netscape-cert-renewal-url',
778                        '2.16.840.1.113730.1.8' => ' netscape-ca-policy-url',
779                        '2.16.840.1.113730.1.9' => ' HomePage-url',
780                        '2.16.840.1.113730.2' => ' data-type',
781                        '2.16.840.1.113730.2.1' => ' GIF',
782                        '2.16.840.1.113730.2.2' => ' JPEG',
783                        '2.16.840.1.113730.2.3' => ' URL',
784                        '2.16.840.1.113730.2.4' => ' HTML',
785                        '2.16.840.1.113730.2.5' => ' netscape-cert-sequence',
786                        '2.16.840.1.113730.2.6' => ' netscape-cert-url',
787                        '2.16.840.1.113730.3' => ' directory',
788                        '2.16.840.1.113730.4.1' => ' serverGatedCrypto',
789                        '2.16.840.1.113733.1.6.3' => ' Unknown Verisign extension',
790                        '2.16.840.1.113733.1.6.6' => ' Unknown Verisign extension',
791                        '2.16.840.1.113733.1.7.1.1' => ' Verisign certificatePolicy',
792                        '2.16.840.1.113733.1.7.1.1.1' => ' Unknown Verisign policy qualifier',
793                        '2.16.840.1.113733.1.7.1.1.2' => ' Unknown Verisign policy qualifier',
794                        '2.23.133' => ' TCPA',
795                        '2.23.133.1' => ' tcpa_specVersion',
796                        '2.23.133.2' => ' tcpa_attribute',
797                        '2.23.133.2.1' => ' tcpa_at_tpmManufacturer',
798                        '2.23.133.2.10' => ' tcpa_at_securityQualities',
799                        '2.23.133.2.11' => ' tcpa_at_tpmProtectionProfile',
800                        '2.23.133.2.12' => ' tcpa_at_tpmSecurityTarget',
801                        '2.23.133.2.13' => ' tcpa_at_foundationProtectionProfile',
802                        '2.23.133.2.14' => ' tcpa_at_foundationSecurityTarget',
803                        '2.23.133.2.15' => ' tcpa_at_tpmIdLabel',
804                        '2.23.133.2.2' => ' tcpa_at_tpmModel',
805                        '2.23.133.2.3' => ' tcpa_at_tpmVersion',
806                        '2.23.133.2.4' => ' tcpa_at_platformManufacturer',
807                        '2.23.133.2.5' => ' tcpa_at_platformModel',
808                        '2.23.133.2.6' => ' tcpa_at_platformVersion',
809                        '2.23.133.2.7' => ' tcpa_at_componentManufacturer',
810                        '2.23.133.2.8' => ' tcpa_at_componentModel',
811                        '2.23.133.2.9' => ' tcpa_at_componentVersion',
812                        '2.23.133.3' => ' tcpa_protocol',
813                        '2.23.133.3.1' => ' tcpa_prtt_tpmIdProtocol',
814                        '2.23.42.0' => ' contentType',
815                        '2.23.42.0.0' => ' PANData',
816                        '2.23.42.0.1' => ' PANToken',
817                        '2.23.42.0.2' => ' PANOnly',
818                        '2.23.42.1' => ' msgExt',
819                        '2.23.42.10' => ' national',
820                        '2.23.42.10.192' => ' Japan',
821                        '2.23.42.2' => ' field',
822                        '2.23.42.2.0' => ' fullName',
823                        '2.23.42.2.1' => ' givenName',
824                        '2.23.42.2.10' => ' amount',
825                        '2.23.42.2.2' => ' familyName',
826                        '2.23.42.2.3' => ' birthFamilyName',
827                        '2.23.42.2.4' => ' placeName',
828                        '2.23.42.2.5' => ' identificationNumber',
829                        '2.23.42.2.6' => ' month',
830                        '2.23.42.2.7' => ' date',
831                        '2.23.42.2.7.11' => ' accountNumber',
832                        '2.23.42.2.7.12' => ' passPhrase',
833                        '2.23.42.2.8' => ' address',
834                        '2.23.42.2.9' => ' telephone',
835                        '2.23.42.3' => ' attribute',
836                        '2.23.42.3.0' => ' cert',
837                        '2.23.42.3.0.0' => ' rootKeyThumb',
838                        '2.23.42.3.0.1' => ' additionalPolicy',
839                        '2.23.42.4' => ' algorithm',
840                        '2.23.42.5' => ' policy',
841                        '2.23.42.5.0' => ' root',
842                        '2.23.42.6' => ' module',
843                        '2.23.42.7' => ' certExt',
844                        '2.23.42.7.0' => ' hashedRootKey',
845                        '2.23.42.7.1' => ' certificateType',
846                        '2.23.42.7.2' => ' merchantData',
847                        '2.23.42.7.3' => ' cardCertRequired',
848                        '2.23.42.7.4' => ' tunneling',
849                        '2.23.42.7.5' => ' setExtensions',
850                        '2.23.42.7.6' => ' setQualifier',
851                        '2.23.42.8' => ' brand',
852                        '2.23.42.8.1' => ' IATA-ATA',
853                        '2.23.42.8.30' => ' Diners',
854                        '2.23.42.8.34' => ' AmericanExpress',
855                        '2.23.42.8.4' => ' VISA',
856                        '2.23.42.8.5' => ' MasterCard',
857                        '2.23.42.8.6011' => ' Novus',
858                        '2.23.42.9' => ' vendor',
859                        '2.23.42.9.0' => ' GlobeSet',
860                        '2.23.42.9.1' => ' IBM',
861                        '2.23.42.9.10' => ' Griffin',
862                        '2.23.42.9.11' => ' Certicom',
863                        '2.23.42.9.12' => ' OSS',
864                        '2.23.42.9.13' => ' TenthMountain',
865                        '2.23.42.9.14' => ' Antares',
866                        '2.23.42.9.15' => ' ECC',
867                        '2.23.42.9.16' => ' Maithean',
868                        '2.23.42.9.17' => ' Netscape',
869                        '2.23.42.9.18' => ' Verisign',
870                        '2.23.42.9.19' => ' BlueMoney',
871                        '2.23.42.9.2' => ' CyberCash',
872                        '2.23.42.9.20' => ' Lacerte',
873                        '2.23.42.9.21' => ' Fujitsu',
874                        '2.23.42.9.22' => ' eLab',
875                        '2.23.42.9.23' => ' Entrust',
876                        '2.23.42.9.24' => ' VIAnet',
877                        '2.23.42.9.25' => ' III',
878                        '2.23.42.9.26' => ' OpenMarket',
879                        '2.23.42.9.27' => ' Lexem',
880                        '2.23.42.9.28' => ' Intertrader',
881                        '2.23.42.9.29' => ' Persimmon',
882                        '2.23.42.9.3' => ' Terisa',
883                        '2.23.42.9.30' => ' NABLE',
884                        '2.23.42.9.31' => ' espace-net',
885                        '2.23.42.9.32' => ' Hitachi',
886                        '2.23.42.9.33' => ' Microsoft',
887                        '2.23.42.9.34' => ' NEC',
888                        '2.23.42.9.35' => ' Mitsubishi',
889                        '2.23.42.9.36' => ' NCR',
890                        '2.23.42.9.37' => ' e-COMM',
891                        '2.23.42.9.38' => ' Gemplus',
892                        '2.23.42.9.4' => ' RSADSI',
893                        '2.23.42.9.5' => ' VeriFone',
894                        '2.23.42.9.6' => ' TrinTech',
895                        '2.23.42.9.7' => ' BankGate',
896                        '2.23.42.9.8' => ' GTE',
897                        '2.23.42.9.9' => ' CompuSource',
898                        '2.5.29.1' => ' authorityKeyIdentifier',
899                        '2.5.29.10' => ' basicConstraints',
900                        '2.5.29.11' => ' nameConstraints',
901                        '2.5.29.12' => ' policyConstraints',
902                        '2.5.29.13' => ' basicConstraints',
903                        '2.5.29.14' => ' subjectKeyIdentifier',
904                        '2.5.29.15' => ' keyUsage',
905                        '2.5.29.16' => ' privateKeyUsagePeriod',
906                        '2.5.29.17' => ' subjectAltName',
907                        '2.5.29.18' => ' issuerAltName',
908                        '2.5.29.19' => ' basicConstraints',
909                        '2.5.29.2' => ' keyAttributes',
910                        '2.5.29.20' => ' cRLNumber',
911                        '2.5.29.21' => ' cRLReason',
912                        '2.5.29.22' => ' expirationDate',
913                        '2.5.29.23' => ' instructionCode',
914                        '2.5.29.24' => ' invalidityDate',
915                        '2.5.29.26' => ' issuingDistributionPoint',
916                        '2.5.29.27' => ' deltaCRLIndicator',
917                        '2.5.29.28' => ' issuingDistributionPoint',
918                        '2.5.29.29' => ' certificateIssuer',
919                        '2.5.29.3' => ' certificatePolicies',
920                        '2.5.29.30' => ' nameConstraints',
921                        '2.5.29.31' => ' cRLDistributionPoints',
922                        '2.5.29.32' => ' certificatePolicies',
923                        '2.5.29.33' => ' policyMappings',
924                        '2.5.29.34' => ' policyConstraints',
925                        '2.5.29.35' => ' authorityKeyIdentifier',
926                        '2.5.29.36' => ' policyConstraints',
927                        '2.5.29.37' => ' extKeyUsage',
928                        '2.5.29.4' => ' keyUsageRestriction',
929                        '2.5.29.5' => ' policyMapping',
930                        '2.5.29.6' => ' subtreesConstraint',
931                        '2.5.29.7' => ' subjectAltName',
932                        '2.5.29.8' => ' issuerAltName',
933                        '2.5.29.9' => ' subjectDirectoryAttributes',
934                        '2.5.4.0' => ' objectClass',
935                        '2.5.4.1' => ' aliasObjectName',
936                        '2.5.4.12' => ' title',
937                        '2.5.4.13' => ' description',
938                        '2.5.4.14' => ' searchGuide',
939                        '2.5.4.15' => ' businessCategory',
940                        '2.5.4.16' => ' postalAddress',
941                        '2.5.4.17' => ' postalCode',
942                        '2.5.4.18' => ' postOfficeBox',
943                        '2.5.4.19' => ' physicalDeliveryOfficeName',
944                        '2.5.4.2' => ' knowledgeInformation',
945                        '2.5.4.20' => ' telephoneNumber',
946                        '2.5.4.21' => ' telexNumber',
947                        '2.5.4.22' => ' teletexTerminalIdentifier',
948                        '2.5.4.23' => ' facsimileTelephoneNumber',
949                        '2.5.4.24' => ' x121Address',
950                        '2.5.4.25' => ' internationalISDNNumber',
951                        '2.5.4.26' => ' registeredAddress',
952                        '2.5.4.27' => ' destinationIndicator',
953                        '2.5.4.28' => ' preferredDeliveryMehtod',
954                        '2.5.4.29' => ' presentationAddress',
955                        '2.5.4.30' => ' supportedApplicationContext',
956                        '2.5.4.31' => ' member',
957                        '2.5.4.32' => ' owner',
958                        '2.5.4.33' => ' roleOccupant',
959                        '2.5.4.34' => ' seeAlso',
960                        '2.5.4.35' => ' userPassword',
961                        '2.5.4.36' => ' userCertificate',
962                        '2.5.4.37' => ' caCertificate',
963                        '2.5.4.38' => ' authorityRevocationList',
964                        '2.5.4.39' => ' certificateRevocationList',
965                        '2.5.4.40' => ' crossCertificatePair',
966                        '2.5.4.41' => ' givenName',
967                        '2.5.4.42' => ' givenName',
968                        '2.5.4.5' => ' serialNumber',
969                        '2.5.4.52' => ' supportedAlgorithms',
970                        '2.5.4.53' => ' deltaRevocationList',
971                        '2.5.4.58' => ' crossCertificatePair',
972                        '2.5.4.9' => ' streetAddress',
973                        '2.5.8' => ' X.500-Algorithms',
974                        '2.5.8.1' => ' X.500-Alg-Encryption',
975                        '2.5.8.1.1' => ' rsa',
976                        '2.16.76.1.1' => 'DPC',
977                        '2.16.76.1.1.0' => 'DPC da AC Raiz',
978                        '2.16.76.1.1.1' => 'DPC da AC Presidência',
979                        '2.16.76.1.1.2' => 'DPC da AC Serpro',
980                        '2.16.76.1.1.3' => 'DPC da SERASA Autoridade Certificadora Principal - ACP',
981                        '2.16.76.1.1.4' => 'DPC da SERASA Autoridade Certificadora - AC',
982                        '2.16.76.1.1.5' => 'DPC da AC CertiSign na ICP­Brasil',
983                        '2.16.76.1.1.6' => 'DPC da AC CertiSign SPB na ICP­Brasil',
984                        '2.16.76.1.1.7' => 'DPC da SERASA Certificadora Digital',
985                        '2.16.76.1.1.8' => 'DPC da AC SRF',
986                        '2.16.76.1.1.9' => 'DPC da AC CAIXA',
987                        '2.16.76.1.1.10' => 'DPC da AC CAIXA IN',
988                        '2.16.76.1.1.11' => 'DPC da AC CAIXA PJ',
989                        '2.16.76.1.1.12' => 'DPC da AC CAIXA PF',
990                        '2.16.76.1.1.13' => 'DPC da AC SERPRO SRF',
991                        '2.16.76.1.1.14' => 'DPC da Autoridade Certificadora CertiSign Múltipla',
992                        '2.16.76.1.1.15' => 'DPC da Autoridade Certificadora CertiSign para Secretaria da Receita Federal',
993                        '2.16.76.1.1.16' => 'DPC da AC SERASA SRF',
994                        '2.16.76.1.1.17' => 'DPC da Autoridade Certificadora Imprensa Oficial ­ SP',
995                        '2.16.76.1.1.18' => 'DPC da Autoridade Certificadora PRODEMGE',
996                        '2.16.76.1.1.19' => 'DPC da Autoridade Certificadora do Sistema Justiça Federal - AC­JUS',
997                        '2.16.76.1.1.20' => 'Declaração   de   Práticas   de   Certificação   da   Autoridade   Certificadora   do SERPRO Final - DPC SERPRO ACF',
998                        '2.16.76.1.1' => 'DPC',
999                        '2.16.76.1.1.21' => 'Declaração de Práticas de Certificação da Autoridade Certificadora SINCOR',
1000                        '2.16.76.1.1.22' => 'Declaração de Práticas de Certificação da Autoridade Certificadora Imprensa Oficial SP SRF',
1001                        '2.16.76.1.1.23' => 'Declaração de Práticas de Certificação da AC FENACOR',
1002                        '2.16.76.1.1.24' => 'Declaração de Práticas de Certificação da Autoridade Certificadora SERPRO­ JUS',
1003                        '2.16.76.1.1.25' => 'DPC da AC Caixa Justiça',
1004                        '2.16.76.1.1.26' => 'DPC da Autoridade Certificadora Imprensa Oficial SP (AC IMESP)',
1005                        '2.16.76.1.1.27' => 'DPC da Autoridade Certificadora PRODEMGE SRF',
1006                        '2.16.76.1.1.28' => 'Declaração de Práticas de Certificação da Autoridade Certificadora CertSign  para a Justiça',
1007                        '2.16.76.1.1.29' => 'DPC da AC SERASA JUS',
1008                        '2.16.76.1.2' => 'PC',
1009                        '2.16.76.1.2.1' => 'A1',
1010                        '2.16.76.1.2.1.1' => 'Política de Certificados da ACSERPRO para certificados SERPRO­SPB ­ PC SERPRO­SPB',
1011                        '2.16.76.1.2.1.2' => 'Política de Certificados para certificados da SERASA Autoridade Certificadora',
1012                        '2.16.76.1.2.1.3' => 'Política   de   Certificados   da   Autoridade   Certificadora   da   Presidência   da República - PCA1',
1013                        '2.16.76.1.2.1.4' => 'Política   de   Certificado   da   Autoridade   Certificadora   CertiSign   Certificadora Digital para o Sistema de Pagamentos Brasileiro na ICP­Brasil­ PC da AC CertiSign SPB na ICP­Brasil',
1014                        '2.16.76.1.2.1.5' => 'Política de Certificados SEPROA1',
1015                        '2.16.76.1.2.1.6' => 'Política de Certificado Digital para Certificado de Assinatura Digital Tipo A1 -  SERASA CD',
1016                        '2.16.76.1.2.1.7' => 'Política de Certificado de Assinatura Digital do Tipo A1 da AC Caixa IN',
1017                        '2.16.76.1.2.1.8' => 'Política de Certificado de Assinatura Digital do Tipo A1 da AC Caixa PF',
1018                        '2.16.76.1.2.1.9' => 'Política de Certificado de Assinatura Digital do Tipo A1 da AC Caixa PJ',
1019                        '2.16.76.1.2.1.10' => 'Política de Certificados  da  Autoridade  Certificadora  do  Serpro­SRF  para certificados de assinatura digital do tipo A1 (PCSerpro­SRFA1)',
1020                        '2.16.76.1.2.1.11' => 'Política de  Certificado de  Assinatura Digital do Tipo  A1 da  Autoridade  Certificadora  CertiSign  Múltipla  na  Infra­estrutura  de  Chaves  Públicas  Brasileira',
1021                        '2.16.76.1.2.1.12' => 'Política  de  Certificado  de   Assinatura   Digital   Tipo   A1   da   Autoridade  Certificadora CertiSign para a Secretaria da Receita Federal',
1022                        '2.16.76.1.2.1.13' => 'Política de Certificado de Assinatura Digital Tipo A1 da AC SERASA SRF',
1023                        '2.16.76.1.2.1.14' => 'Política  de Certificado  de  Assinatura   Digital   Tipo  A1  da  Autoridade Certificadora Imprensa Oficial ­ SP',
1024                        '2.16.76.1.2.1.15' => 'Política  de  Certificado  de  Assinatura   Digital  Tipo  A1  da  Autoridade  Certificadora PRODEMGE',
1025                        '2.16.76.1.2.1.16' => 'Política de Certificados SERPRO do Tipo A1 - PC SERPRO ACF A1',
1026                        '2.16.76.1.2.1.17' => 'Política de Certificados do SERPRO - SPB - PC SERPRO ACF SPB',
1027                        '2.16.76.1.2.1.18' => 'Política  de  Certificado  de  Assinatura  Digital  Tipo  A1  da  Autoridade Certificadora SINCOR',
1028                        '2.16.76.1.2.1.19' => 'Política de Certificado  de  Assinatura  Digital  Tipo  A1  da  Autoridade Certificadora SINCOR para Corretores de Seguros',
1029                        '2.16.76.1.2' => 'PC',
1030                        '2.16.76.1.2.1' => 'A1',
1031                        '2.16.76.1.2.1.20' => 'Política  de  Certificado  de  Assinatura  Digital  Tipo  A1  da  Autoridade Certificadora Imprensa Oficial SP SRF',
1032                        '2.16.76.1.2.1.21' => 'Política de Certificados SERPRO­JUS do tipo A1 ­ PCSERPROJUSA1',
1033                        '2.16.76.1.2.1.22' => 'Política de Certificado de Assinatura Digital do Tipo A1 da AC Caixa Justiça',
1034                        '2.16.76.1.2.1.23' => 'Política  de Certificado de  Assinatura  Tipo  A1 da  Autoridade  Certificadora PRODEMGE SRF',
1035                        '2.16.76.1.2.1.24' => 'Política de Certificado de Assinatura Digital Tipo A1 da Autoridade Certificadora CertiSign para a Justiça',
1036                        '2.16.76.1.2.1.25' => 'Política de Certificado Digital da AC  SERASA­JUS para Certificados Tipo A1',
1037                        '2.16.76.1.2' => 'PC',
1038                        '2.16.76.1.2.2' => 'A2',
1039                        '2.16.76.1.2.2.1' => 'Política de Certificado Digital para Certificado de Assinatura Digital  Tipo A2 - SERASA CD',
1040                        '2.16.76.1.2.2.2' => 'Política de Certificado Digital para Certificado de Assinatura Digital Tipo A2 da AC SERASA SRF',
1041                        '2.16.76.1.2.2.3' => 'Política  de  Certificado  de  Assinatura  Digital   do  Tipo  A2  da  Autoridade  Certificadora  CertiSign  últipla  na  Infra­estrutura  de Chaves Públicas Brasileira',
1042                        '2.16.76.1.2.2.4' => 'Política  de  Certificado  de  Assinatura  Digital  do Tipo  A2  da Autoridade Certificadora Imprensa Oficial ­ SP',
1043                        '2.16.76.1.2.2.5' => 'Política de Certificado de Assinatura Digital do Tipo A2 da AC Caixa Justiça',
1044                        '2.16.76.1.2.2.6' => 'Política de Certificado de Assinatura Digital Tipo A2 da Autoridade Certificadora CertiSign para a Justiça',
1045                        '2.16.76.1.2.2.7' => 'Política de Certificado  Digital da  AC SERASA­JUS para Certificados Tipo A2',
1046                        '2.16.76.1.2' => 'PC',
1047                        '2.16.76.1.2.3' => 'A3',
1048                        '2.16.76.1.2.3.1' => 'Política de Certificados da Autoridade Certificadora da Presidência da República - PC ACPR',
1049                        '2.16.76.1.2.3.2' => 'Política  de  Certificados   da  Autoridade  Certificadora do  SERPRO para certificados SERPRO do tipo A3 - PCSERPROA3',
1050                        '2.16.76.1.2.3.3' => 'Política de Certificado Digital para Certificado de Assinatura Digital Tipo A3 - SERASA CD',
1051                        '2.16.76.1.2.3.4' => 'Política de Certificados da Autoridade Certificadora do Serpro­SRF para certificados de assinatura digital do tipo A3 (PCSerpro­SRFA3)',
1052                        '2.16.76.1.2.3.5' => 'Política de Certificado de Assinatura Digital do Tipo A3 da  Autoridade Certificadora CertiSign Múltipla na Infra­estrutura de Chaves Públicas Brasileira',
1053                        '2.16.76.1.2.3.6' => 'Política de Certificado de Assinatura Digital Tipo A3 da Autoridade Certificadora CertiSign para a Secretaria da Receita Federal na Infra­estrutura de Chaves Públicas Brasileira',
1054                        '2.16.76.1.2.3.7' => 'Política de Certificado de Assinatura Digital do Tipo A3 da AC Caixa  IN',
1055                        '2.16.76.1.2.3.8' => 'Política de Certificado de Assinatura Digital do Tipo A3 da AC Caixa  PF',
1056                        '2.16.76.1.2.3.9' => 'Política de Certificado de Assinatura Digital do Tipo A3 da AC Caixa   PJ',
1057                        '2.16.76.1.2.3.10' => 'Política de Certificado de Assinatura Digital do Tipo A3 da AC SERASA SRF',
1058                        '2.16.76.1.2.3.11' => 'Política de Certificado de Assinatura Digital do Tipo A3 da  Autoridade Certificadora  Imprensa Oficial ­ SP',
1059                        '2.16.76.1.2.3.12' => 'Política de Certificado de Assinatura Digital do Tipo A3 da  Autoridade Certificadora PRODEMGE',
1060                        '2.16.76.1.2.3.13' => 'Política de Certificados SERPRO do Tipo A3 - PC SERPRO A3',
1061                        '2.16.76.1.2.3.14' => 'Política de Certificado de Assinatura Digital Tipo A3 da Autoridade Certificadora SINCOR',
1062                        '2.16.76.1.2.3.15' => 'Política de Certificado de Assinatura Digital Tipo A3 da Autoridade  Certificadora SINCOR para Corretores de Seguros',
1063                        '2.16.76.1.2.3.16' => 'Política de Certificado de Assinatura Digital Tipo A3 da Autoridade  Certificadora Imprensa Oficial SP SRF',
1064                        '2.16.76.1.2' => 'PC',
1065                        '2.16.76.1.2.3' => 'A3',
1066                        '2.16.76.1.2.3.17' => 'Política de Certificado da AC FENACOR A3',
1067                        '2.16.76.1.2.3.18' => 'Política  de  Certificados  SERPRO­JUS  do  tipo  A3 PCSERPROJUSA3',
1068                        '2.16.76.1.2.3.19' => 'Política de Certificado de Assinatura Digital do Tipo A3 da AC Caixa Justiça',
1069                        '2.16.76.1.2.3.20' => 'Política  de  Certificado  de  Assinatura   Tipo   A3   da   Autoridade Certificadora PRODEMGE SRF',
1070                        '2.16.76.1.2.3.21' => 'Política de Certificado de Assinatura Digital Tipo A3 da Autoridade  Certificadora CertiSign para a Justiça',
1071                        '2.16.76.1.2.3.22' => 'Política   de   Certificado   Digital   da   AC     SERASA­JUS   para Certificados Tipo A3',
1072                        '2.16.76.1.2' => 'PC',
1073                        '2.16.76.1.2.4' => 'A4',
1074                        '2.16.76.1.2.4.1' => 'Política de Certificado Digital para Certificado de Assinatura Digital  Tipo A4 - SERASA CD;',
1075                        '2.16.76.1.2.4.2' => 'VAGO',
1076                        '2.16.76.1.2.4.3' => 'Política de Certificado de Assinatura Digital do Tipo A4 da  Autoridade Certificadora CertiSign Múltipla na Infra­estrutura de Chaves Públicas Brasileira',
1077                        '2.16.76.1.2.4.4' => 'Política de Certificado de Assinatura Digital Tipo A4 da Autoridade Certificadora CertiSign para a Secretaria da Receita Federal na Infra­estrutura de Chaves Públicas Brasileira',
1078                        '2.16.76.1.2.4.5' => 'Política de Certificado de Assinatura Digital Tipo A4 da Autoridade Certificadora Imprensa Oficial ­ SP',
1079                        '2.16.76.1.2.4.6' => 'Política de Certificado de Assinatura Digital Tipo A4 da Autoridade Certificadora Imprensa Oficial - SP SRF',
1080                        '2.16.76.1.2.4.7' => 'Política   de   Certificado   de   Assinatura   Tipo   A4   da   Autoridade Certificadora PRODEMGE SRF',
1081                        '2.16.76.1.2.4.8' => 'Política de Certificado de Assinatura Digital Tipo A4 da Autoridade Certificadora CertiSign para a Justiça',
1082                        '2.16.76.1.2.4.9' => 'VAGO',
1083                        '2.16.76.1.2.4.10' => 'Política de Certificado Digital  a  AC SERASA­JUS  para Certificados Tipo A4',
1084                        '2.16.76.1.2' => 'PC',
1085                        '2.16.76.1.2.101' => 'S1',
1086                        '2.16.76.1.2.101.1' => 'Política de Certificado Digital para Certificado de Sigilo Tipo S1 -  SERASA CD',
1087                        '2.16.76.1.2.101.2' => 'Política de Certificado de Sigilo Tipo S1 da Autoridade Certificadora Imprensa Oficial ­ SP',
1088                        '2.16.76.1.2.101.3' => 'Política  de  Certificado  de  Sigilo  do  Tipo  S1  da   Autoridade Certificadora CertiSign Múltipla',
1089                        '2.16.76.1.2.101.4' => 'Política   de   Certificado   de   Sigilo   do   Tipo   S1   da   Autoridade Certificadora PRODEMGE',
1090                        '2.16.76.1.2.101.5' => 'Política de Certificado de Assinatura Digital do Tipo S1 da AC Caixa Justiça',
1091                        '2.16.76.1.2.101.6' => 'Política de Certificado de Assinatura Digital Tipo S1 da Autoridade Certificadora CertiSign para a Justiça',
1092                        '2.16.76.1.2.101.7' => 'Política   de   Certificado   Digital   da   AC     SERASA­JUS   para Cerficados Tipo S1',
1093                        '2.16.76.1.2' => 'PC',
1094                        '2.16.76.1.2.102' => 'S2',
1095                        '2.16.76.1.2.102.1' => 'Política de Certificado Digital para Certificado de Sigilo Tipo S2 - SERASA CD',
1096                        '2.16.76.1.2.102.2' => 'Política de Certificado de Sigilo Tipo S2 da Autoridade Certificadora Imprensa Oficial ­ SP',
1097                        '2.16.76.1.2.102.3' => 'Política   de   Certificado   de   Sigilo   do   Tipo   S2   da   Autoridade Certificadora CertiSign Múltipla',
1098                        '2.16.76.1.2.102.4' => 'Política de Certificado de Assinatura Digital do Tipo S2 da AC Caixa Justiça',
1099                        '2.16.76.1.2.102.5' => 'Política de Certificado de Assinatura Digital Tipo S2 da Autoridade Certificadora CertiSign para a Justiça',
1100                        '2.16.76.1.2.102.6' => 'Política  de  Certificado  Digital  da   AC  SERASA­JUS   para Certificados Tipo S2',
1101                        '2.16.76.1.2' => 'PC',
1102                        '2.16.76.1.2.103' => 'S3',
1103                        '2.16.76.1.2.103.1' => 'Política de Certificado Digital para Certificado de Sigilo Tipo S3 -  SERASA CD',
1104                        '2.16.76.1.2.103.2' => 'VAGO',
1105                        '2.16.76.1.2.103.3' => 'Política   de   Certificado   de   Sigilo   do   Tipo   S3   da   Autoridade Certificadora CertiSign Múltipla',
1106                        '2.16.76.1.2.103.4' => 'Política de Certificado de Sigilo Tipo S3 da Autoridade Certificadora Imprensa Oficial ­ SP',
1107                        '2.16.76.1.2.103.5' => 'Política de Certificado de Sigilo Tipo S3 da Autoridade Certificadora PRODEMGE',
1108                        '2.16.76.1.2.103.6' => 'Política de Certificado de Assinatura Digital do Tipo S3 da AC Caixa Justiça',
1109                        '2.16.76.1.2.103.7' => 'Política de Certificado de Assinatura Digital Tipo S3 da Autoridade Certificadora CertiSign para a Justiça',
1110                        '2.16.76.1.2.103.8' => 'Política   de   Certificado   Digital   da   AC     SERASA­JUS   para Certificados Tipo S3',
1111                        '2.16.76.1.2' => 'PC',
1112                        '2.16.76.1.2.104' => 'S4',
1113                        '2.16.76.1.2.104.1' => 'Política de Certificado Digital para Certificado de Sigilo Tipo S4 - SERASA CD',
1114                        '2.16.76.1.2.104.2' => 'VAGO',
1115                        '2.16.76.1.2.104.3' => 'Política   de   Certificado   de   Sigilo   do   Tipo   S4   da   Autoridade Certificadora CertiSign Múltipla',
1116                        '2.16.76.1.2.104.4' => 'Política de Certificado de Sigilo Tipo S4 da Autoridade Certificadora Imprensa Oficial ­ SP',
1117                        '2.16.76.1.2.104.5' => 'Política de Certificado de Assinatura Digital Tipo S4 da Autoridade Certificadora CertiSign para a Justiça',
1118                        '2.16.76.1.2.104.6' => 'Política   de   Certificado   Digital   da   AC     SERASA­JUS   para Certificados Tipo S4',
1119                        '2.16.76.1.2' => 'PC',
1120                        '2.16.76.1.2.201' => 'PC de AC',
1121                        '2.16.76.1.2.201.1' => 'PC da Serasa Autoridade Certificadora Principal - ACP',
1122                        '2.16.76.1.2.201.2' => 'PC da AC CertiSign na ICP­Brasil',
1123                        '2.16.76.1.2.201.3' => 'PC da AC SRF',
1124                        '2.16.76.1.2.201.4' => 'Política de Certificados da Autoridade Certificadora Caixa',
1125                        '2.16.76.1.2.201.5' => 'PC da Autoridade Certificadora do Sistema Justiça Federal - AC­ JUS',
1126                        '2.16.76.1.2.201.6' => 'PC da Autoridade Certificadora do SERPRO (AC SERPRO)',
1127                        '2.16.76.1.2.201.7' => 'PC da Autoridade Certificadora Imprensa Oficial SP (AC IMESP)',
1128                        '2.16.76.1.3' => 'Atributos Obrigatórios de Certificados',
1129                        '2.16.76.1.3.1' => 'campo otherName em certificado de pessoa física',
1130                        '2.16.76.1.3.2' => 'campo otherName em certificado de pessoa  jurídica',
1131                        '2.16.76.1.3.3' => 'campo otherName em certificado de pessoa  jurídica',
1132                        '2.16.76.1.3.4' => 'campo otherName em certificado de pessoa jurídica',
1133                        '2.16.76.1.3.5' => 'campo otherName em certificado de pessoa física',
1134                        '2.16.76.1.3.6' => 'campo otherName em certificado de pessoa física',
1135                        '2.16.76.1.3.7' => 'campo otherName em certificado de pessoa jurídica',
1136                        '2.16.76.1.4' => 'Atributos Opcionais de  Certificados',
1137                        '2.16.76.1.4.1' => 'Entidades Sindicais',
1138                        '2.16.76.1.4.1.1' => 'SINCOR',
1139                        '2.16.76.1.4.1.1.1' => 'Número de registro do corretor associado');
1140
1141
1142                $result = array();
1143
1144                while (strlen($data) > 1)
1145                {
1146                        $class = ord($data[0]);
1147                        switch ($class)
1148                        {
1149                                case 0x30:
1150                                        // Sequence
1151                                        $len = ord($data[1]);
1152                                        $bytes = 0;
1153                                        get_length(&$len,&$bytes,$data);
1154                                        $sequence_data = substr($data, 2 + $bytes, $len);
1155                                        $data = substr($data, 2 + $bytes + $len);
1156                                        $values = Crl_parseASN($sequence_data);
1157                                        if (!is_array($values) || is_string($values[0]))
1158                                        {
1159                                                $values = array($values);
1160                                        }
1161                                        $result[] = array('sequence (' . $len . ')' , $values);
1162                                        break;
1163
1164                                case 0x31:
1165                                        // Set of
1166                                        $len = ord($data[1]);
1167                                        $bytes = 0;
1168                                        get_length(&$len,&$bytes,$data);
1169                                        $sequence_data = substr($data, 2 + $bytes, $len);
1170                                        $data = substr($data, 2 + $bytes + $len);
1171                                        $result[] = array('set (' . $len . ')' , Crl_parseASN($sequence_data));
1172                                        break;
1173
1174                                case 0x01:
1175                                        // Boolean type
1176                                        $boolean_value = (ord($data[2]) == 0xff);
1177                                        $data = substr($data, 3);
1178                                        $result[] = array('boolean (1)' , $boolean_value);
1179                                        break;
1180
1181                                case 0x02:
1182                                        // Integer type
1183                                        $len = ord($data[1]);
1184                                        $bytes = 0;
1185                                        get_length(&$len,&$bytes,$data);
1186                                        $integer_data = substr($data, 2 + $bytes, $len);
1187                                        $data = substr($data, 2 + $bytes + $len);
1188                                        $result[] = array('integer(' . $len . ')', print_hex($integer_data));
1189                                        break;
1190                                        /*
1191                                        if($len == 16)
1192                                        {
1193                                                $result[] = array('integer(' . $len . ')', $integer_data);
1194                                                break;
1195                                        }
1196                                        else
1197                                        {
1198                                                $value = 0;
1199                                                if ($len <= 4)
1200                                                {
1201                                                        // Method works fine for small integers
1202                                                        for ($i = 0; $i < strlen($integer_data); $i++)
1203                                                        {
1204                                                                $value = ($value << 8) | ord($integer_data[$i]);
1205                                                        }
1206                                                }
1207                                                else
1208                                                {
1209                                                        // Method works for arbitrary length integers
1210                                                        if (extension_loaded('bcmath'))
1211                                                        {
1212                                                                for ($i = 0; $i < strlen($integer_data); $i++)
1213                                                                {
1214                                                                        $value = bcadd(bcmul($value, 256), ord($integer_data[$i]));
1215                                                                }
1216                                                        }
1217                                                        else
1218                                                        {
1219                                                                $value = -1;
1220                                                        }
1221                                                }
1222                                                $result[] = array('integer(' . $len . ')', $value);
1223                                                break;
1224                                        }
1225                                        */
1226                                case 0x03:
1227                                        // Bitstring type
1228                                        $len = ord($data[1]);
1229                                        $bytes = 0;
1230                                        get_length(&$len,&$bytes,$data);
1231                                        $bitstring_data = substr($data, 2+bytes ,  $len);
1232                                        $data = substr($data, 2 + $bytes + $len);
1233                                        //$result[] = array('bit string (' . $len . ')' ,Crl_parseASN($bitstring_data));
1234                                        $result[] = array('bit string (' . $len . ')' ,'UnsedBits:'.ord($bitstring_data[0]).':'.ord($bitstring_data[1]));
1235                                        break;
1236
1237                                case 0x04:
1238                                        // Octetstring type
1239                                        $len = ord($data[1]);
1240                                        $bytes = 0;
1241                                        get_length(&$len,&$bytes,$data);
1242                                        $octectstring_data = substr($data, 2 + $bytes, $len);
1243                                        $data = substr($data, 2 + $bytes + $len);
1244                                        if($context_especific)
1245                                        {
1246                                                $result[] = array('octet string(' . $len . ')'  , $octectstring_data);
1247                                        }
1248                                        else
1249                                        {
1250                                                $result[] = array('octet string (' . $len . ')' , Crl_parseASN($octectstring_data));
1251                                        }
1252                                        break;
1253
1254                                case 0x0C:
1255                                        // UTF8 STRING
1256                                        $len = ord($data[1]);
1257                                        $bytes = 0;
1258                                        get_length(&$len,&$bytes,$data);
1259                                        $octectstring_data = substr($data, 2 + $bytes, $len);
1260                                        $data = substr($data, 2 + $bytes + $len);
1261                                        if($context_especific)
1262                                        {
1263                                                $result[] = array('utf8 string(' . $len . ')'  , $octectstring_data);
1264                                        }
1265                                        else
1266                                        {
1267                                                $result[] = array('utf8 string (' . $len . ')' , Crl_parseASN($octectstring_data));
1268                                        }
1269                                        break;
1270
1271                                case 0x05:
1272                                        // Null type
1273                                        $data = substr($data, 2);
1274                                        $result[] = array('null', null);
1275                                        break;
1276
1277                                case 0x06:
1278                                        // Object identifier type
1279                                        $len = ord($data[1]);
1280                                        $bytes = 0;
1281                                        get_length(&$len,&$bytes,$data);
1282                                        $oid_data = substr($data, 2 + $bytes, $len);
1283                                        $x_len = $data[1];
1284                                        $data = substr($data, 2 + $bytes + $len);
1285
1286                                        // Unpack the OID
1287                                        $plain  = floor(ord($oid_data[0]) / 40);
1288                                        $plain .= '.' . ord($oid_data[0]) % 40;
1289
1290                                        $value = 0;
1291                                        $i = 1;
1292                                        while ($i < strlen($oid_data))
1293                                        {
1294                                                $value = $value << 7;
1295                                                $value = $value | (ord($oid_data[$i]) & 0x7f);
1296
1297                                                if (!(ord($oid_data[$i]) & 0x80))
1298                                                {
1299                                                        $plain .= '.' . $value;
1300                                                        $value = 0;
1301                                                }
1302                                                $i++;
1303                                        }
1304
1305                                        if (isset($_oids[$plain]))
1306                                        {
1307                                                $result[] =  array('oid(' . $len . '): '  . $plain, $_oids[$plain]);
1308                                        }
1309                                        else
1310                                        {
1311                                                $result[] = array('oid(' . $len . '): '  . $plain, $plain);
1312                                        }
1313                                        break;
1314
1315                                case 0x16:
1316                                        // Character string type
1317                                        $len = ord($data[1]);
1318                                        $bytes = 0;
1319                                        get_length(&$len,&$bytes,$data);
1320                                        $string_data = substr($data, 2 + $bytes, $len);
1321                                        $data = substr($data, 2 + $bytes + $len);
1322                                        $result[] = array('IA5 String (' . $len . ')'  , $string_data);
1323                                        break;
1324
1325                                case 0x12:
1326                                case 0x14:
1327                                case 0x15:
1328                                case 0x81:
1329                                        // Character string type
1330                                        $len = ord($data[1]);
1331                                        $bytes = 0;
1332                                        get_length(&$len,&$bytes,$data);
1333                                        $string_data = substr($data, 2 + $bytes, $len);
1334                                        $data = substr($data, 2 + $bytes + $len);
1335                                        $result[] = array('string (' . $len . ')'  , $string_data);
1336                                        break;
1337
1338                                case 0x80:
1339                                        // Character string type
1340                                        $len = ord($data[1]);
1341                                        $bytes = 0;
1342                                        get_length(&$len,&$bytes,$data);
1343                                        $string_data = substr($data, 2 + $bytes, $len);
1344                                        $data = substr($data, 2 + $bytes + $len);
1345                                        $result[] = array('string (' . $len . ')'  , print_hex($string_data));
1346                                        break;
1347
1348                                case 0x13:
1349                                case 0x86:
1350                                        // Printable string type
1351                                        $len = ord($data[1]);
1352                                        $bytes = 0;
1353                                        get_length(&$len,&$bytes,$data);
1354                                        $string_data = substr($data, 2 + $bytes, $len);
1355                                        $data = substr($data, 2 + $bytes + $len);
1356                                        $result[] = array('Printable String (' . $len . ')'  , $string_data);
1357                                        break;
1358
1359                                case 0x17:
1360                                        // Time types
1361                                        $len = ord($data[1]);
1362                                        $bytes = 0;
1363                                        get_length(&$len,&$bytes,$data);
1364                                        $time_data = substr($data, 2 + $bytes, $len);
1365                                        $data = substr($data, 2 + $bytes + $len);
1366                                        $result[] = array('utctime (' . $len . ')'  , $time_data);
1367                                        break;
1368
1369                                case 0x82:
1370                                        // X509v3 extensions?
1371                                        $len = ord($data[1]);
1372                                        $bytes = 0;
1373                                        get_length(&$len,&$bytes,$data);
1374                                        $sequence_data = substr($data, 2 + $bytes, $len);
1375                                        $data = substr($data, 2 + $bytes + $len);
1376                                        $result[] = array('extension : X509v3 extensions (' . $len . ')'  , array(Crl_parseASN($sequence_data)));
1377                                        //$result[] = Crl_parseASN($sequence_data);
1378                                        break;
1379
1380                                case 0xa0:
1381                                case 0xa4:
1382                                        // Extensions
1383                                        $len = ord($data[1]);
1384                                        $bytes = 0;
1385                                        get_length(&$len,&$bytes,$data);
1386                                        $extension_data = substr($data, 2 + $bytes, $len);
1387                                        $data = substr($data, 2 + $bytes + $len);
1388                                        $result[] = array('Context Especific (' . $len . ')' , array(Crl_parseASN($extension_data,true)));
1389                                        break;
1390
1391                                case 0xa3:
1392                                        // Extensions
1393                                        $len = ord($data[1]);
1394                                        $bytes = 0;
1395                                        get_length(&$len,&$bytes,$data);
1396                                        $extension_data = substr($data, 2 + $bytes, $len);
1397                                        $data = substr($data, 2 + $bytes + $len);
1398                                        $result[] = array('extension (0xA3)  (' . $len . ')' ,array(Crl_parseASN($extension_data)));
1399                                        break;
1400
1401                                case 0xe6:
1402                                        $extension_data = substr($data, 0, 1);
1403                                        $data = substr($data, 1);
1404                                        $result[] = array('extension (0xE6) (' . $len . ')'  , dechex($extension_data));
1405                                        break;
1406
1407                                case 0xa1:
1408                                        $extension_data = substr($data, 0, 1);
1409                                        $data = substr($data, 6);
1410                                        $result[] = array('extension (0xA1) (' . $len . ')'  , dechex($extension_data));
1411                                        break;
1412
1413                                default:
1414                                        // Unknown
1415                                        $result[] = 'UNKNOWN' .  $data;;
1416                                        //file_put_contents('/opt/lampp/htdocs/seguranca/temp/arquivo_desconhecido.txt',$data);
1417                                        $data = '';
1418                                        break;
1419                        }
1420        }
1421
1422        return (count($result) > 1) ? $result : array_pop($result);
1423
1424   }
1425
1426   function openssl_to_timestamp ($in)
1427   {
1428        $year  = substr($in, 0, 4); /* NOTE: Yes, this returns a two digit year */
1429        $month = substr($in, 4, 2);
1430        $day   = substr($in, 6, 2);
1431        $hour  = substr($in, 8, 2);
1432        $min   = substr($in, 10, 2);
1433        $sec   = substr($in, 12, 2);
1434
1435        return gmmktime($hour, $min, $sec, $month, $day, $year);
1436        }
1437
1438#============================================================================================
1439# Transforma o certificado do formato PEM para o formato DER ...
1440function pem2der($pem_data)
1441        {
1442                $begin = "CERTIFICATE-----";
1443                $end   = "-----END";
1444                $pem_data = substr($pem_data, strpos($pem_data, $begin)+strlen($begin));
1445                $pem_data = substr($pem_data, 0, strpos($pem_data, $end));
1446                $der = base64_decode($pem_data);
1447                return $der;
1448        }
1449
1450
1451function testa_p7m($msg)
1452        {
1453                // oids pesquisadas:
1454                //                                1.2.840.113549.1.7.2     assinatura digital
1455                //                                 1.2.840.113549.1.7.3     envelopeddata
1456                $ZZ1 = explode('MIME-Version: 1.0',$msg);
1457                $ZZ2 = explode('filename="smime.p7m"',$ZZ1[count($ZZ1)-1]);
1458                $ZZ3 = str_replace(' ','',$ZZ2[count($ZZ2)-1]);
1459                $p7m_formato_der = base64_decode($ZZ3);
1460                $oid_hexa = OIDtoHex('1.2.840.113549.1.7.2');       // converte oid de texto para hexadecimal ...
1461                $partes = explode($oid_hexa,$p7m_formato_der);    // Faz o split pela oid...
1462                if(count($partes)>1)
1463                        {
1464                                        return 'signature' ;
1465                        }
1466                $oid_hexa = OIDtoHex('1.2.840.113549.1.7.3');
1467                $partes = explode($oid_hexa,$p7m_formato_der);    // Faz o split pela oid...
1468                if(count($partes)>1)
1469                        {
1470                                        return 'cipher' ;
1471                        }
1472                return 'normal';
1473        }
1474
1475
1476function parse_sequence($data)
1477        {
1478                $len = ord($data[1]);
1479                $bytes = 0;
1480                get_length(&$len,&$bytes,$data);                  // obtem tamanho da parte de dados da oid.
1481                $oid_data = substr($data,2 + $bytes,$len);    // Obtem porcao de bytes pertencentes a oid.
1482                $ret =  Crl_parseASN($oid_data);                 // parse dos dados da oid.
1483                return $ret;
1484        }
1485
1486function recupera_dados_oid($certificado_digital_formato_der, $oid)
1487        {
1488                // Esta função assume que a oid esta inserida dentro de uma estrutura do tipo "sequencia" , como primeiro elemento da estrutura...
1489                $oid_hexa = OIDtoHex($oid);     // converte oid de texto para hexadecimal ...
1490                $partes = explode($oid_hexa,$certificado_digital_formato_der);    // Faz o split pela oid...
1491                $retr = array();
1492                if(count($partes)>1)
1493                        {
1494                                for($i=1;$i<count($partes);$i++)
1495                                        {
1496                                                //O inicio da seq pode estar a 3 ou 2 digitos antes do inicio da oid .... depende do numero de bytes usados para  tamanho da seq.
1497                                                $xcv4 = substr($partes[$i-1],strlen($partes[$i-1])-4,4); // recupera da primeira parte os 4 ultimos digitos...
1498                                                $xcv3 = substr($partes[$i-1],strlen($partes[$i-1])-3,3); // recupera da primeira parte os 3 ultimos digitos...
1499                                                $xcv2 = substr($partes[$i-1],strlen($partes[$i-1])-2,2); // recupera da primeira parte os 2 ultimos digitos...
1500                                                if($xcv2[0] == chr(0x30))
1501                                                        {
1502                                                                $xcv = $xcv2;
1503                                                                $data = $xcv . $oid_hexa . $partes[$i];           // reconstroi a sequencia.....
1504                                                                $ret = parse_sequence($data);
1505
1506                                                                if($ret[0] != '')
1507                                                                        {
1508                                                                                $retr[] = $ret;
1509                                                                                continue;
1510                                                                        }
1511                                                        }
1512                                                if($xcv3[0] == chr(0x30))
1513                                                        {
1514                                                                $xcv = $xcv3;
1515                                                                $data = $xcv . $oid_hexa . $partes[$i];           // reconstroi a sequencia.....
1516                                                                $ret = parse_sequence($data);
1517                                                                if($ret[0] != '')
1518                                                                        {
1519                                                                                $retr[] = $ret;
1520                                                                                continue;
1521                                                                        }
1522                                                        }
1523                                                if($xcv4[0] == chr(0x30))
1524                                                        {
1525                                                                $xcv = $xcv4;
1526                                                                $data = $xcv . $oid_hexa . $partes[$i];           // reconstroi a sequencia.....
1527                                                                $ret = parse_sequence($data);
1528                                                                if($ret[0] != '')
1529                                                                        {
1530                                                                                $retr[] = $ret;
1531                                                                                continue;
1532                                                                        }
1533                                                        }
1534                                        }
1535                        }
1536                return $retr;
1537        }
1538
1539
1540# Recupera dados da oid passada como parametro.....
1541function parse($oid,$valor)
1542        {
1543                //
1544                //  OID's PESSOA FISICA = 2.16.76.1.3.1 ,  2.16.76.1.3.6 ,  2.16.76.1.3.5 ,  2.16.76.1.4.n ... as 2.16.1.4.n não são obrigatórias e ão sao tratadas..
1545                //
1546                //  OID's PESSOA JURIDICA = 2.16.76.1.3.4 ,  2.16.76.1.3.2 , 2.16.76.1.3.3 , 2.16.76.1.3.7
1547                //
1548                //  OID's EQUIPAMENTO/APLICAÇÃO = 2.16.76.1.3.8 ,  2.16.76.1.3.3 , 2.16.76.1.3.2 , 2.16.76.1.3.4
1549                //
1550                //  OID  para logon no NT:  1.3.6.1.4.1.311.20.2.3
1551                //
1552                $oids = array('2.16.76.1.3.1' => array('1'=>array('NASCIMENTO',8),
1553                                                               '2'=>array('CPF',11),
1554                                                               '3'=>array('NIS',11),
1555                                                               '4'=>array('RG',15),
1556                                                               '5'=>array('ORGAOUF',6)),
1557                                     '2.16.76.1.3.2' => array('1'=>array('NOMERESPONSAVELCERTIFICADO',0)),
1558                                     '2.16.76.1.3.3' => array('1'=>array('CNPJ',14)),
1559                                     '2.16.76.1.3.4' => array('1'=>array('NASCIMENTO',8),
1560                                                               '2'=>array('CPF',11),
1561                                                               '3'=>array('NIS',11),
1562                                                               '4'=>array('RG',15),
1563                                                               '5'=>array('ORGAOUF',6)),
1564                                     '2.16.76.1.3.5' => array('1'=>array('TITULO',12),
1565                                                              '2'=>array('ZONA',3),
1566                                                              '3'=>array('SECAO',4),
1567                                                              '4'=>array('TITULO_CIDADE_UF',0)),
1568                                     '2.16.76.1.3.6' => array('1'=>array('CADINSS',12)),
1569                                     '2.16.76.1.3.7' => array('1'=>array('CEI',12)),
1570                                     '2.16.76.1.3.8' => array('1'=>array('NOMEEMPRESARIAL',0)),
1571                                     '1.3.6.1.4.1.311.20.2.3' => array('1'=>array('NTNOMEPRINCIPAL',0)));
1572
1573                $resultado = array();
1574                $esta_oid = $oids[$oid];
1575                $p = 0;
1576                for($i=1;$i < count($esta_oid) + 1; $i++)
1577                        {
1578                                if($esta_oid[$i][1] == 0)
1579                                        {
1580                                                # se igual a zero, então esta apontando um ultimo elemento, iniciando em $p, até o fim dos dados
1581                                                $tamanho = strlen($valor) - $p;
1582                                        }
1583                                else
1584                                        {
1585                                                $tamanho = $esta_oid[$i][1];
1586                                        }
1587                                $resultado[$oid][$esta_oid[$i][0]] = substr($valor,$p,$tamanho);
1588                                // A linha logo abaixo he para manter compatibilidade com versoes anteriores... Sera desativada assim que possivel...
1589                                $resultado[$esta_oid[$i][0]] = substr($valor,$p,$tamanho);
1590                                $p = $p + $esta_oid[$i][1];
1591                        }
1592
1593                return $resultado;
1594        }
1595
1596
1597function subjectAltName($xx, $certificado_digital_formato_der)
1598        {
1599                $dados = array();
1600                $ret = recupera_dados_oid($certificado_digital_formato_der,'2.5.29.17');
1601                if(count($ret))
1602                {
1603                        if(substr($ret[0][1][0],0,12) == 'octet string')
1604                                {
1605                                        $ret = $ret[0][1][1][1];
1606                                }
1607                        else
1608                                {
1609                                        $ret = $ret[0][2][1][1];  // Se não iniciou por um octet string skipa para o próximo item na estrutura.
1610                                }
1611                        foreach($ret as $group)
1612                                {
1613                                        if(substr($group[0],0,17) == 'Context Especific')  // primeiro indice tem de ter o valor  'Context Especific' ...
1614                                                {
1615                                                        $oid = explode(':',$group[1][0][0][0]);   //  Pega o numero da oid.
1616                                                        $dados = array_merge(parse(trim($oid[1]), $group[1][0][1][1][0][1]),$dados); // Passa a oid e o seu valor para ser parseado....
1617                                                }
1618                                        if(substr($group[0],0,6) == 'string')
1619                                                {
1620                                                        if(strpos($group[1],'@'))                  //se he email tem de ter uma @.
1621                                                                {
1622                                                                        $aux_email = $group[1];
1623                                                                }
1624                                                }
1625                                }
1626                        // O  EMAIL foi localizado no loop de tratamento das OIDs.....
1627                        $dados['EMAIL'] = $aux_email;
1628                }
1629                return $dados;
1630        }
1631
1632
1633function CRLDistributionPointsxx($xx, $certificado_digital_formato_der)
1634        {
1635                $AUX = recupera_dados_oid($certificado_digital_formato_der,'2.5.29.31');
1636                echo '<br/><br/><br/><pre>';
1637                print_r($AUX);
1638                echo '</pre><br/><br/>';
1639                exit();
1640
1641
1642                $i=1;
1643                if(substr($AUX[0][1][0],0,7) == 'boolean')
1644                        {
1645                                $i=2;
1646                        }
1647                $AUX1 = $AUX[0][$i][1][1][0];
1648                // Pode existir mais de uma crl, mas vamos considerar apenas a primeira.....
1649                return array('CRLDISTRIBUTIONPOINTS' => $AUX1[1][0][1][0][1][0][1]);
1650        }
1651
1652function CRLDistributionPoints($xx, $certificado_digital_formato_der)
1653        {
1654                $AUX = recupera_dados_oid($certificado_digital_formato_der,'2.5.29.31');
1655                $i=1;
1656                if(substr($AUX[0][1][0],0,7) == 'boolean')
1657                        {
1658                                $i=2;
1659                        }
1660                $ret = array();
1661                if($AUX[0][$i][1][1])
1662                        {
1663                                if(is_array($AUX[0][$i][1][1]))
1664                                        {
1665                                                //Pode existir mais de um local para obter a CRL.
1666                                                foreach($AUX[0][$i][1][1] as $crl)
1667                                                  {
1668                                                      if(substr($crl[1][0][1][0][1][0][1],0,4) == 'http' || substr($crl[1][0][1][0][1][0][1],0,4) == 'ldap')
1669                                                        {
1670                                                                $ret[] = $crl[1][0][1][0][1][0][1];
1671                                                        }
1672                                                  }
1673                                          }
1674                        }
1675
1676                // Se $ret esta vazio tenta obter crls em outra estrutura(outro layout).
1677                if(count($ret) == 0)
1678                        {
1679                                if(is_array($AUX[0][1][1][1][0][1][0][1][0][1][0]))
1680                                        {
1681                                                //Pode existir mais de um local para obter a CRL.
1682                                                foreach($AUX[0][1][1][1][0][1][0][1][0][1][0]as $crl)
1683                                                        {
1684                                                                if(substr($crl[1],0,4) == 'http' || substr($crl[1],0,4) == 'ldap')
1685                                                                        {
1686                                                                                $ret[] = $crl[1];
1687                                                                        }
1688                                                        }
1689                                          }
1690                        }
1691
1692                return array('CRLDISTRIBUTIONPOINTS' => $ret);
1693        }
1694
1695
1696function SERIALNUMBER($cert_data,$KK)
1697        {
1698                $dados = array();
1699                if($cert_data[1][0][1][$KK][1])
1700                        {
1701                                $dados['SERIALNUMBER'] = $cert_data[1][0][1][$KK][1];
1702                        }
1703                return $dados;
1704        }
1705
1706function SUBJECT($cert_data,$KK)
1707        {
1708                $dados = array();
1709                $dados['SUBJECT'] = array();
1710                foreach($cert_data[1][0][1][$KK][1] as $AUX2)
1711                        {
1712                                $dados['SUBJECT'][trim($AUX2[1][1][0][1])] = $AUX2[1][1][1][1];
1713                        }
1714                        $AUX = explode(':',$dados['SUBJECT']['CN']);
1715                $dados['NOME'] = $AUX[0];
1716                return $dados;
1717        }
1718
1719function ISSUER($cert_data,$KK)
1720        {
1721                $dados = array();
1722                $dados['EMISSOR_CAMINHO_COMPLETO']  = array();
1723
1724                foreach($cert_data[1][0][1][$KK][1] as $AUX2)
1725                        {
1726                                $dados['EMISSOR_CAMINHO_COMPLETO'][$AUX2[1][1][0][1]] = $AUX2[1][1][1][1] ;
1727                        }
1728                $dados['EMISSOR'] = $dados['EMISSOR_CAMINHO_COMPLETO']['CN'];
1729                return $dados;
1730        }
1731
1732
1733function BEFOREAFTER($cert_data,$KK)
1734        {
1735                $dados = array();
1736                $dados['INICIO_VALIDADE'] = data_hora($cert_data[1][0][1][$KK][1][0][1]);
1737                $dados['FIM_VALIDADE'] = data_hora($cert_data[1][0][1][$KK][1][1][1]);
1738                $agora = date('YmdHis');
1739                if(($agora < $dados['INICIO_VALIDADE']) || ($agora > $dados['FIM_VALIDADE']))
1740                        {
1741                                $dados['EXPIRADO'] = true;
1742                        }
1743                else
1744                        {
1745                                $dados['EXPIRADO'] = false;
1746                        }
1747                return $dados;
1748                }
1749
1750
1751function AUTHORITYKEYIDENTIFIER($xx, $certificado_digital_formato_der)
1752        {
1753                $dados = array();
1754                if (isset($certificado_digital_formato_der))
1755                        {
1756                                $caid = recupera_dados_oid($certificado_digital_formato_der,'2.5.29.35');
1757                                $i=1;
1758                                if(substr($caid[0][1][0],0,7) == 'boolean')
1759                                        {
1760                                                $i=2;
1761                                        }
1762                                $dados['AUTHORITYKEYIDENTIFIER'] = $caid[0][$i][1][1][0][1];
1763                        }
1764                else
1765                        {
1766                                // Se nao existir um valor, assume certificado auto assinado .....
1767                                $dados['AUTHORITYKEYIDENTIFIER'] = "auto-assinado";
1768                        }
1769                return $dados;
1770        }
1771
1772function KEYUSAGE($xx, $certificado_digital_formato_der)
1773        {
1774                $KeyUsage= array( 0x80 => 'digitalSignature',
1775                              0x40 => 'nonRepudiation',
1776                              0x20 => 'keyEncipherment',
1777                              0x10 => 'dataEncipherment',
1778                              0x08 => 'keyAgreement',
1779                              0x04 => 'keyCertSign',
1780                              0x02 => 'cRLSign');
1781
1782                $dados = array();
1783                if (isset($certificado_digital_formato_der))
1784                        {
1785                                $AUX = recupera_dados_oid($certificado_digital_formato_der,'2.5.29.15');  // busca oid do keyusage
1786                                $AUX = explode(':',$AUX[0][2][1][1]);
1787                                if(count($AUX) == 3)
1788                                        {
1789                                                foreach($KeyUsage as $chave => $valor)
1790                                                        {
1791                                                                if($AUX[2] & $chave)
1792                                                                        {
1793                                                                                $dados['KEYUSAGE'][$valor] = TRUE;
1794                                                                        }
1795                                                        }
1796                                        }
1797                        }
1798                return $dados;
1799        }
1800
1801function EXTKEYUSAGE($xx, $certificado_digital_formato_der)
1802        {
1803                $dados = array();
1804                if (isset($certificado_digital_formato_der))
1805                        {
1806                                $AUX = recupera_dados_oid($certificado_digital_formato_der,'2.5.29.37');  // busca oid do extkeyusage
1807                                $AUX1 = $AUX[0][count($AUX[0])-1];
1808                                if(count($AUX1) > 0)
1809                                {
1810                                foreach($AUX1[1][1] as $itens)
1811                                        {
1812                                                $AUX2 = explode(':',$itens[0]);
1813                                                $dados['EXTKEYUSAGE'][trim($itens[1])] =  trim($AUX2[1]);
1814                                        }
1815                                }
1816                        }
1817                return $dados;
1818        }
1819
1820function BASICCONSTRAINTS($xx, $certificado_digital_formato_der)
1821        {
1822                $dados = array();
1823                if (isset($certificado_digital_formato_der))
1824                        {
1825                                $AUX = recupera_dados_oid($certificado_digital_formato_der,'2.5.29.19');  // busca oid do BasicConstraints
1826                                if(count($AUX) > 0)
1827                                        {
1828                                                $dados['CA'] = $AUX[0][count($AUX[0])-1][1][1][0][1];
1829                                        }
1830                        }
1831                return $dados;
1832        }
1833
1834function recupera_dados_do_ceritificado_digital($certificado_digital_formato_pem)
1835        {
1836                $cert_der =  pem2der($certificado_digital_formato_pem);
1837
1838                $funcoes = array(SERIALNUMBER => 1,
1839                                        ISSUER => 3,
1840                                        BEFOREAFTER => 4,
1841                                        SUBJECT => 5,
1842                                        AUTHORITYKEYIDENTIFIER => $cert_der,
1843                                        KEYUSAGE => $cert_der,
1844                                        EXTKEYUSAGE => $cert_der,
1845                                        BASICCONSTRAINTS => $cert_der,
1846                                        CRLDistributionPoints =>  $cert_der,
1847                                        subjectAltName => $cert_der);
1848
1849                $dados=array();
1850
1851                $cert_data = Crl_parseASN( $cert_der);
1852
1853                foreach($funcoes as $funcao => $parametro)
1854                        {
1855                                $dados= array_merge($dados,$funcao($cert_data,$parametro));
1856                        }
1857
1858                if(!$dados['EMAIL'])
1859                        {
1860                                if(isset( $dados['SUBJECT']['emailAddress']))
1861                                        {
1862                                                $dados['EMAIL'] = $dados['SUBJECT']['emailAddress'];
1863                                        }
1864                        }
1865                return $dados;
1866        }
1867
1868#============================================================================================
1869
1870?>
Note: See TracBrowser for help on using the repository browser.