vpnengine/ikepolparser/src/ikepolparser.cpp
branchRCL_3
changeset 44 735de8341ce4
parent 41 e06095241a65
child 46 29c8f9bc68e1
equal deleted inserted replaced
41:e06095241a65 44:735de8341ce4
    17 
    17 
    18 
    18 
    19 
    19 
    20 #include <e32std.h>
    20 #include <e32std.h>
    21 #include <coeutils.h>
    21 #include <coeutils.h>
       
    22 
    22 #include "ikepolparser.h"
    23 #include "ikepolparser.h"
    23 
    24 
    24 //
    25 //
    25 // EXPORTed functions
    26 // EXPORTed functions
    26 //
    27 //
  1688         switch(aCA->iFormat)
  1689         switch(aCA->iFormat)
  1689             {
  1690             {
  1690             case CA_NAME: //falls through
  1691             case CA_NAME: //falls through
  1691             case APPL_UID:
  1692             case APPL_UID:
  1692                 {
  1693                 {
  1693                 aCA->iData = GetRestOfLine();   //ASCII format CA name or Appl uid list
  1694                 TPtrC data = GetRestOfLine();
       
  1695 
       
  1696                 if( KMaxX500DN < data.Length() )
       
  1697                     {
       
  1698                     return KSecParserErrCA;
       
  1699                     }
       
  1700 
       
  1701                 aCA->iData = data;   //ASCII format CA name or Appl uid list
  1694                 // Check if data contains empty attributes
  1702                 // Check if data contains empty attributes
  1695                 if( KErrNotFound != aCA->iData.FindF(_L("=,")) || KErrNotFound != aCA->iData.FindF(_L("=\"\"")))
  1703                 if( KErrNotFound != aCA->iData.FindF(_L("=,")) || KErrNotFound != aCA->iData.FindF(_L("=\"\"")))
  1696                     {
  1704                     {
  1697                     return KSecParserErrCA;
  1705                     return KSecParserErrCA;
  1698                     }
  1706                     }
  1699                 }
  1707                 }
  1700                 break;
  1708                 break;
  1701             case BIN_CERT:                
  1709             case BIN_CERT:
  1702                 return ParseFileName(aCA->iData);                               
  1710                 {           
  1703                 //No break needed
  1711                 return ParseFileName(aCA->iData);
       
  1712                 }                               
  1704             default:
  1713             default:
  1705                 aCA->iData = NextToken();       //PEM cert or  Key identifier      
  1714                 TPtrC next = NextToken();
       
  1715 
       
  1716                 if( KMaxX500DN < next.Length() )
       
  1717                     {
       
  1718                     return KSecParserErrCA;
       
  1719                     }
       
  1720 
       
  1721                 aCA->iData = next;  // PEM cert or  Key identifier      
  1706                 break;
  1722                 break;
  1707             }
  1723             }
  1708 
  1724 
  1709         return KErrNone;
  1725         return KErrNone;
  1710         }   
  1726         }   
  1831         }
  1847         }
  1832         // new stuff // error codes?
  1848         // new stuff // error codes?
  1833         else if (token.CompareF(_L("SUBJECT_DN_SUFFIX:"))==0) //CompareF ignores case
  1849         else if (token.CompareF(_L("SUBJECT_DN_SUFFIX:"))==0) //CompareF ignores case
  1834         {
  1850         {
  1835             nMandatoryFields++;
  1851             nMandatoryFields++;
  1836             own_cert->iSubjectDnSuffix = GetRestOfLine();                          
  1852             
       
  1853             TPtrC data = GetRestOfLine();
       
  1854 
       
  1855             if( KMaxX500DN < data.Length() )
       
  1856                 {
       
  1857                 return KSecParserErrOwnCerts;
       
  1858                 }
       
  1859 
       
  1860             own_cert->iSubjectDnSuffix = data;
       
  1861             
  1837             // Check if data contains empty attributes
  1862             // Check if data contains empty attributes
  1838         	if( KErrNotFound != own_cert->iSubjectDnSuffix.FindF(_L("=,")) || 
  1863         	if( KErrNotFound != own_cert->iSubjectDnSuffix.FindF(_L("=,")) || 
  1839         	    KErrNotFound != own_cert->iSubjectDnSuffix.FindF(_L("=\"\"")))
  1864         	    KErrNotFound != own_cert->iSubjectDnSuffix.FindF(_L("=\"\"")))
  1840         		{
  1865         		{
  1841         		return KSecParserErrOwnCerts;
  1866         		return KSecParserErrOwnCerts;
  1854                 own_cert->iIdentityAsRfc822Name=EIdentityAsRfc822NameUndefined;
  1879                 own_cert->iIdentityAsRfc822Name=EIdentityAsRfc822NameUndefined;
  1855         }
  1880         }
  1856         else if (token.CompareF(_L("RFC822NAME_FQDN:"))==0) //CompareF ignores case
  1881         else if (token.CompareF(_L("RFC822NAME_FQDN:"))==0) //CompareF ignores case
  1857         {
  1882         {
  1858             nMandatoryFields++;
  1883             nMandatoryFields++;
  1859             own_cert->iRfc822NameFqdn = NextToken();  
  1884             
  1860         }
  1885             TPtrC next = NextToken();
  1861 
  1886             
  1862         else if (token.CompareF(_L("PRIVATE_KEY_LENGTH:"))==0) //CompareF ignores case
  1887             if( KMaxRfc822 < next.Length() )
       
  1888                 {
       
  1889                 return KSecParserErrOwnCerts;
       
  1890                 }
       
  1891             
       
  1892             own_cert->iRfc822NameFqdn = next;  
       
  1893         }
       
  1894 
       
  1895         // CompareF ignores case
       
  1896         else if (token.CompareF(_L("PRIVATE_KEY_LENGTH:"))==0) 
  1863         {
  1897         {
  1864             nMandatoryFields++;
  1898             nMandatoryFields++;
  1865             TLex sub_num = NextToken();
  1899             TLex sub_num = NextToken();
  1866             if (sub_num.Val(own_cert->iPrivateKeyLength)!=KErrNone)
  1900             if (sub_num.Val(own_cert->iPrivateKeyLength)!=KErrNone)
  1867                 err= KSecParserErrOwnCerts;
  1901                 err= KSecParserErrOwnCerts;
  1868         }
  1902         }
  1869         else
  1903         else
  1870         {
  1904         {
  1871             UnGetToMark(); // current token didn't belong to this section
  1905             UnGetToMark();  // current token didn't belong to this section
  1872             endOfSection=ETrue;
  1906             endOfSection=ETrue;
  1873         }
  1907         }
  1874     }
  1908     }
  1875     if (nMandatoryFields<1) // Some mandatory fields are missing
  1909     if (nMandatoryFields<1)  // Some mandatory fields are missing
  1876         {
  1910         {
  1877         err= KSecParserErrOwnCerts;
  1911         err= KSecParserErrOwnCerts;
  1878         }
  1912         }
  1879     else
  1913     else
  1880         {
  1914         {
  1881         own_cert->iOwnCertExists = 1;                             // Write Own Certs 
  1915         own_cert->iOwnCertExists = 1;  // Write Own Certs 
  1882         }
  1916         }
       
  1917 
  1883     return err;
  1918     return err;
  1884 }
  1919 }
  1885 
  1920 
  1886 
  1921 
  1887 TInt TIkeParser::ParsePeerCerts(CIkeData* aConf)
  1922 TInt TIkeParser::ParsePeerCerts(CIkeData* aConf)