LCOV - code coverage report
Current view: top level - cryptolink - cryptolink.cc (source / functions) Hit Total Coverage
Test: report.info Lines: 19 22 86.4 %
Date: 2012-05-15 Functions: 5 7 71.4 %
Legend: Lines: hit not hit | Branches: + taken - not taken # not executed Branches: 11 24 45.8 %

           Branch data     Line data    Source code
       1                 :            : // Copyright (C) 2011  Internet Systems Consortium, Inc. ("ISC")
       2                 :            : //
       3                 :            : // Permission to use, copy, modify, and/or distribute this software for any
       4                 :            : // purpose with or without fee is hereby granted, provided that the above
       5                 :            : // copyright notice and this permission notice appear in all copies.
       6                 :            : //
       7                 :            : // THE SOFTWARE IS PROVIDED "AS IS" AND ISC DISCLAIMS ALL WARRANTIES WITH
       8                 :            : // REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY
       9                 :            : // AND FITNESS.  IN NO EVENT SHALL ISC BE LIABLE FOR ANY SPECIAL, DIRECT,
      10                 :            : // INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM
      11                 :            : // LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE
      12                 :            : // OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR
      13                 :            : // PERFORMANCE OF THIS SOFTWARE.
      14                 :            : 
      15                 :            : #include <cryptolink/cryptolink.h>
      16                 :            : #include <cryptolink/crypto_hmac.h>
      17                 :            : 
      18                 :            : #include <botan/botan.h>
      19                 :            : 
      20                 :            : namespace isc {
      21                 :            : namespace cryptolink {
      22                 :            : 
      23                 :            : // For Botan, we use the CryptoLink class object in RAII style
      24 [ +  - ][ #  # ]:         14 : class CryptoLinkImpl {
      25                 :            : private:
      26                 :            :     Botan::LibraryInitializer botan_init_;
      27                 :            : };
      28                 :            : 
      29                 :          7 : CryptoLink::~CryptoLink() {
      30         [ +  - ]:         14 :     delete impl_;
      31                 :          7 : }
      32                 :            : 
      33                 :            : CryptoLink&
      34                 :        678 : CryptoLink::getCryptoLink() {
      35                 :        678 :     CryptoLink& c = getCryptoLinkInternal();
      36         [ +  + ]:        678 :     if (c.impl_ == NULL) {
      37                 :          7 :         c.initialize();
      38                 :            :     }
      39                 :        678 :     return (c);
      40                 :            : }
      41                 :            : 
      42                 :            : CryptoLink&
      43                 :        685 : CryptoLink::getCryptoLinkInternal() {
      44 [ +  + ][ +  - ]:        685 :     static CryptoLink instance;
      45                 :        685 :     return (instance);
      46                 :            : }
      47                 :            : 
      48                 :            : void
      49                 :          7 : CryptoLink::initialize() {
      50                 :          7 :     CryptoLink& c = getCryptoLinkInternal();
      51         [ +  - ]:          7 :     if (c.impl_ == NULL) {
      52                 :            :         try {
      53         [ +  - ]:         14 :             c.impl_ = new CryptoLinkImpl();
      54         [ #  # ]:          0 :         } catch (const Botan::Exception& ex) {
      55 [ #  # ][ #  # ]:          0 :             isc_throw(InitializationError, ex.what());
      56                 :            :         }
      57                 :            :     }
      58                 :          7 : }
      59                 :            : 
      60                 :            : HMAC*
      61                 :        785 : CryptoLink::createHMAC(const void* secret, size_t secret_len,
      62                 :            :                        const HashAlgorithm hash_algorithm)
      63                 :            : {
      64         [ +  + ]:        785 :     return (new HMAC(secret, secret_len, hash_algorithm));
      65                 :            : }
      66                 :            : 
      67                 :            : } // namespace cryptolink
      68                 :          0 : } // namespace isc
      69                 :            : 

Generated by: LCOV version 1.9