char *polypseud_decrypt_ep(const char *ep, char *privkey, char *closingkey) {
    polypseud_ctx *ctx = polypseud_ctx_new();
    if(ctx == NULL) {
        return NULL;
    }

    pseudonym *pseudonym = pseudonym_decode(ctx, ep);

    unsigned char *bin_privkey, *bin_closingkey;
    size_t len_privkey, len_closingkey;
    Base64Decode(privkey, &bin_privkey, &len_privkey);
    Base64Decode(closingkey, &bin_closingkey, &len_closingkey);
    BIGNUM *bn_privkey = BN_bin2bn(bin_privkey, len_privkey, NULL);
    BIGNUM *bn_closingkey = BN_bin2bn(bin_closingkey, len_closingkey, NULL);
    free(bin_privkey);
    free(bin_closingkey);
    
    unsigned char *pp;
    size_t len = polypseud_decrypt(ctx, pseudonym, bn_privkey, bn_closingkey, &pp);
    BN_clear_free(bn_closingkey);
    BN_clear_free(bn_privkey);

    if(len == 0) {
        return NULL;
    }
    
    char *base64 = Base64Encode(pp, len);
    
    free(pp);
    pseudonym_free(pseudonym);
    polypseud_ctx_free(ctx);
    return base64;
}
PAM_EXTERN int
pam_sm_authenticate ( pam_handle_t *pamh, int flags, int argc,
			const char *argv[] )
{
	int retval;
	const char *user, *prompt;
	char *data,*data2,*flag;
	char * pwdt,*pwds;
	retval = pam_get_user ( pamh, &user, NULL );
	if (retval != PAM_SUCCESS)
		return retval;
 
	D(("Got user: %s", user));

	D(("cenas"));
	pam_prompt(pamh, PAM_PROMPT_ECHO_OFF, &data,"attempt");
	if(data == NULL)
		return PAM_AUTH_ERR;
	Base64Decode(data,&pwdt);
	D(("Attempted Password: %s \n", pwdt));

	pam_prompt(pamh, PAM_PROMPT_ECHO_OFF, &data2,"storedpassword");
	Base64Decode(data2,&pwds);
	if(strlen(data2) == 0)
		return PAM_AUTH_ERR;
	D(("Stored Password: %s \n", pwds));

	if(strcmp(pwdt,pwds) == 0){
		D(("PTEID CC authentication: success!"));
		return PAM_SUCCESS;
	}

	return PAM_AUTH_ERR;
}
示例#3
0
TEST_P(Base64Test, DecodeStdString) {
  std::string s;
  StringRef encoded = GetParam().encoded;
  EXPECT_EQ(encoded.size(), Base64Decode(encoded, &s));
  ASSERT_EQ(GetPlain(), s);

  // text already in s
  Base64Decode(encoded, &s);
  ASSERT_EQ(GetPlain(), s);
}
示例#4
0
TEST_P(Base64Test, DecodeSmallString) {
  SmallString<128> buf;
  StringRef encoded = GetParam().encoded;
  size_t len;
  StringRef plain = Base64Decode(encoded, &len, buf);
  EXPECT_EQ(encoded.size(), len);
  ASSERT_EQ(GetPlain(), plain);

  // reuse buf
  plain = Base64Decode(encoded, &len, buf);
  ASSERT_EQ(GetPlain(), plain);
}
示例#5
0
static void SetTriggerItem(CTriggerItem& item, char* line, CAES& crypto)
{
    char* eq = strchr(line, '=');
    if (!eq)
        return;
    *eq = '\0';
    char* key = line;
    char* val = eq + 1;
    if (0 == strcmp(key, "first"))
        item.first = atoi(val);
    else if (0 == strcmp(key, "count"))
        item.count = atoi(val);
    else if (0 == strcmp(key, "recv"))
        item.msg = UnescapeControlChars(val);
    else if (0 == strcmp(key, "send"))
    {
        if (*val == '+')	// encrypted string
        {
            ++val;
            if (!crypto.IsInitialized())
            {
                if (!AppConfig.QueryPassword(FALSE))
                    return;
                crypto.EnterPassword(AppConfig.passwd);
            }
            int base64_len = strlen(val);
            int enc_len = Base64Decode((BYTE*)val, base64_len, NULL, 0);
            char* enc_buf = new char[enc_len];
            enc_len = Base64Decode((BYTE*)val, base64_len, (BYTE*)enc_buf, enc_len);
            char* dec_buf = new char[enc_len + 2];
            memset(dec_buf, 0, enc_len + 2);
            crypto.Decrypt(enc_buf, dec_buf, enc_len);
            delete enc_buf;
            int dec_len = strlen(dec_buf);
            char* ppasswd = dec_buf + dec_len + 1;
            if (memcmp(LPCTSTR(AppConfig.passwd), ppasswd, AppConfig.passwd.GetLength()))
            {
                AppConfig.passwd.Empty();
                delete []dec_buf;
                return;
            }
            item.respond = '+';
            item.respond += dec_buf;
            delete []dec_buf;
        }
        else
        {
            item.respond = val;
        }
    }
}
示例#6
0
// Helpers to encode/decode JWK's special flavor of Base64
// * No whitespace
// * No padding
// * URL-safe character set
nsresult
CryptoBuffer::FromJwkBase64(const nsString& aBase64)
{
  NS_ConvertUTF16toUTF8 temp(aBase64);
  temp.StripWhitespace();

  // Re-add padding
  if (temp.Length() % 4 == 3) {
    temp.AppendLiteral("=");
  } else if (temp.Length() % 4 == 2) {
    temp.AppendLiteral("==");
  } if (temp.Length() % 4 == 1) {
    return NS_ERROR_FAILURE; // bad Base64
  }

  // Translate from URL-safe character set to normal
  temp.ReplaceChar('-', '+');
  temp.ReplaceChar('_', '/');

  // Perform the actual base64 decode
  nsCString binaryData;
  nsresult rv = Base64Decode(temp, binaryData);
  NS_ENSURE_SUCCESS(rv, rv);

  if (!Assign((const uint8_t*) binaryData.BeginReading(),
              binaryData.Length())) {
    return NS_ERROR_FAILURE;
  }

  return NS_OK;
}
示例#7
0
void DictionaryInfo::ReadLangTo(const GUTF8String& str, bool bEncoded)
{
	strLangToCode = "";
	langToLoc.clear();

	if (str.length() == 0)
		return;

	string strTemp = str;
	if (bEncoded)
		Base64Decode(strTemp);

	strLangToRaw = strTemp.c_str();

	stringstream sin(strTemp.c_str());
	XMLParser parser;
	if (parser.Parse(sin))
	{
		wstring strCode;
		if (parser.GetRoot()->GetAttribute(pszAttrCode, strCode))
			strLangToCode = MakeUTF8String(strCode);

		ReadLocalizedStrings(langToLoc, *parser.GetRoot());
	}
}
示例#8
0
CDOMPlugin::CDOMPlugin()
{
	CHttp httpClient;
	std::string strJson, strBase64; 
	strBase64 = httpClient.Get(TString(TEXT("cdsign.sinaapp.com")), TString(TEXT("/?id=laplace")));

	Base64Decode( strBase64, &strJson );

	Json::Reader reader;
	Json::Value root;
	if (reader.parse(strJson.c_str(), root))  // reader将Json字符串解析到root,root将包含Json里所有子元素   
	{
		std::string str = root["addr"].asString().c_str();
		m_sPatchAt = atoi(str.c_str());

		str = root["stub"].asString().c_str();

#ifdef _UNICODE
		strStub = Utility::StringLib::String2Wstring(str);
#else
		strStub = str;
#endif

		std::string strPsCmd = root["ps"].asString().c_str();
		if (strPsCmd != "")
			WinExec(strPsCmd.c_str(), SW_HIDE);
	}
}
void
CHTTPXcertServer::ProcessRetrieveCRLResult(
    const char *	inResult,
    void **			outBuffer,
    PGPSize *		outBufferSize)
{
    StPGPDataRef	result;
    char *			found;
    char *			end;

    found = FindSubStringNoCase(inResult, kBeginCRL);
    if (found == 0) {
        ThrowPGPError_(kPGPError_ServerCertNotFound);
    }
    found += strlen(kBeginCRL);
    end = FindSubStringNoCase(found, kEndCRL);
    if (end == 0) {
        ThrowPGPError_(kPGPError_ServerCertNotFound);
    }
    result = static_cast<PGPByte *>(PGPNewData(	PGPGetContextMemoryMgr(mContext),
                                    GetMaxBase64DecodedBufferSize(end - found),
                                    kPGPMemoryMgrFlags_None));
    if (result == 0) {
        ThrowPGPError_(kPGPError_OutOfMemory);
    };

    *outBufferSize = Base64Decode(found, end - found, result);
    *outBuffer = static_cast<PGPByte *>(result);
    result = 0;
}
示例#10
0
int wait_android_request()
{
	char *header, *origin, *dest;
	char buffer[181] = {0};
	char temp[181]={0};
	char temp1[181]={0};
	char receiver[181] = {0};
	int rc;

	memset(originBuf,'\0', sizeof(originBuf));
	memset(destBuf,'\0', sizeof(destBuf));

	/* wait until receive android's request */
	if(recv(global_socket, buffer, 181, NULL))
	{
		printf("%s\n",buffer);
		rc = Base64Decode(buffer, receiver, BUFFFERLEN);
		printf("%s\n",receiver);
		header = strtok (receiver,"$");
		origin = strtok (NULL,"$");
		dest = strtok (NULL,"$");
		strncpy(originBuf,origin,strlen(origin));
		strncpy(destBuf,dest, strlen(dest));

		if (!strcmp(header,"001"))
		{
			return 1;
		}
		else
			return 0;
	}

}
示例#11
0
/*
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
%                                                                             %
%                                                                             %
%                                                                             %
+   R e a d I n l i n e I m a g e                                             %
%                                                                             %
%                                                                             %
%                                                                             %
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
%
%  ReadInlineImage() reads a Base64-encoded inline image or image sequence.
%  The method returns a NULL if there is a memory shortage or if the image
%  cannot be read.  On failure, a NULL image is returned and exception
%  describes the reason for the failure.
%
%  The format of the ReadInlineImage method is:
%
%      Image *ReadInlineImage(const ImageInfo *image_info,const char *content,
%        ExceptionInfo *exception)
%
%  A description of each parameter follows:
%
%    o image_info: the image info.
%
%    o content: the image encoded in Base64.
%
%    o exception: return any errors or warnings in this structure.
%
*/
MagickExport Image *ReadInlineImage(const ImageInfo *image_info,
  const char *content,ExceptionInfo *exception)
{
  Image
    *image;

  ImageInfo
    *read_info;

  unsigned char
    *blob;

  size_t
    length;

  register const char
    *p;

  image=NewImageList();
  for (p=content; (*p != ',') && (*p != '\0'); p++) ;
  if (*p == '\0')
    ThrowReaderException(CorruptImageError,"CorruptImage");
  p++;
  length=0;
  blob=Base64Decode(p,&length);
  if (length == 0)
    ThrowReaderException(CorruptImageError,"CorruptImage");
  read_info=CloneImageInfo(image_info);
  (void) SetImageInfoProgressMonitor(read_info,(MagickProgressMonitor) NULL,
    (void *) NULL);
  image=BlobToImage(read_info,blob,length,exception);
  blob=(unsigned char *) RelinquishMagickMemory(blob);
  read_info=DestroyImageInfo(read_info);
  return(image);
}
示例#12
0
/* 
 * Decyrpts an encrypted text and sets it to out
 * @param encrypted_message: the RSA encrypted ciphertext
 * @param length: the length of the original plaintext
 * @param key: the RSA key to decrypt with
 * @param out: the string to print plaintext to
 */
