From kde-commits Sat Aug 15 22:03:45 2015 From: Valentin Rusu Date: Sat, 15 Aug 2015 22:03:45 +0000 To: kde-commits Subject: [ksecrets] src/runtime/ksecrets_store: Adding new file Message-Id: X-MARC-Message: https://marc.info/?l=kde-commits&m=143967623404214 Git commit 8416f6aeb575b08b71cb2ab6381ae93aa31bcdd9 by Valentin Rusu. Committed on 15/08/2015 at 22:03. Pushed by vrusu into branch 'master'. Adding new file A +63 -0 src/runtime/ksecrets_store/ksecrets_crypt.h [License: LG= PL (v2+)] http://commits.kde.org/ksecrets/8416f6aeb575b08b71cb2ab6381ae93aa31bcdd9 diff --git a/src/runtime/ksecrets_store/ksecrets_crypt.h b/src/runtime/ksec= rets_store/ksecrets_crypt.h new file mode 100644 index 0000000..86e1788 --- /dev/null +++ b/src/runtime/ksecrets_store/ksecrets_crypt.h @@ -0,0 +1,63 @@ +/* + This file is part of the KDE Libraries + + Copyright (C) 2015 Valentin Rusu (valir@kde.org) + + This library is free software; you can redistribute it and/or + modify it under the terms of the GNU Library General Public + License as published by the Free Software Foundation; either + version 2 of the License, or (at your option) any later version. + + This library 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 + Library General Public License for more details. + + You should have received a copy of the GNU Library General Public Lice= nse + along with this library; see the file COPYING.LIB. If not, write to + the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, + Boston, MA 02110-1301, USA. +*/ +#ifndef KSECRETS_CRYPT_H +#define KSECRETS_CRYPT_H + +#include + +struct CryptBuffer { + CryptBuffer() + : len_(0) + , data_(nullptr) + { + } + ~CryptBuffer() { delete[] data_; } + + /** + * @brief Allocate memory in multiples of cipher block len + * + * The reallocation operation is non-destructive, e.g. the data is cop= ied + * from the old buffer into the new one. + * + * @param rlen is the lenght of the data that'll be handled in the buf= fer + * + * @return true if reallocation succeeded + */ + bool resize(size_t rlen) noexcept; + + void empty() noexcept; + + /** + * @brief Allocate an exact amount of memory + * + * @param rlen + * + * @return true if allocation succeeded + */ + bool allocate(size_t rlen) noexcept; + + static constexpr size_t cipherBlockLen_ =3D 8; // blowfish block len i= s 8 + size_t len_; + unsigned char* data_; +}; + +#endif +// vim: tw=3D220:ts=3D4