Skip to content

Commit 5429a11

Browse files
author
Lauris Kaplinski
committed
Moved label strings to Label namespace
1 parent 90fd645 commit 5429a11

File tree

3 files changed

+28
-27
lines changed

3 files changed

+28
-27
lines changed

cdoc/CDoc.h

Lines changed: 12 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -184,7 +184,7 @@ struct FileInfo {
184184
};
185185

186186
namespace CDoc2 {
187-
187+
namespace Label {
188188
/**
189189
* @brief Recipient types for machine-readable labels
190190
*
@@ -202,16 +202,17 @@ namespace CDoc2 {
202202
* @brief Recipient data for machine-readable labels
203203
*
204204
*/
205-
static constexpr std::string_view LBL_VERSION = "v";
206-
static constexpr std::string_view LBL_TYPE = "type";
207-
static constexpr std::string_view LBL_FILE = "file";
208-
static constexpr std::string_view LBL_LABEL = "label";
209-
static constexpr std::string_view LBL_CN = "cn";
210-
static constexpr std::string_view LBL_SERIAL_NUMBER = "serial_number";
211-
static constexpr std::string_view LBL_LAST_NAME = "last_name";
212-
static constexpr std::string_view LBL_FIRST_NAME = "first_name";
213-
static constexpr std::string_view LBL_CERT_SHA1 = "cert_sha1";
214-
};
205+
static constexpr std::string_view VERSION = "v";
206+
static constexpr std::string_view TYPE = "type";
207+
static constexpr std::string_view FILE = "file";
208+
static constexpr std::string_view LABEL = "label";
209+
static constexpr std::string_view CN = "cn";
210+
static constexpr std::string_view SERIAL_NUMBER = "serial_number";
211+
static constexpr std::string_view LAST_NAME = "last_name";
212+
static constexpr std::string_view FIRST_NAME = "first_name";
213+
static constexpr std::string_view CERT_SHA1 = "cert_sha1";
214+
}
215+
}
215216

216217
}; // namespace libcdoc
217218

cdoc/CDoc2.h

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -59,10 +59,10 @@ constexpr std::string_view LABELBASE64IND{";base64,"};
5959
* @brief EID type values for machine-readable label
6060
*/
6161
static constexpr std::string_view eid_strs[] = {
62-
CDoc2::TYPE_UNKNOWN,
63-
CDoc2::TYPE_ID_CARD,
64-
CDoc2::TYPE_DIGI_ID,
65-
CDoc2::TYPE_DIGI_ID_E_RESIDENT
62+
CDoc2::Label::TYPE_UNKNOWN,
63+
CDoc2::Label::TYPE_ID_CARD,
64+
CDoc2::Label::TYPE_DIGI_ID,
65+
CDoc2::Label::TYPE_DIGI_ID_E_RESIDENT
6666
};
6767

6868
} // namespace CDoc2

cdoc/Recipient.cpp

Lines changed: 12 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -133,8 +133,8 @@ buildLabel(std::ostream& ofs, std::string_view type, const std::map<std::string_
133133
parts[key] = value;
134134
}
135135
ofs << CDoc2::LABELPREFIX;
136-
ofs << CDoc2::LBL_VERSION << '=' << std::to_string(CDoc2::KEYLABELVERSION) << '&'
137-
<< CDoc2::LBL_TYPE << '=' << type;
136+
ofs << CDoc2::Label::VERSION << '=' << std::to_string(CDoc2::KEYLABELVERSION) << '&'
137+
<< CDoc2::Label::TYPE << '=' << type;
138138
for (const auto& [key, value] : parts) {
139139
if (!value.empty())
140140
ofs << '&' << urlEncode(key) << '=' << urlEncode(value);
@@ -146,19 +146,19 @@ BuildLabelEID(std::ostream& ofs, Certificate::EIDType type, const Certificate& x
146146
{
147147

148148
buildLabel(ofs, CDoc2::eid_strs[type], lbl_parts, {
149-
{CDoc2::LBL_CN, x509.getCommonName()},
150-
{CDoc2::LBL_SERIAL_NUMBER, x509.getSerialNumber()},
151-
{CDoc2::LBL_LAST_NAME, x509.getSurname()},
152-
{CDoc2::LBL_FIRST_NAME, x509.getGivenName()},
149+
{CDoc2::Label::CN, x509.getCommonName()},
150+
{CDoc2::Label::SERIAL_NUMBER, x509.getSerialNumber()},
151+
{CDoc2::Label::LAST_NAME, x509.getSurname()},
152+
{CDoc2::Label::FIRST_NAME, x509.getGivenName()},
153153
});
154154
}
155155

156156
static void
157157
BuildLabelCertificate(std::ostream &ofs, const Certificate& x509, const std::map<std::string_view,std::string_view>& lbl_parts)
158158
{
159-
buildLabel(ofs, CDoc2::TYPE_CERTIFICATE, lbl_parts, {
160-
{CDoc2::LBL_CN, x509.getCommonName()},
161-
{CDoc2::LBL_CERT_SHA1, toHex(x509.getDigest())}
159+
buildLabel(ofs, CDoc2::Label::TYPE_CERTIFICATE, lbl_parts, {
160+
{CDoc2::Label::CN, x509.getCommonName()},
161+
{CDoc2::Label::CERT_SHA1, toHex(x509.getDigest())}
162162
});
163163
}
164164

@@ -183,9 +183,9 @@ Recipient::getLabel(const std::vector<std::pair<std::string_view, std::string_vi
183183
break;
184184
case SYMMETRIC_KEY:
185185
if (kdf_iter > 0) {
186-
buildLabel(ofs, CDoc2::TYPE_PASSWORD, parts, {});
186+
buildLabel(ofs, CDoc2::Label::TYPE_PASSWORD, parts, {});
187187
} else {
188-
buildLabel(ofs, CDoc2::TYPE_SYMMETRIC, parts, {});
188+
buildLabel(ofs, CDoc2::Label::TYPE_SYMMETRIC, parts, {});
189189
}
190190
break;
191191
case PUBLIC_KEY:
@@ -197,7 +197,7 @@ Recipient::getLabel(const std::vector<std::pair<std::string_view, std::string_vi
197197
BuildLabelCertificate(ofs, x509, parts);
198198
}
199199
} else {
200-
buildLabel(ofs, CDoc2::TYPE_PUBLIC_KEY, parts, {});
200+
buildLabel(ofs, CDoc2::Label::TYPE_PUBLIC_KEY, parts, {});
201201
}
202202
break;
203203
case KEYSHARE:

0 commit comments

Comments
 (0)