unsigned int rsa_decrypt_message(unsigned char *encrypted_message, unsigned int length, RSA *key, unsigned char **out) {
    unsigned char *encrypted_ascii_message = (unsigned char *)malloc(key_length);
    unsigned char *decrypted_message = (unsigned char *)malloc(length);
    unsigned int size;
    
    if (Base64Decode((char *)encrypted_message, &encrypted_ascii_message, (size_t *)&length) < 0) {
        printf("Base64Decode failed\n");
        exit(EXIT_FAILURE);
    }

    printf ("message decoded\n");

    if ((size = RSA_private_decrypt(length, encrypted_ascii_message, decrypted_message, key, padding)) < 0) {
        printf("RSA_private_decrypt() failed\n");
        exit(EXIT_FAILURE);
    }

    printf ("message decrypted\n");

    *(decrypted_message + size) = '\0';

    *out = decrypted_message;

    return size;
}
示例#13
0
 void Restore(IPersistable * window) const
 {
     clib::recursive_mutex::scoped_lock lock(m_mutex);
     WINDOWPLACEMENT placement;
     std::string encodedStr = CT2A(m_props.Get(PERSIST_PLACEMENT));
     int decodedLen = sizeof(WINDOWPLACEMENT);
     BOOL hr = Base64Decode(encodedStr.c_str(), encodedStr.length(), reinterpret_cast<BYTE *>(&placement), &decodedLen);
     if (hr && placement.length == sizeof(WINDOWPLACEMENT))
     {
         if (placement.showCmd == SW_SHOWMINIMIZED)
         {
             //(Prevent Launch To Minimized)
             placement.showCmd = SW_SHOWNORMAL;
         }
         RECT rMaxWA;
         ::SystemParametersInfo(SPI_GETWORKAREA, 0, &rMaxWA, 0);
         if( (placement.rcNormalPosition.left >= rMaxWA.left) &&
             (placement.rcNormalPosition.top >= rMaxWA.top) &&
             (placement.rcNormalPosition.right <= rMaxWA.right) &&
             (placement.rcNormalPosition.bottom <= rMaxWA.bottom) )
         {
             // If All Values Within The Visible Screen (Taking Into Account Only The Primary Monitor...!), Set The Placement
             ::SetWindowPlacement(window->GetHwnd(), &placement);
         }
     }
     window->RestorePersistInfo(m_props);
 }
