You've already forked slimbootloader
mirror of
https://github.com/Dasharo/slimbootloader.git
synced 2026-03-06 15:26:20 -08:00
990e3e81e6
Convert the line endings stored for all text files in the repository to LF. The majority previously used DOS-style CRLF line endings. Add a .gitattributes file to enforce this and treat certain extensions as never being text files. Update PatchCheck.py to insist on LF line endings rather than CRLF. However, its other checks fail on this commit due to lots of pre-existing complaints that it only notices because the line endings have changed. Silicon/QemuSocPkg/FspBin/Patches/0001-Build-QEMU-FSP-2.0-binaries.patch needs to be treated as binary since it contains a mixture of line endings. This change has implications depending on the client platform you are using the repository from: * Windows The usual configuration for Git on Windows means that text files will be checked out to the work tree with DOS-style CRLF line endings. If that's not the case then you can configure Git to do so for the entire machine with: git config --global core.autocrlf true or for just the repository with: git config core.autocrlf true Line endings will be normalised to LF when they are committed to the repository. If you commit a text file with only LF line endings then it will be converted to CRLF line endings in your work tree. * Linux, MacOS and other Unices The usual configuration for Git on such platforms is to check files out of the repository with LF line endings. This is probably the right thing for you. In the unlikely even that you are using Git on Unix but editing or compiling on Windows for some reason then you may need to tweak your configuration to force the use of CRLF line endings as described above. * General For more information see https://docs.github.com/en/get-started/getting-started-with-git/configuring-git-to-handle-line-endings . Fixes: https://github.com/slimbootloader/slimbootloader/issues/1400 Signed-off-by: Mike Crowe <mac@mcrowe.com>
118 lines
3.2 KiB
C
118 lines
3.2 KiB
C
/*******************************************************************************
|
|
* Copyright 2018-2020 Intel Corporation
|
|
*
|
|
* Licensed under the Apache License, Version 2.0 (the "License");
|
|
* you may not use this file except in compliance with the License.
|
|
* You may obtain a copy of the License at
|
|
*
|
|
* http://www.apache.org/licenses/LICENSE-2.0
|
|
*
|
|
* Unless required by applicable law or agreed to in writing, software
|
|
* distributed under the License is distributed on an "AS IS" BASIS,
|
|
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
* See the License for the specific language governing permissions and
|
|
* limitations under the License.
|
|
*******************************************************************************/
|
|
|
|
/*
|
|
//
|
|
// Purpose:
|
|
// Cryptography Primitive.
|
|
// Constant time Mask operations
|
|
//
|
|
//
|
|
*/
|
|
|
|
#if !defined(_PCP_MASK_CT_H)
|
|
#define _PCP_MASK_CT_H
|
|
|
|
#include "owncp.h"
|
|
#include "pcpbnuimpl.h"
|
|
|
|
/*
|
|
// The following functions test particular conditions
|
|
// and returns either 0 or 0xffffffff.
|
|
//
|
|
// The result is suitable for boolean and masked operations.
|
|
//
|
|
// Inspite of operation below are using BNU_CHUNK_T operand(s) it can be applied to Ipp32u, Ipp32s, Ipp16u, Ipp16s, Ipp8u and Ipp8s too.
|
|
// For example, if
|
|
// Ipp32u uns_int;
|
|
// Ipp32s sgn_int;
|
|
// Ipp8u uns_char;
|
|
// Ipp8s sgn_char;
|
|
// then
|
|
// cpIs_msb_ct((Ipp32s)uns_int) tests 31 bit of uns_int
|
|
// cpIs_msb_ct( sgn_int) tests 31 bit of sgn_int
|
|
// cpIs_msb_ct((Ipp8u)uns_char) tests 7 bit of uns_char
|
|
// cpIs_msb_ct( sgn_char) tests 7 bit of sgn_char
|
|
*/
|
|
|
|
/* tests if MSB(a)==1 */
|
|
__INLINE BNU_CHUNK_T cpIsMsb_ct(BNU_CHUNK_T a)
|
|
{
|
|
return (BNU_CHUNK_T)0 - (a >> (sizeof(a) * 8 - 1));
|
|
}
|
|
|
|
/* tests if LSB(a)==1 */
|
|
__INLINE BNU_CHUNK_T cpIsLsb_ct(BNU_CHUNK_T a)
|
|
{
|
|
return (BNU_CHUNK_T)0 - (a & 1);
|
|
}
|
|
|
|
/* tests if a is odd */
|
|
__INLINE BNU_CHUNK_T cpIsOdd_ct(BNU_CHUNK_T a)
|
|
{
|
|
return cpIsLsb_ct(a);
|
|
}
|
|
|
|
/* tests if a is even */
|
|
__INLINE BNU_CHUNK_T cpIsEven_ct(BNU_CHUNK_T a)
|
|
{
|
|
return ~cpIsLsb_ct(a);
|
|
}
|
|
|
|
/* tests if a==0 */
|
|
__INLINE BNU_CHUNK_T cpIsZero_ct(BNU_CHUNK_T a)
|
|
{
|
|
return cpIsMsb_ct(~a & (a - 1));
|
|
}
|
|
|
|
/* tests if a==b */
|
|
__INLINE BNU_CHUNK_T cpIsEqu_ct(BNU_CHUNK_T a, BNU_CHUNK_T b)
|
|
{
|
|
return cpIsZero_ct(a ^ b);
|
|
}
|
|
|
|
/* replace under mask: dst[] = replaceFlag? src[] : dst[] */
|
|
__INLINE void cpMaskedReplace_ct(BNU_CHUNK_T* dst, const BNU_CHUNK_T* src, int len, BNU_CHUNK_T replaceMask)
|
|
{
|
|
BNU_CHUNK_T dstMask = ~replaceMask;
|
|
int n;
|
|
for(n=0; n<len; n++)
|
|
dst[n] = (src[n] & replaceMask) ^ (dst[n] & dstMask);
|
|
}
|
|
|
|
/* copy under mask: dst[] = src1[] & mask) ^ src2[] & ~mask */
|
|
__INLINE void cpMaskedCopyBNU_ct(BNU_CHUNK_T* dst, BNU_CHUNK_T mask, const BNU_CHUNK_T* src1, const BNU_CHUNK_T* src2, int len)
|
|
{
|
|
int i;
|
|
for(i=0; i<(len); i++)
|
|
dst[i] = (src1[i] & mask) ^ (src2[i] & ~mask);
|
|
}
|
|
|
|
/* test if GF element is equal to x chunk */
|
|
__INLINE BNU_CHUNK_T cpIsGFpElemEquChunk_ct(const BNU_CHUNK_T* pE, int nsE, BNU_CHUNK_T x)
|
|
{
|
|
int i;
|
|
BNU_CHUNK_T accum = pE[0] ^ x;
|
|
for (i = 1; i < nsE; i++) {
|
|
accum |= pE[i];
|
|
}
|
|
return cpIsZero_ct(accum);
|
|
}
|
|
|
|
#define GFPE_IS_ZERO_CT(a,size) cpIsGFpElemEquChunk_ct((a),(size), 0)
|
|
|
|
#endif /* _PCP_MASK_CT_H */
|