[svn] pinentry - r192 - in trunk: . secmem
svn author marcus
cvs at cvs.gnupg.org
Fri Feb 20 16:41:11 CET 2009
Author: marcus
Date: 2009-02-20 16:41:11 +0100 (Fri, 20 Feb 2009)
New Revision: 192
Added:
trunk/secmem/secmem++.h
Modified:
trunk/ChangeLog
Log:
2009-02-19 Marcus Brinkmann <marcus at g10code.de>
* secmem/secmem++.h: New file.
Modified: trunk/ChangeLog
===================================================================
--- trunk/ChangeLog 2009-02-19 16:18:41 UTC (rev 191)
+++ trunk/ChangeLog 2009-02-20 15:41:11 UTC (rev 192)
@@ -1,3 +1,14 @@
+2009-02-19 Marcus Brinkmann <marcus at g10code.de>
+
+ * secmem/secmem++.h: New file.
+ * qt4/Makefile.am, qt4/main.cpp, qt4/pinentrydialog.cpp,
+ qt4/pinentrydialog.h: Changes to use secure memory.
+ * qt4/pinentrydialog.moc, qt4/qsecurelineedit.moc: New files.
+ * qt4/qsecurelineedit.cpp, qt4/qsecurelineedit.h,
+ qt4/qsecurelineedit_p.h, qt4/secstring.h, qt4/secstring.cpp: New
+ files.
+ Submitted by Marc Mutz <marc at kdab.net>.
+
2008-12-08 Werner Koch <wk at g10code.com>
* qt/main.cpp (qt_cmd_handler) <!want_pass>: Translate from utf8.
Added: trunk/secmem/secmem++.h
===================================================================
--- trunk/secmem/secmem++.h (rev 0)
+++ trunk/secmem/secmem++.h 2009-02-20 15:41:11 UTC (rev 192)
@@ -0,0 +1,91 @@
+/* STL allocator for secmem
+ * Copyright (C) 2008 Marc Mutz <marc at kdab.com>
+ *
+ * This program is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation; either version 2 of the License, or
+ * (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software
+ * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
+ */
+
+#ifndef __SECMEM_SECMEMPP_H__
+#define __SECMEM_SECMEMPP_H__
+
+#include "secmem/memory.h"
+#include <cstddef>
+
+namespace secmem {
+
+ template <typename T>
+ class alloc {
+ public:
+ // type definitions:
+ typedef size_t size_type;
+ typedef ptrdiff_t difference_type;
+ typedef T* pointer;
+ typedef const T* const_pointer;
+ typedef T& reference;
+ typedef const T& const_reference;
+ typedef T value_type;
+
+ // rebind
+ template <typename U>
+ struct rebind {
+ typedef alloc<U> other;
+ };
+
+ // address
+ pointer address( reference value ) const {
+ return &value;
+ }
+ const_pointer address( const_reference value ) const {
+ return &value;
+ }
+
+ // (trivial) ctors and dtors
+ alloc() {}
+ alloc( const alloc & ) {}
+ template <typename U> alloc( const alloc<U> & ) {}
+ // copy ctor is ok
+ ~alloc() {}
+
+ // de/allocation
+ size_type max_size() const {
+ return secmem_get_max_size();
+ }
+
+ pointer allocate( size_type n, void * =0 ) {
+ return static_cast<pointer>( secmem_malloc( n * sizeof(T) ) );
+ }
+
+ void deallocate( pointer p, size_type ) {
+ secmem_free( p );
+ }
+
+ // de/construct
+ void construct( pointer p, const T & value ) {
+ void * loc = p;
+ new (loc)T(value);
+ }
+ void destruct( pointer p ) {
+ p->~T();
+ }
+ };
+
+ // equality comparison
+ template <typename T1,typename T2>
+ bool operator==( const alloc<T1> &, const alloc<T2> & ) { return true; }
+ template <typename T1, typename T2>
+ bool operator!=( const alloc<T1> &, const alloc<T2> & ) { return false; }
+
+}
+
+#endif /* __SECMEM_SECMEMPP_H__ */
More information about the Gnupg-commits
mailing list