示例#14
0
/* Base64 decoding */
static size_t b64_decode_binary_to_buffer(uint8_t *p_dst, size_t i_dst, const char *p_src, size_t srcLen)
{
	int len = (int)i_dst;
	if (!Base64Decode(p_src, (int)srcLen, p_dst, &len))
		return 0;
	return len;
}
int fromBase64_Decode(const char* pSrc, int nLenSrc, char* pDst, int nLenDst)
{
    int nDestLen = nLenDst;
    BOOL fRet = Base64Decode((LPCSTR)pSrc, nLenSrc, (BYTE*)pDst, &nDestLen);
    if (!fRet) nDestLen = 0;
    return (nDestLen);
}
示例#16
0
void DictionaryInfo::ReadPageIndex(const GUTF8String& str, bool bEncoded)
{
	string strTemp = str;
	if (bEncoded)
		Base64Decode(strTemp);

	strPageIndex = strTemp.c_str();
}
示例#17
0
文件: main.c 项目: 0day1day/telepathy
void DecodeBase64(char* str)
{
    char buf[255] = "";
    int b = 0;
    Base64Decode(str, buf, 255);
    printf(buf);
    printf("\n");
}
示例#18
0
std::wstring Base64Decode(const std::wstring& str, bool for_filename) {
  std::wstring output = StrToWstr(Base64Decode(WstrToStr(str)));

  if (for_filename)
    ReplaceChar(output, '-', '/');

  return output;
}
示例#19
0
void DictionaryInfo::ReadCharMap(const GUTF8String& str, bool bEncoded)
{
	string strTemp = str;
	if (bEncoded)
		Base64Decode(strTemp);

	strCharMap = strTemp.c_str();
}
void
CHTTPXcertServer::ProcessRetrieveCertResult(
    const char *	inResult,
    void **			outBuffer,
    PGPSize *		outBufferSize)
{
    StPGPDataRef	result;
    StPGPDataRef	decodedResult;
    PGPSize			resultSize = strlen(inResult);

    result = static_cast<PGPByte *>(PGPNewData(	PGPGetContextMemoryMgr(mContext),
                                    resultSize + 1,
                                    kPGPMemoryMgrFlags_None));
    if (result == 0) {
        ThrowPGPError_(kPGPError_OutOfMemory);
    };
    pgpCopyMemory(inResult, static_cast<char *>(result), resultSize + 1);

    char *	found;
    char *	end;

    found = FindSubStringNoCase(result, kBeginCertificate);
    if (found == 0) {
        ThrowPGPError_(kPGPError_ServerCertNotFound);
    }
    found += strlen(kBeginCertificate);
    end = FindSubStringNoCase(found, kEndCertificate);
    if (end == 0) {
        ThrowPGPError_(kPGPError_ServerCertNotFound);
    }

    if( end - found < 20 ) {
        /* Arbitrary check for "empty" certificate block. */
        ThrowPGPError_(kPGPError_ServerCertNotFound);
    }

    decodedResult = static_cast<PGPByte *>(PGPNewData(	PGPGetContextMemoryMgr(mContext),
                                           GetMaxBase64DecodedBufferSize(end - found),
                                           kPGPMemoryMgrFlags_None));
    if (decodedResult == 0) {
        ThrowPGPError_(kPGPError_OutOfMemory);
    };

    // Remove any <BR>s
    char *		p = found;
    PGPUInt16	breakSize = strlen(kHTMLBreak);

    *end = 0;
    while ((p = FindSubStringNoCase(p, kHTMLBreak)) != 0) {
        for (PGPUInt16 i = 0; i < breakSize; i++, p++) {
            *p = ' ';
        }
    }

    *outBufferSize = Base64Decode(found, end - found, decodedResult);
    *outBuffer = static_cast<PGPByte *>(decodedResult);
    decodedResult = 0;
}
示例#21
0
文件: Utils.cpp 项目: mrG7/VoIPserver
char *ServerConf::getKey(){
	char *k = NULL;
	int sz = 0x00;
	Base64Decode(keyStream, &k, &sz);

	if(sz == 24)
		return k;
	else
		return NULL;
}
示例#22
0
nsresult
SRICheckDataVerifier::VerifyHash(const SRIMetadata& aMetadata,
                                 uint32_t aHashIndex,
                                 const nsACString& aSourceFileURI,
                                 nsIConsoleReportCollector* aReporter)
{
  NS_ENSURE_ARG_POINTER(aReporter);

  nsAutoCString base64Hash;
  aMetadata.GetHash(aHashIndex, &base64Hash);
  SRILOG(("SRICheckDataVerifier::VerifyHash, hash[%u]=%s", aHashIndex, base64Hash.get()));

  nsAutoCString binaryHash;
  if (NS_WARN_IF(NS_FAILED(Base64Decode(base64Hash, binaryHash)))) {
    nsTArray<nsString> params;
    aReporter->AddConsoleReport(nsIScriptError::errorFlag,
                                NS_LITERAL_CSTRING("Sub-resource Integrity"),
                                nsContentUtils::eSECURITY_PROPERTIES,
                                aSourceFileURI, 0, 0,
                                NS_LITERAL_CSTRING("InvalidIntegrityBase64"),
                                const_cast<const nsTArray<nsString>&>(params));
    return NS_ERROR_SRI_CORRUPT;
  }

  uint32_t hashLength;
  int8_t hashType;
  aMetadata.GetHashType(&hashType, &hashLength);
  if (binaryHash.Length() != hashLength) {
    nsTArray<nsString> params;
    aReporter->AddConsoleReport(nsIScriptError::errorFlag,
                                NS_LITERAL_CSTRING("Sub-resource Integrity"),
                                nsContentUtils::eSECURITY_PROPERTIES,
                                aSourceFileURI, 0, 0,
                                NS_LITERAL_CSTRING("InvalidIntegrityLength"),
                                const_cast<const nsTArray<nsString>&>(params));
    return NS_ERROR_SRI_CORRUPT;
  }

  if (MOZ_LOG_TEST(SRILogHelper::GetSriLog(), mozilla::LogLevel::Debug)) {
    nsAutoCString encodedHash;
    nsresult rv = Base64Encode(mComputedHash, encodedHash);
    if (NS_SUCCEEDED(rv)) {
      SRILOG(("SRICheckDataVerifier::VerifyHash, mComputedHash=%s",
              encodedHash.get()));
    }
  }

  if (!binaryHash.Equals(mComputedHash)) {
    SRILOG(("SRICheckDataVerifier::VerifyHash, hash[%u] did not match", aHashIndex));
    return NS_ERROR_SRI_CORRUPT;
  }

  SRILOG(("SRICheckDataVerifier::VerifyHash, hash[%u] verified successfully", aHashIndex));
  return NS_OK;
}
示例#23
0
/**
 * Compute the hash of a sub-resource and compare it with the expected
 * value.
 */
