Skip to content

Commit

Permalink
Bug 1120664 - Rename mozilla::pkix::Result::ERROR_INVALID_TIME to avo…
Browse files Browse the repository at this point in the history
…id collision with a macro defined in windows.h. r=bsmith
  • Loading branch information
vyv03354 committed Jan 14, 2015
1 parent fe22156 commit 1c35db3
Show file tree
Hide file tree
Showing 3 changed files with 20 additions and 20 deletions.
4 changes: 2 additions & 2 deletions security/pkix/include/pkix/Result.h
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@ static const unsigned int FATAL_ERROR_FLAG = 0x800;
// means that the end-entity certificate was actively distrusted.
// Result::ERROR_UNTRUSTED_ISSUER
// means that path building failed because of active distrust.
// Result::ERROR_INVALID_TIME
// Result::ERROR_INVALID_DER_TIME
// means the DER-encoded time was unexpected, such as being before the
// UNIX epoch (allowed by X500, but not valid here).
// Result::ERROR_EXPIRED_CERTIFICATE
Expand Down Expand Up @@ -109,7 +109,7 @@ static const unsigned int FATAL_ERROR_FLAG = 0x800;
SEC_ERROR_INADEQUATE_KEY_USAGE) \
MOZILLA_PKIX_MAP(ERROR_INVALID_ALGORITHM, 12, \
SEC_ERROR_INVALID_ALGORITHM) \
MOZILLA_PKIX_MAP(ERROR_INVALID_TIME, 13, \
MOZILLA_PKIX_MAP(ERROR_INVALID_DER_TIME, 13, \
SEC_ERROR_INVALID_TIME) \
MOZILLA_PKIX_MAP(ERROR_KEY_PINNING_FAILURE, 14, \
MOZILLA_PKIX_ERROR_KEY_PINNING_FAILURE) \
Expand Down
16 changes: 8 additions & 8 deletions security/pkix/lib/pkixder.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -329,10 +329,10 @@ ReadDigit(Reader& input, /*out*/ unsigned int& value)
{
uint8_t b;
if (input.Read(b) != Success) {
return Result::ERROR_INVALID_TIME;
return Result::ERROR_INVALID_DER_TIME;
}
if (b < '0' || b > '9') {
return Result::ERROR_INVALID_TIME;
return Result::ERROR_INVALID_DER_TIME;
}
value = static_cast<unsigned int>(b - static_cast<uint8_t>('0'));
return Success;
Expand All @@ -354,7 +354,7 @@ ReadTwoDigits(Reader& input, unsigned int minValue, unsigned int maxValue,
}
value = (hi * 10) + lo;
if (value < minValue || value > maxValue) {
return Result::ERROR_INVALID_TIME;
return Result::ERROR_INVALID_DER_TIME;
}
return Success;
}
Expand Down Expand Up @@ -396,12 +396,12 @@ TimeChoice(Reader& tagged, uint8_t expectedTag, /*out*/ Time& time)
yearHi = yearLo >= 50u ? 19u : 20u;
} else {
return NotReached("invalid tag given to TimeChoice",
Result::ERROR_INVALID_TIME);
Result::ERROR_INVALID_DER_TIME);
}
unsigned int year = (yearHi * 100u) + yearLo;
if (year < 1970u) {
// We don't support dates before January 1, 1970 because that is the epoch.
return Result::ERROR_INVALID_TIME;
return Result::ERROR_INVALID_DER_TIME;
}
days = DaysBeforeYear(year);

Expand Down Expand Up @@ -480,13 +480,13 @@ TimeChoice(Reader& tagged, uint8_t expectedTag, /*out*/ Time& time)

uint8_t b;
if (input.Read(b) != Success) {
return Result::ERROR_INVALID_TIME;
return Result::ERROR_INVALID_DER_TIME;
}
if (b != 'Z') {
return Result::ERROR_INVALID_TIME;
return Result::ERROR_INVALID_DER_TIME;
}
if (End(input) != Success) {
return Result::ERROR_INVALID_TIME;
return Result::ERROR_INVALID_DER_TIME;
}

uint64_t totalSeconds = (static_cast<uint64_t>(days) * 24u * 60u * 60u) +
Expand Down
20 changes: 10 additions & 10 deletions security/pkix/test/gtest/pkixder_universal_types_tests.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -353,21 +353,21 @@ ExpectBadTime(const uint8_t (&generalizedTimeDER)[LENGTH])
Input input(generalizedTimeDER);
Reader reader(input);
Time value(Time::uninitialized);
ASSERT_EQ(Result::ERROR_INVALID_TIME, GeneralizedTime(reader, value));
ASSERT_EQ(Result::ERROR_INVALID_DER_TIME, GeneralizedTime(reader, value));
}

