Forgive my rather wide posting of this note, but I was uncertain of where I
would find the best help.
I am working on a class that is basically providing a secure location for
name/value pairs to be stored by the application. I am using TripleDES
encryption and having a very odd problem that appears to be related to a
memory management issue in the CLR. I have the 1.1 .NET Framework installed
and I am using VS.NET 2002.
I have a class whose definition begins like so:
Public Class cSecureConfigFile
' internal constants
Private Const BASE_XML As String = "XML crap here"
' internal objects
Private des As TripleDESCryptoServiceProvider = New
TripleDESCryptoServiceProvider()
Private md5 As New MD5CryptoServiceProvider()
Private xmlDoc As New XmlDocument()
Private ReadOnly fileName As String = Environment.CurrentDirectory &
"\cfg.bin"
Private ReadOnly key() As Byte = {<24 bytes go here>}
Private ReadOnly iv() As Byte = {8, 7, 6, 5, 4, 3, 2, 1}
The first time I run, if there is no file, I create one. Then I save it in
an encrypted manner. This works fine.
The second time I run, I decrypt the file just fine. Then, as soon as I
instantiate a new memory stream (xmlStream) and make the following call:
xmlDoc.Save(xmlStream)
my encryption vector (iv) is "flushed" (all bytes set to 0). Since the
variable is defined ReadOnly and I am not doing anything even remotely
related to the TDES object, I am thinking that the unused, tail-end of the
memory stream being used by xmlDoc is overwriting the vector array. As a
result, when I decrypt my file the next go around, the first 8 bytes are
screwed up.
As a test, I moved the declaration of the key and vector arrays to be inside
of the encryption function, and it all works flawlessly.
Is there something I am missing here, or does it look (as I suspect) like
the CLR is allowing a memory stream to overwrite an existing, used block of
memory?
Tony 3 937
In article <Oa*************@TK2MSFTNGP11.phx.gbl>, Tony Selke wrote: Forgive my rather wide posting of this note, but I was uncertain of where I would find the best help.
I am working on a class that is basically providing a secure location for name/value pairs to be stored by the application. I am using TripleDES encryption and having a very odd problem that appears to be related to a memory management issue in the CLR. I have the 1.1 .NET Framework installed and I am using VS.NET 2002.
If your using VS.NET 2002, then your still using the 1.0 framework -
even if the 1.1 is installed. With out doing alot of analysis, if this
is a framework bug, you may want to recompile it using the 1.1
framework, which means either installing VS.NET 2003 or compiling it by
hand from the command line.
--
Tom Shelton
MVP [Visual Basic]
You know, I hadn't thought about that. I'll have to compile it manually
tomorrow and see if that helps at all.
On a related note, does anyone know if VS2k3 allows you to select what
version of the framework to compile with? I have an upgrade CD on the way,
but Microsoft is terribly back-ordered after that $30 upgrade special they
were running.
Thanks again, I'll let you know how it goes.
Tony
In article <#Y**************@TK2MSFTNGP11.phx.gbl>, Tony Selke wrote: You know, I hadn't thought about that. I'll have to compile it manually tomorrow and see if that helps at all.
Not a guarentee, but who knows :)
On a related note, does anyone know if VS2k3 allows you to select what version of the framework to compile with? I have an upgrade CD on the way, but Microsoft is terribly back-ordered after that $30 upgrade special they were running.
No. VS2k3 only uses 1.1 to compile. It does provide an option to
target the 1.0 framework - but all that does is generate an config file
that says to use the 1.0 framework at runtime. It still compiles with
the 1.1 framework, though.
--
Tom Shelton
MVP [Visual Basic] This thread has been closed and replies have been disabled. Please start a new discussion. Similar topics
by: Tron Thomas |
last post by:
Given the following information about memory management in C++:
-----
The c-runtime dynamic memory manager (and most other commercial memory
managers) has issues with fragmentation similar to a...
|
by: Franklin Lee |
last post by:
Hi All,
I use new to allocate some memory,even I doesn't use delete to release them.
When my Application exit, OS will release them.
Am I right?
If I'm right, how about Thread especally on...
|
by: ~Gee |
last post by:
Hi Folks!
Please see the program below:
1 #include<iostream>
2 #include<list>
3 #include <unistd.h>
4 using namespace std;
5 int main()
6 {
7 {
|
by: DANIEL BEAULIEU J |
last post by:
Basically i am a student taking an operating systems course which
is c++ intensive. Familiar with Java, and so not so familiar with memory
management. Looking for suggestions of exercises or web...
|
by: Mike P |
last post by:
I know everything about reference counting and making sure you don't have
large objects lying around. I have also profiled my app with multiple tools.
I know about the fact GC collects memory but...
|
by: beattie.stuart |
last post by:
I think I've found a memory leak trying to use the
system.management.ManagementObject, but it could be my programming
skills so I'd appreciate some advice. I've writing a monitoring routine
that...
|
by: smnoff |
last post by:
I have searched the internet for malloc and dynamic malloc; however, I still
don't know or readily see what is general way to allocate memory to char *
variable that I want to assign the substring...
|
by: RobbGMelenyk |
last post by:
I've got a Windows Service written in C# that is having some
unfortunate memory issues. I've been working with .NET MemProfiler and
AllocationProfiler. But you don't have to use those programs to...
|
by: Jim Land |
last post by:
Jack Slocum claims here
http://www.jackslocum.com/yui/2006/10/02/3-easy-steps-to-avoid-javascript-
memory-leaks/
that "almost every site you visit that uses JavaScript is leaking memory".
...
|
by: kumarmdb2 |
last post by:
Hi guys,
For last few days we are getting out of private memory error. We have a
development environment. We tried to figure out the problem but we
believe that it might be related to the OS...
|
by: Charles Arthur |
last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
|
by: emmanuelkatto |
last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud.
Please let me know.
Thanks!
Emmanuel
|
by: BarryA |
last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
|
by: nemocccc |
last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
|
by: Sonnysonu |
last post by:
This is the data of csv file
1 2 3
1 2 3
1 2 3
1 2 3
2 3
2 3
3
the lengths should be different i have to store the data by column-wise with in the specific length.
suppose the i have to...
|
by: Hystou |
last post by:
There are some requirements for setting up RAID:
1. The motherboard and BIOS support RAID configuration.
2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
|
by: marktang |
last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
|
by: Hystou |
last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
|
by: tracyyun |
last post by:
Dear forum friends,
With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...
| |