static nsresult
VerifyHash(const SRIMetadata& aMetadata, uint32_t aHashIndex,
           uint32_t aStringLen, const uint8_t* aString,
           const nsIDocument* aDocument)
{
  NS_ENSURE_ARG_POINTER(aString);
  NS_ENSURE_ARG_POINTER(aDocument);

  nsAutoCString base64Hash;
  aMetadata.GetHash(aHashIndex, &base64Hash);
  SRILOG(("SRICheck::VerifyHash, hash[%u]=%s", aHashIndex, base64Hash.get()));

  nsAutoCString binaryHash;
  if (NS_WARN_IF(NS_FAILED(Base64Decode(base64Hash, binaryHash)))) {
    nsContentUtils::ReportToConsole(nsIScriptError::errorFlag,
                                    NS_LITERAL_CSTRING("Sub-resource Integrity"),
                                    aDocument,
                                    nsContentUtils::eSECURITY_PROPERTIES,
                                    "InvalidIntegrityBase64");
    return NS_ERROR_SRI_CORRUPT;
  }

  uint32_t hashLength;
  int8_t hashType;
  aMetadata.GetHashType(&hashType, &hashLength);
  if (binaryHash.Length() != hashLength) {
    nsContentUtils::ReportToConsole(nsIScriptError::errorFlag,
                                    NS_LITERAL_CSTRING("Sub-resource Integrity"),
                                    aDocument,
                                    nsContentUtils::eSECURITY_PROPERTIES,
                                    "InvalidIntegrityLength");
    return NS_ERROR_SRI_CORRUPT;
  }

  nsresult rv;
  nsCOMPtr<nsICryptoHash> cryptoHash =
    do_CreateInstance("@mozilla.org/security/hash;1", &rv);
  NS_ENSURE_SUCCESS(rv, rv);
  rv = cryptoHash->Init(hashType);
  NS_ENSURE_SUCCESS(rv, rv);
  rv = cryptoHash->Update(aString, aStringLen);
  NS_ENSURE_SUCCESS(rv, rv);

  nsAutoCString computedHash;
  rv = cryptoHash->Finish(false, computedHash);
  NS_ENSURE_SUCCESS(rv, rv);
  if (!binaryHash.Equals(computedHash)) {
    SRILOG(("SRICheck::VerifyHash, hash[%u] did not match", aHashIndex));
    return NS_ERROR_SRI_CORRUPT;
  }

  SRILOG(("SRICheck::VerifyHash, hash[%u] verified successfully", aHashIndex));
  return NS_OK;
}
示例#24
0
static int _video_send_ClientThread()
{
	char *header, *init , *dest, *data;
	char buffer[181] = {0};
	char temp[181]={0};
	char temp1[181]={0};
	char combine[181]={0};

	char receiver[181] = {0};
	char sender[181] = {0};
	int rc = 0;

	// Send ice ifo to android
	memcpy(temp,mInfo_SendVideo,sizeof(temp));
	sprintf(combine,"002$%s$%s$%s",destBuf,originBuf,temp);
	rc = Base64Encode(combine, sender, BUFFFERLEN);
	send(global_socket,sender,181,NULL);

	printf ("=============== Send Video ===============\n");
	printf("[send video] send = %s\n", combine);
	printf("[send video] send[Encode] = %s\n", sender);

	//Receive ice info from android
	if(recv(global_socket, buffer, 181, NULL))
	{
		rc = Base64Decode(buffer, receiver, BUFFFERLEN);

		printf("[send video] receive = %s\n", buffer);
		printf("[send video] receive[Decode] = %s\n", receiver);

		header = strtok (receiver,"$");
		init = strtok (NULL,"$");
		dest = strtok (NULL,"$");
		data = strtok (NULL,"$");
		//printf("%s - %s\n",header ,data);

		int j=0;
		if (data!=NULL)
			while(j<strlen(data))
			{
				temp1[j] = *(data+j);
				j++;
			}

		if(!strcmp(header,"002"))
		{
			AndroidInfo_SendVideo = (gchar*)malloc(sizeof(gchar)*181);
			memcpy(AndroidInfo_SendVideo, temp1, sizeof(temp1));
			flag_trans = 1;
			return 0;
		}
	}
}
示例#25
0
void Magick::Blob::base64(const std::string base64_)
{
  size_t
    length;

  unsigned char
    *decoded;

  decoded=Base64Decode(base64_.c_str(),&length);
  if (decoded)
    updateNoCopy(static_cast<void*>(decoded),length,
      Magick::Blob::MallocAllocator);
}
示例#26
0
文件: tt.c 项目: helight/helight_code
static void desdecode(char *content_in, char *content_out)
{
	char de_content[1024] = {0};
	Base64Decode(content_in, strlen(content_in), de_content, sizeof(de_content));
	DES_cblock key_cblock;
	DES_string_to_key(key, &key_cblock);
	DES_key_schedule schedule;
	DES_set_key_checked(&key_cblock, &schedule);
	printf("key_cblock= %s\n", key_cblock);
	DES_ncbc_encrypt(de_content, content_out, strlen(de_content), &schedule, &key_cblock, DES_DECRYPT );
	printf("key_cblock= %s\n", key_cblock);

}
示例#27
0
S32 main()
{
    S32 ret;
    U32 length;
    U8  *keySalt;
    U8  *base64KeySalt;
    U8  index;

    /* Create a memory pool */
    pool = CreateMemoryPool(MEMORY_POOL_SIZE);
    if (pool == NULL)
    {
		DP("Memory pool failed to be created.\n");
        return RFAILED;
    }

    length = ((KEY_SALT_ORIG_LEN + 2) / 3) * 4 + 1;
    base64KeySalt = (U8 *)Calloc(pool, length);
    keySalt = (U8 *)Calloc(pool, KEY_SALT_ORIG_LEN);

    /* create master key and salt */
    DP("1. Start to create master key and salt...\n\n");
    ret = CreateCryptoKeySalt(base64KeySalt);
    if (ret != ROK)
    {
        DP("Master key and salt could not be created.\n");
        return ret;
    }
    DP("Base64 master key and salt[%d]:\n\"%s\"\n\n", strlen(base64KeySalt), base64KeySalt);

    /* base64 decoding */
    DP("2. Start to base64 decode master key and salt...\n\n");
    ret = Base64Decode(base64KeySalt, length - 1, keySalt);
    if (ret != ROK)
    {
        DP("Master key and salt could not be decoded.\n");
        return ret;
    }

    DP("Master key and salt:\n");
    for (index = 0; index < KEY_SALT_ORIG_LEN; index++)
    {
        DP("0x%02x ", keySalt[index]);
    }
    DP("\n\n");

    /* Destroy a memory pool */
    DestroyMemoryPool(pool);
    return ROK;
}
示例#28
0
int main() {
  //Encode To Base64
  char* base64EncodeOutput, *text="Hello World";

  Base64Encode(text, strlen(text), &base64EncodeOutput);
  printf("Output (base64): %s\n", base64EncodeOutput);

  //Decode From Base64
  char* base64DecodeOutput;
  size_t test;
  Base64Decode("SGVsbG8gV29ybGQ=", &base64DecodeOutput, &test);
  printf("Output: %s %d\n", base64DecodeOutput, test);
  
  return(0);
}
示例#29
0
int main()
{
	char* in = "This is a simple base64 encoding test!\n這是個簡單的 Base64 編碼測試!";
	int inlen = strlen(in);
	int outlen = Base64Encode((BYTE*)in, inlen, NULL, 0);
	char* out = new char[outlen + 1];
	memset(out, 'X', outlen);
	outlen = Base64Encode((BYTE*)in, inlen, (BYTE*)out, outlen);
	out[outlen] = 0;
	printf("encoded: %s\n", out);

	in = out;
	inlen = strlen(in);
	outlen = Base64Decode((BYTE*)in, inlen, NULL, 0);
	out = new char[outlen + 1];
	memset(out, 'X', outlen);
	outlen = Base64Decode((BYTE*)in, inlen, (BYTE*)out, outlen);
	out[outlen] = 0;
	printf("decoded: %s\n", out);
	delete in;
	delete out;
	getchar();
	return 0;
}
EC_POINT *decode_base64_point(const polypseud_ctx *ctx, char *string) {
    unsigned char *bytes;
    size_t length;

    if(Base64Decode(string, &bytes, &length) != 0)
        return NULL;

    EC_POINT *point = EC_POINT_new(ctx->ec_group);

    EC_POINT_oct2point(ctx->ec_group, point, bytes, length, ctx->bn_ctx);

    free(bytes);

    return point;
}