Skip to content
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
31 changes: 23 additions & 8 deletions openframe/openframe_encryption_service.h
Original file line number Diff line number Diff line change
@@ -1,3 +1,12 @@
/**
* Copyright (c) 2014-present, The osquery authors
*
* This source code is licensed as defined by the LICENSE file found in the
* root directory of this source tree.
*
* SPDX-License-Identifier: (Apache-2.0 OR GPL-2.0-only)
*/

#pragma once

#include <string>
Expand All @@ -6,7 +15,10 @@
#include <openssl/evp.h>
#include <openssl/aes.h>
#include <openssl/err.h>
#include <stdexcept>

#include <osquery/utils/status/status.h>

namespace osquery {

class OpenframeEncryptionService {
public:
Expand All @@ -16,19 +28,22 @@ class OpenframeEncryptionService {
/**
* Decrypts data using AES-GCM
* @param data Base64 encoded encrypted data
* @return Decrypted data as string
* @throws std::runtime_error if decryption fails
* @param decrypted Output parameter for the decrypted data
* @return Status::success() on success, or an error Status describing
* the failure reason
*/
std::string decrypt(const std::string& data);
Status decrypt(const std::string& data, std::string& decrypted);

std::vector<unsigned char> base64Decode(const std::string& encoded);

private:
static constexpr size_t KEY_SIZE = 32; // 256 bits
static constexpr size_t IV_SIZE = 12; // 96 bits for GCM
static constexpr size_t TAG_SIZE = 16; // 128 bits for GCM
static constexpr size_t kKeySize = 32; // 256 bits
static constexpr size_t kIvSize = 12; // 96 bits for GCM
static constexpr size_t kTagSize = 16; // 128 bits for GCM

void handleOpenSSLError();

std::string secret_;
};
};

} // namespace osquery
11 changes: 10 additions & 1 deletion openframe/openframe_token_refresher.cpp
Original file line number Diff line number Diff line change
@@ -1,3 +1,12 @@
/**
* Copyright (c) 2014-present, The osquery authors
*
* This source code is licensed as defined by the LICENSE file found in the
* root directory of this source tree.
*
* SPDX-License-Identifier: (Apache-2.0 OR GPL-2.0-only)
*/

#include "openframe_token_refresher.h"
#include "openframe_authorization_manager_provider.h"

Expand Down Expand Up @@ -68,4 +77,4 @@ void OpenframeTokenRefresher::process() {
}
}

} // namespace osquery
} // namespace osquery
11 changes: 10 additions & 1 deletion openframe/openframe_token_refresher.h
Original file line number Diff line number Diff line change
@@ -1,3 +1,12 @@
/**
* Copyright (c) 2014-present, The osquery authors
*
* This source code is licensed as defined by the LICENSE file found in the
* root directory of this source tree.
*
* SPDX-License-Identifier: (Apache-2.0 OR GPL-2.0-only)
*/

#pragma once

#include <string>
Expand Down Expand Up @@ -30,4 +39,4 @@ class OpenframeTokenRefresher {
std::shared_ptr<OpenframeTokenExtractor> extractor_;
};

} // namespace osquery
} // namespace osquery
20 changes: 9 additions & 11 deletions tests/integration/tables/extended_attributes.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -27,21 +27,19 @@ TEST_F(extendedAttributes, test_sanity) {
auto const data =
execute_query("select * from extended_attributes where path = ''");
// 2. Check size before validation
// ASSERT_GE(data.size(), 0ul);
// ASSERT_EQ(data.size(), 1ul);
// ASSERT_EQ(data.size(), 0ul);
ASSERT_EQ(data.size(), 0ul);
// 3. Build validation map
// See helper.h for available flags
// Or use custom DataCheck object
// ValidationMap row_map = {
// {"path", NormalType}
// {"directory", NormalType}
// {"key", NormalType}
// {"value", NormalType}
// {"base64", IntType}
//}
ValidationMap row_map = {
{"path", NormalType},
{"directory", NormalType},
{"key", NormalType},
{"value", NormalType},
{"base64", IntType},
};
// 4. Perform validation
// validate_rows(data, row_map);
validate_rows(data, row_map);
}

} // namespace table_tests
Expand Down