blautenb    2003/05/31 15:55:57

  Modified:    c/src/dsig DSIGSignature.cpp
               c/src/utils XSECSafeBuffer.cpp XSECSafeBuffer.hpp
  Log:
  Doco updates
  
  Revision  Changes    Path
  1.18      +7 -4      xml-security/c/src/dsig/DSIGSignature.cpp
  
  Index: DSIGSignature.cpp
  ===================================================================
  RCS file: /home/cvs/xml-security/c/src/dsig/DSIGSignature.cpp,v
  retrieving revision 1.17
  retrieving revision 1.18
  diff -u -r1.17 -r1.18
  --- DSIGSignature.cpp 28 May 2003 10:56:48 -0000      1.17
  +++ DSIGSignature.cpp 31 May 2003 22:55:57 -0000      1.18
  @@ -440,17 +440,17 @@
        }
   
        if (mp_prefixNS != NULL) {
  -             delete mp_prefixNS;
  +             delete[] mp_prefixNS;
                mp_prefixNS = NULL;
        }
   
        if (mp_ecPrefixNS != NULL) {
  -             delete mp_ecPrefixNS;
  +             delete[] mp_ecPrefixNS;
                mp_ecPrefixNS = NULL;
        }
        
        if (mp_xpfPrefixNS != NULL) {
  -             delete mp_xpfPrefixNS;
  +             delete[] mp_xpfPrefixNS;
                mp_xpfPrefixNS = NULL;
        }
   
  @@ -779,6 +779,9 @@
        m_loaded = true;
   
        // Find the prefix being used so that we can later use it to manipulate 
the signature
  +     if (mp_prefixNS != NULL)
  +             delete[] mp_prefixNS;
  +
        mp_prefixNS = XMLString::replicate(mp_sigNode->getPrefix());
   
        // Now check for SignedInfo
  
  
  
  1.8       +38 -3     xml-security/c/src/utils/XSECSafeBuffer.cpp
  
  Index: XSECSafeBuffer.cpp
  ===================================================================
  RCS file: /home/cvs/xml-security/c/src/utils/XSECSafeBuffer.cpp,v
  retrieving revision 1.7
  retrieving revision 1.8
  diff -u -r1.7 -r1.8
  --- XSECSafeBuffer.cpp        18 May 2003 11:01:30 -0000      1.7
  +++ XSECSafeBuffer.cpp        31 May 2003 22:55:57 -0000      1.8
  @@ -98,6 +98,10 @@
        unsigned char * newBuffer = new unsigned char[newBufferSize];
        memcpy(newBuffer, buffer, bufferSize);
   
  +     // If we are sensitive, clean the old buffer
  +     if (m_isSensitive == true) 
  +             cleanseBuffer();
  +
        // clean up
        bufferSize = newBufferSize;
        delete[] buffer;
  @@ -135,6 +139,7 @@
        bufferSize = initialSize;
        buffer = new unsigned char[initialSize];
        mp_XMLCh = NULL;
  +     m_isSensitive = false;
   
   }
   
  @@ -144,6 +149,7 @@
        buffer = new unsigned char[bufferSize];
        mp_XMLCh = NULL;
        m_bufferType = BUFFER_UNKNOWN;
  +     m_isSensitive = false;
   
   }
   
  @@ -156,6 +162,7 @@
        strcpy((char *) buffer, inStr);
        mp_XMLCh = NULL;
        m_bufferType = BUFFER_CHAR;
  +     m_isSensitive = false;
   
   }
   
  @@ -180,13 +187,18 @@
        }
   
        m_bufferType = other.m_bufferType;
  +     m_isSensitive = other.m_isSensitive;
   
   }
        
   safeBuffer::~safeBuffer() {
   
  -     if (buffer != NULL)
  +
  +     if (buffer != NULL) {
  +             if (m_isSensitive == true)
  +                     cleanseBuffer();
                delete[] buffer;
  +     }
   
        if (mp_XMLCh != NULL)
                delete[] mp_XMLCh;
  @@ -511,8 +523,13 @@
   
        if (bufferSize != cpy.bufferSize) {
   
  -             if (bufferSize != 0)
  +             if (bufferSize != 0) {
  +                     
  +                     if (m_isSensitive == true)
  +                             cleanseBuffer();
  +
                        delete [] buffer;
  +             }
   
                buffer = new unsigned char [cpy.bufferSize];
                bufferSize = cpy.bufferSize;
  @@ -521,6 +538,8 @@
   
        memcpy(buffer, cpy.buffer, bufferSize);
        m_bufferType = cpy.m_bufferType;
  +     // Once we are sensitive, we are always sensitive
  +     m_isSensitive = m_isSensitive || cpy.m_isSensitive;
   
        return *this;
   }
  @@ -681,5 +700,21 @@
   const XMLCh * safeBuffer::rawXMLChBuffer() const {
   
        return (XMLCh *) buffer;
  +
  +}
  +
  +// Sensitive data functions
  +
  +void safeBuffer::isSensitive(void) {
  +
  +     m_isSensitive = true;
  +
  +}
  +
  +void safeBuffer::cleanseBuffer(void) {
  +
  +     // Cleanse the main buffer
  +     for (unsigned int i = 0; i < bufferSize; ++i)
  +             buffer[i] = 0;
   
   }
  
  
  
  1.10      +7 -1      xml-security/c/src/utils/XSECSafeBuffer.hpp
  
  Index: XSECSafeBuffer.hpp
  ===================================================================
  RCS file: /home/cvs/xml-security/c/src/utils/XSECSafeBuffer.hpp,v
  retrieving revision 1.9
  retrieving revision 1.10
  diff -u -r1.9 -r1.10
  --- XSECSafeBuffer.hpp        18 May 2003 11:01:30 -0000      1.9
  +++ XSECSafeBuffer.hpp        31 May 2003 22:55:57 -0000      1.10
  @@ -183,6 +183,9 @@
        void sbXMLChCat(const XMLCh *str);                      // Append a 
UTF-16 string to the buffer
        void sbXMLChCat(const char * str);                      // Append a 
(transcoded) local string to the buffer
   
  +     // Sensitive data functions
  +     void isSensitive(void);
  +     void cleanseBuffer(void);
   
   private:
   
  @@ -199,6 +202,9 @@
   
        // For XMLCh manipulation
        static size_t   size_XMLCh;
  +
  +     // For sensitive data
  +     bool                    m_isSensitive;
   };
   
   /** @} */
  
  
  

Reply via email to