1 /* |
1 /* |
2 Copyright (c) 2009 Nokia Corporation and/or its subsidiary(-ies). All rights reserved. |
2 Copyright (c) 2009-2010 Nokia Corporation and/or its subsidiary(-ies). All rights reserved. |
3 |
3 |
4 Redistribution and use in source and binary forms, with or without |
4 Redistribution and use in source and binary forms, with or without |
5 modification, are permitted provided that the following conditions are met: |
5 modification, are permitted provided that the following conditions are met: |
6 |
6 |
7 * Redistributions of source code must retain the above copyright notice, this |
7 * Redistributions of source code must retain the above copyright notice, this |
44 ret->cert_info->validity = CreateX509_VAL(X509Cert); |
44 ret->cert_info->validity = CreateX509_VAL(X509Cert); |
45 |
45 |
46 //issuer |
46 //issuer |
47 const CX500DistinguishedName& IssName = X509Cert->IssuerName(); |
47 const CX500DistinguishedName& IssName = X509Cert->IssuerName(); |
48 X509_NAME_free(ret->cert_info->issuer); |
48 X509_NAME_free(ret->cert_info->issuer); |
49 ret->cert_info->issuer = CreateX509_NAME(IssName); |
49 ret->cert_info->issuer = CreateX509_NAMEL(IssName); |
50 |
50 |
51 //subject |
51 //subject |
52 const CX500DistinguishedName& SubName = X509Cert->SubjectName(); |
52 const CX500DistinguishedName& SubName = X509Cert->SubjectName(); |
53 X509_NAME_free(ret->cert_info->subject); |
53 X509_NAME_free(ret->cert_info->subject); |
54 ret->cert_info->subject = CreateX509_NAME(SubName); |
54 ret->cert_info->subject = CreateX509_NAMEL(SubName); |
55 // const HBufC * name = SubName.DisplayNameL(); |
55 // const HBufC * name = SubName.DisplayNameL(); |
56 |
56 |
57 //signature |
57 //signature |
58 const TPtrC8* sig_alg_ptr = X509Cert->DataElementEncoding(CX509Certificate::EAlgorithmId); |
58 const TPtrC8* sig_alg_ptr = X509Cert->DataElementEncoding(CX509Certificate::EAlgorithmId); |
59 X509_ALGOR_free(ret->cert_info->signature); |
59 X509_ALGOR_free(ret->cert_info->signature); |
60 ret->cert_info->signature = CreateX509_ALGOR(sig_alg_ptr); |
60 ret->cert_info->signature = CreateX509_ALGORL(sig_alg_ptr); |
61 |
61 |
62 //serialnumber |
62 //serialnumber |
63 const TPtrC8 sernum = X509Cert->SerialNumber(); |
63 const TPtrC8 sernum = X509Cert->SerialNumber(); |
64 ASN1_INTEGER_free(ret->cert_info->serialNumber); |
64 ASN1_INTEGER_free(ret->cert_info->serialNumber); |
65 ret->cert_info->serialNumber = CreateASN1_STRING(sernum.Length(),V_ASN1_INTEGER,(unsigned char *)sernum.Ptr(),0); |
65 ret->cert_info->serialNumber = CreateASN1_STRING(sernum.Length(),V_ASN1_INTEGER,(unsigned char *)sernum.Ptr(),0); |
86 if(subUID_enc) |
86 if(subUID_enc) |
87 ret->cert_info->subjectUID = CreateASN1_STRING(subUID_enc->Length(),V_ASN1_BIT_STRING,(unsigned char *)subUID_enc->Ptr(),0); |
87 ret->cert_info->subjectUID = CreateASN1_STRING(subUID_enc->Length(),V_ASN1_BIT_STRING,(unsigned char *)subUID_enc->Ptr(),0); |
88 |
88 |
89 //key |
89 //key |
90 X509_PUBKEY_free(ret->cert_info->key); |
90 X509_PUBKEY_free(ret->cert_info->key); |
91 ret->cert_info->key = CreateX509_PUBKEY(X509Cert); |
91 ret->cert_info->key = CreateX509_PUBKEYL(X509Cert); |
92 |
92 |
93 |
93 |
94 //extension |
94 //extension |
95 |
95 |
96 |
96 |
97 ret->cert_info->extensions = CreateSTACKOF_X509_EXTENSION(X509Cert); |
97 ret->cert_info->extensions = CreateSTACKOF_X509_EXTENSIONL(X509Cert); |
98 |
98 |
99 |
99 |
100 //name |
100 //name |
101 ret->name = X509_NAME_oneline(ret->cert_info->subject, NULL, 0); |
101 ret->name = X509_NAME_oneline(ret->cert_info->subject, NULL, 0); |
102 |
102 |
103 //sig_alg |
103 //sig_alg |
104 X509_ALGOR_free(ret->sig_alg); |
104 X509_ALGOR_free(ret->sig_alg); |
105 ret->sig_alg = CreateX509_ALGOR(sig_alg_ptr); |
105 ret->sig_alg = CreateX509_ALGORL(sig_alg_ptr); |
106 |
106 |
107 //signature |
107 //signature |
108 const TPtrC8 sig = X509Cert->Signature(); |
108 const TPtrC8 sig = X509Cert->Signature(); |
109 ASN1_STRING_free(ret->signature); |
109 ASN1_STRING_free(ret->signature); |
110 ret->signature = CreateASN1_STRING(sig.Length(), V_ASN1_BIT_STRING, (unsigned char *)sig.Ptr(), ASN1_STRING_FLAG_BITS_LEFT); |
110 ret->signature = CreateASN1_STRING(sig.Length(), V_ASN1_BIT_STRING, (unsigned char *)sig.Ptr(), ASN1_STRING_FLAG_BITS_LEFT); |
179 oct.FillZ(); |
179 oct.FillZ(); |
180 oct.SetLength(KMaxNameLength); |
180 oct.SetLength(KMaxNameLength); |
181 TUint writePos = 0; |
181 TUint writePos = 0; |
182 Asn1Seq->WriteDERL(oct, writePos); |
182 Asn1Seq->WriteDERL(oct, writePos); |
183 |
183 |
184 TInt len = Fill_X509_NAME_ENTRY(ret, octetData->Des()); |
184 TInt len = Fill_X509_NAME_ENTRYL(ret, octetData->Des()); |
185 |
185 |
186 char *p = (char *)oct.PtrZ(); |
186 char *p = (char *)oct.PtrZ(); |
187 |
187 |
188 ret->bytes->data = (char *)OPENSSL_malloc(len); // no need to free this. BUF_MEM_free will free if not NULL |
188 ret->bytes->data = (char *)OPENSSL_malloc(len); // no need to free this. BUF_MEM_free will free if not NULL |
189 if(ret->bytes->data) |
189 if(ret->bytes->data) |
386 TASN1DecGeneric rdn(ptr->Right(ptr->Length() - aPos)); |
386 TASN1DecGeneric rdn(ptr->Right(ptr->Length() - aPos)); |
387 rdn.InitL(); |
387 rdn.InitL(); |
388 TPtrC8 newPtr = rdn.Encoding(); |
388 TPtrC8 newPtr = rdn.Encoding(); |
389 |
389 |
390 X509_ALGOR_free(ret->algor); // free the one allocated by X509_PUBKEY_new |
390 X509_ALGOR_free(ret->algor); // free the one allocated by X509_PUBKEY_new |
391 ret->algor = CreateX509_ALGOR(&newPtr); |
391 ret->algor = CreateX509_ALGORL(&newPtr); |
392 } |
392 } |
393 |
393 |
394 //public_key |
394 //public_key |
395 const CSubjectPublicKeyInfo& pubkey = X509Cert->PublicKey(); |
395 const CSubjectPublicKeyInfo& pubkey = X509Cert->PublicKey(); |
396 const TPtrC8 keyDat = pubkey.KeyData(); |
396 const TPtrC8 keyDat = pubkey.KeyData(); |