tailieunhanh - cryptography for developers PHẦN 3

Chức năng này lưu trữ một số nguyên trong một số có hai chữ số ASCII phải được trong khoảng 0-99 cho chức năng này để thành công. Nó cập nhật con trỏ đầu ra, như chúng ta sẽ thấy trong các chức năng tiếp theo là ngay lập tức hữu ích. Chúng tôi đang tái sử dụng der_printable_char_encode | 68 Chapter 2 Encoding 001 include 002 unsigned long der_utctime_length void 003 004 return 15 005 My thanks go to the revised specifications 001 include 002 003 static int putnum int val unsigned char out 004 005 unsigned char ptr 006 int h l 007 008 if val 0 return -1 009 010 ptr out 011 h val 10 012 l val 10 013 014 if h 9 l 9 015 return -1 016 017 018 ptr der_printable_char_encode 0123456789 h 019 ptr der_printable_char_encode 0123456789 l 020 out ptr 021 022 return 0 023 This function stores an integer in a two-digit ASCII number must be in the range 0 99 for this function to succeed. It updates the output pointer which as we shall see in the next function is immediately useful. We are re-using the der_printable_char_encode to convert our integers to the ASCII code required. 025 int der_utctime_encode UTCTIME in 026 unsigned char out 027 unsigned long outlen 028 029 check output size 030 if der_utctime_length outlen 031 return -1 032 033 034 store header and length 035 der_put_header_length out ASN1_DER_UTCTIME 13 outlen 036 037 store data Encoding Chapter 2 69 038 if putnum in- year 100 out 039 putnum in- month out 040 putnum in- day out 041 putnum in- hour out 042 putnum in- min out 043 putnum in- sec out 044 return -1 045 046 047 out der_printable_char_encode Z 048 049 return 0 050 After the standard issue header encoding we then proceed to store the fields of the date and time in order as expected. We make extensive use of the way the C language handles the double-OR bars . Specifically that is always implemented from left to right and will abort on the first nonzero return value without proceeding to the next case. This means for example that if after encoding the month the routine fails it will not encode the rest and will proceed inside to the braced statements directly. 001 include 002 003 static int readnum unsigned

crossorigin="anonymous">
Đã phát hiện trình chặn quảng cáo AdBlock
Trang web này phụ thuộc vào doanh thu từ số lần hiển thị quảng cáo để tồn tại. Vui lòng tắt trình chặn quảng cáo của bạn hoặc tạm dừng tính năng chặn quảng cáo cho trang web này.