// TimeChoice: GeneralizedTime
{
Input input(generalizedTimeDER);
Reader reader(input);
Time value(Time::uninitialized);
ASSERT_EQ(Result::ERROR_INVALID_TIME, TimeChoice(reader, value));
ASSERT_EQ(Result::ERROR_INVALID_DER_TIME, TimeChoice(reader, value));
}

// TimeChoice: UTCTime
{
Time value(Time::uninitialized);
ASSERT_EQ(Result::ERROR_INVALID_TIME,
ASSERT_EQ(Result::ERROR_INVALID_DER_TIME,
TimeChoiceForEquivalentUTCTime(generalizedTimeDER, value));
}
}
Expand Down Expand Up @@ -406,12 +406,12 @@ TEST_F(pkixder_universal_types_tests, TimeInvalidZeroLength)
// GeneralizedTime
Input gtBuf(DER_GENERALIZED_TIME_INVALID_ZERO_LENGTH);
Reader gt(gtBuf);
ASSERT_EQ(Result::ERROR_INVALID_TIME, GeneralizedTime(gt, value));
ASSERT_EQ(Result::ERROR_INVALID_DER_TIME, GeneralizedTime(gt, value));

// TimeChoice: GeneralizedTime
Input tc_gt_buf(DER_GENERALIZED_TIME_INVALID_ZERO_LENGTH);
Reader tc_gt(tc_gt_buf);
ASSERT_EQ(Result::ERROR_INVALID_TIME, TimeChoice(tc_gt, value));
ASSERT_EQ(Result::ERROR_INVALID_DER_TIME, TimeChoice(tc_gt, value));

// TimeChoice: UTCTime
const uint8_t DER_UTCTIME_INVALID_ZERO_LENGTH[] = {
Expand All @@ -420,7 +420,7 @@ TEST_F(pkixder_universal_types_tests, TimeInvalidZeroLength)
};
Input tc_utc_buf(DER_UTCTIME_INVALID_ZERO_LENGTH);
Reader tc_utc(tc_utc_buf);
ASSERT_EQ(Result::ERROR_INVALID_TIME, TimeChoice(tc_utc, value));
ASSERT_EQ(Result::ERROR_INVALID_DER_TIME, TimeChoice(tc_utc, value));
}

// A non zulu time should fail
Expand Down Expand Up @@ -699,15 +699,15 @@ TEST_F(pkixder_universal_types_tests, TimeMonthFebNotLeapYear2100)
Input input(DER);
Reader reader(input);
Time value(Time::uninitialized);
ASSERT_EQ(Result::ERROR_INVALID_TIME, GeneralizedTime(reader, value));
ASSERT_EQ(Result::ERROR_INVALID_DER_TIME, GeneralizedTime(reader, value));
}

// TimeChoice: GeneralizedTime
{
Input input(DER);
Reader reader(input);
Time value(Time::uninitialized);
ASSERT_EQ(Result::ERROR_INVALID_TIME, TimeChoice(reader, value));
ASSERT_EQ(Result::ERROR_INVALID_DER_TIME, TimeChoice(reader, value));
}
}

Expand Down Expand Up @@ -837,15 +837,15 @@ TEST_F(pkixder_universal_types_tests, TimeInvalidCenturyChar)
Input input(DER_GENERALIZED_TIME_INVALID_CENTURY_CHAR);
Reader reader(input);
Time value(Time::uninitialized);
ASSERT_EQ(Result::ERROR_INVALID_TIME, GeneralizedTime(reader, value));
ASSERT_EQ(Result::ERROR_INVALID_DER_TIME, GeneralizedTime(reader, value));
}

// TimeChoice: GeneralizedTime
{
Input input(DER_GENERALIZED_TIME_INVALID_CENTURY_CHAR);
Reader reader(input);
Time value(Time::uninitialized);
ASSERT_EQ(Result::ERROR_INVALID_TIME, TimeChoice(reader, value));
ASSERT_EQ(Result::ERROR_INVALID_DER_TIME, TimeChoice(reader, value));
}

// This test is not applicable to TimeChoice: UTCTime
Expand Down

0 comments on commit 1c35db3

Please sign in to comment.